# How to include pushed roll chances in anydice?

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?

• I've never heard of "anydice", but it looks like some variables are not declared (or noted as globally declared). What is T, d, and P? Commented Oct 12, 2023 at 2:00
• Are "mishaps" (i.e. rolls of 1) relevant in any way, except that they cannot be rerolled? And what about "crits" as mentioned in your code (but not in the rest of your question, AFAICT)? Commented Oct 12, 2023 at 16:25
• Also, as far as the error (and some subtler bugs) in your current code is concerned, please see rpg.stackexchange.com/questions/192067/… and rpg.stackexchange.com/questions/206414/… Commented Oct 12, 2023 at 17:34
• Thanks for the responses. The relevancy of mishaps comes from my interpretation of the code. (Which might be horrible sorry) To determine the number of dice I send to the push function, I thought mishaps must be counted. "Crits" is only checking for 6s for critical success is achieved by rolling multiple 6s only so I wanted to count them separately. I have seen those questions but I don't think I have the exact same usage here. I only try to gather the output without any condition (TBP is to be pushed and I just discarded that and nothing has changed). I'll try to do a recursion instead now. Commented Oct 12, 2023 at 17:55

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.

• This is brilliant! Thank you, I'll definitely check the calculator. Commented Oct 13, 2023 at 12:55