Include pushed roll chances in anydice

anydicedicestatisticsyear-zero-engine

D6 dice pool from 0 to 6 where resolving 0 is rolling 2 dice and counting the lower result only. Rolling 5 or 6 means a hit. Rolling 1 is a mishap. Degrees of Success:

  • Failure: no hits at all
  • Mixed Success: only 1 hit
  • Basic Success: at least 2 hits
  • Critical Success: at least 2 dice showing "6"

For this time rolling more than 2 hits will not count so no need to show that on anydice.

Now the players can take a risk and push the roll, rerolling all the dice that are not "1" or "hit" (5-6). The requirement is to have at least 1 hit in the initial roll. After the reroll, hits may increase for a better overall result; or if they scored no hits with the reroll, they lose a hit from the initial roll which can make the overall result worse. I need to see that just like in games like Vaesen where a chart shows the chance of success scaling with the number of dice but also the chance when pushing the roll.

I tried to do something but couldn't do well unfortunately.


function: push ROLL:s {
 H:0 \number of hits\
 C:0 \number of crits\
 loop X over {1..#ROLL} {
  if X@ROLL>4 {H:H+1 if X@ROLL=6 {C:C+1}}
 }
 result: C*10+H \to send both crit and hit numbers?\
}

function: make ROLL:s TBP:n {
 H:0 \number of hits\
 B:0 \number of blanks\
 C:0 \number of crits\
 loop X over {1..#ROLL} {
  if X@ROLL>4 {H:H+1 if X@ROLL=6 {C:C+1}}
  else if X@ROLL>1 {B:B+1}
 }
 if TBP=1 {
  T:[push Bd6]
  C:C+(T/10)
  H:H+(T-((T/10)*10))
 }
 
 if H>2 {H:2}
 if C>1 {result:3}
 else {result:H}
}

Then when I try to output it introduces this error;

Calculation error

Boolean values can only be numbers, but you provided "d{0..0}".
Depending on what you want, you might need to create a function.

Any help would be appreciated. I feel like there is a better way but I can't see it apparently.

EDIT::


function: make ROLL:s TBP:n HT:n BL:n CR:n {
 H:HT\H number of hits\
 B:BL\B number of blanks\
 C:CR\C number of crits\
 loop X over {1..#ROLL} {
  if X@ROLL>4 {H:H+1 if X@ROLL=6 {C:C+1}}
  else if X@ROLL>1 {B:B+1}
 }
 if H=HT {H:H-1 if C>1 {C:C-1}}
 if H>2 {if C>1 {H:3} else {H:2}}
 
 if H>0 & TBP=1 {result:[make Bd6 0 H B C]}
 else {result:H}
}

loop C over {1..6} {
  output [make Cd6 1 0 0 0] named "[C]d"
}

I've tried this and it's been compiled at least, but not sure if I can confirm it mathematically. And still is there a better way?

Best Answer

This program should do what you want:

function: push REROLL:s HITS:n SIXES:n {
 NEW_HITS: [count {5, 6} in REROLL]
 NEW_SIXES: [count 6 in REROLL]
 if SIXES + NEW_SIXES >= 2 {
  result: 3
 }
 if NEW_HITS >= 1 {
  result: [lowest of HITS + NEW_HITS and 2]
 }
 result: [lowest of HITS - 1 and 2]
}

function: vaesen INITIAL:s {
 HITS: [count {5, 6} in INITIAL]
 SIXES: [count 6 in INITIAL]
 BLANKS: [count {2, 3, 4} in INITIAL]
 if SIXES >= 2 {
  result: 3
 }
 if HITS >= 1 & BLANKS >= 1 {
  result: [push BLANKSd6 HITS SIXES]
 }
 result: [lowest of HITS and 2]
}

loop C over {1..6} {
 output [vaesen Cd6] named "[C]d"
}

Note that there are some subtleties:

  • There is no reason to reroll if you rolled two sixes initially.
  • You can't reroll if there are no blanks.

You might also explore strategic pushing.

For what it's worth, I have a more advanced calculator for the SRD version of the Year Zero Engine, though Vaesen does not use this version.