# Count successes in pools of stepped dice

I tried to find this but my google-fu fails me. This is a mechanic similar to Blade Runner or Twilight 2000 RPG.

For any action, the player rolls 2 dice which could range from 2d6 to 2d12 or anything in between (1d8 and 1d6; 1d8 and 1d10; 1d6 and 1d10, etc.) AND the gamemaster rolls similar 2 dice as difficulty.

Each 6+ counts as 1 success and 10+ counts as 2 successes. So, for instance, I roll 1d8 and 1d10 and the gamemaster rolls 2d8. I come up with 6 and 7 and the gamemaster rolls 4 and 6. I have 2 successes and the gamemaster has 1. I win. Another example: I roll 1d6 and 1d10 and the gamemaster rolls 1d8 and 1d10. I come up with 3 and 10 and the gamemaster rolls 8 and 10. I have 2 successes and the gamemaster has 3 successes, the gamemaster wins.

Here's where the thing gets trickier: the player (not the gamemaster) can reroll some or all of my dice once after the first roll. Can someone assist me with figuring out the odds of the first roll and rerolls?

It seems Anydice could do this but I'm illiterate with all but the most basic functions of that website. Thanks in advance.

• Can you provide the whole set of die types you are using in such context? Just d6,d8,d10,d12? Or even d20? Jan 24 at 10:51
• Just d6, d8, d10 and d12. Jan 24 at 12:15
• Two questions: (1) What happens if the player and the GM roll the same number of successes? (2) Does the player have to decide which dice they want to reroll before rerolling any of them, or can they reroll some of the dice and only then decide if they want to reroll more? (This is relevant if your first roll is, say, 1 and 6 on 2d12 and you need three successes to win. If possible, the optimal strategy is then to first reroll the 1 and only risk rerolling the 6 if the first reroll doesn't give you two successes.) Jan 24 at 14:33
• My first idea, would be when you reroll, you choose which dice to reroll, but after you reroll, you cannot reroll a third time. Also, ties go to the character who "defends". This means if the GM rolls 3 successes, the only chance you have of succeeding is a combination of dice that includes a d10 or d12. This is intentional. This being said, you only reroll the dice you choose to reroll. Jan 24 at 15:31
• Also, I added the tag for year-zero-engine, which both mentioned games are based on. Let me know if I've misinterpreted what you're looking for. Jan 25 at 7:37

Anydice:

D_SIX: d{0,0,0,0,0,1}
D_EIGHT: d{0,0,0,0,0,1,1,1}
D_TEN: d{0,0,0,0,0,1,1,1,1,2}
D_TWELVE: d{0,0,0,0,0,1,1,1,1,2,2,2}

function: reroll DIE:n with R_DIE:n if less than B:n {
if (DIE >= B) { result: DIE }
result: R_DIE
}

D_SIX_R: [reroll D_SIX with D_SIX if less than 1]
D_EIGHT_R: [reroll D_EIGHT with D_EIGHT if less than 1]
D_TEN_R_ZERO: [reroll D_TEN with D_TEN if less than 1]
D_TEN_R_ONE: [reroll D_TEN with D_TEN if less than 2]
D_TWELVE_R_ZERO: [reroll D_TWELVE with D_TWELVE if less than 1]
D_TWELVE_R_ONE: [reroll D_TWELVE with D_TWELVE if less than 2]

output (D_TEN_R_ONE + D_SIX_R) >= (D_TEN + D_SIX)


## Usage:

in the output area the first two dice are those of the player. For these use the ..._R versions. Note that you have two different _R dice for d10 and d12 as you can either only reroll 0s or also reroll 1s in hope for a 2. R_ZERO means only 0s are rerolled and R_ONE means that also 1s are rerolled.
The second set of dice are the ones of the GM. Use the dice without the _R suffix for them as the GM is not allowed to reroll

## Strategy for rerolling while playing:

Generally you always want to reroll any die which has no success and never reroll dice that have their maximum successes. Also if you already won the check you also won't reroll anything The edge case for real strategy is the question whether or not to reroll d10 or d12 that do have a success.

I calculated all cases and this is the summary of the results:
You NEVER want to reroll a d10 that has a single success unless you absolutly can't win the check without a double success on that very die.

Rerolling the other die is always better to achive a winning result. rerolling a single success on a d12 is better than not rerolling it in following two scenarios:

• you have a d6 and a d12
• you have a d10 and a d12 and you need 3 successes to win

In any other case where you do not explicitly need a double success on that very die, keeping a single success and trying to get the missing successes with the other die is always better (or at least exactly as good).

## AnyDice with optimal strategy:

function: success DIE:n {
result: (DIE > 5) + (DIE > 9)
}

function: player has P_A:n and P_B:n against GM_A:n and GM_B:n {
result: [inner [success dP_A] or [success dP_A] on die P_A and [success dP_B] or [success dP_B]on die P_B against [success dGM_A] + [success dGM_B]]
}

function: player has P_A:n and P_B:n against GM_A:n and GM_B:n gm defends{
result: [inner [success dP_A] or [success dP_A] on die P_A and [success dP_B] or [success dP_B]on die P_B against [success dGM_A] + [success dGM_B] + 1]
}

function: inner AA:n or AB:n on die A:n and BA:n or BB:n on die B:n against GM:n {
A_USED: AA
B_USED: BA
if (A_USED + B_USED) >= GM {
result: 1
}
if (AA = 0 | (AA < [maximum of [success dA]] & AA + [maximum of [success dB]] < GM ) ) {
A_USED: AB
}
if (BA = 0 | ((BA < [maximum of [success dB]]) & ((BA + [maximum of [success dA]] < GM ) | (GM = 2 & B = 12 & A < 10) | (GM = 3 & B = 12) ))) {
B_USED: BB
}
result : (A_USED + B_USED) >= GM
}

output [player has 6 and 12 against 8 and 12]
output [player has 6 and 12 against 8 and 12 gm defends]


## Usage:

in the output area the first two numbers represent the players dice. Note that you only put the number without the 'd' in front. So in the example the player has a d6 and a d12 denoted with 6 and 12. To ensure optimal rerolling strategy you have to put the smaller die first and the bigger second (disregard this for two identical dice).
The second two numbers represent the GMs dice. As with player dice just put the numbers without a 'd' in there. For the GM the order is not important.
If the GM defends (ties are GM victories) you can append gm defends like the second output does.

From my tests this strategy gives you in most cases 1-2% better chance at victory than simply rerolling dice that have no successes.

• Thanks, that helps a lot. However, I'm confused about the 1s and 0s. What do you mean only 0s are rerolled? Also, if I change the >= to > does this mean I have to have more successes than the GM to win? Jan 25 at 14:05
• @HugoB R_ZERO are the "no brainer" version, meaning that you only reroll the die, if it doesn't have a success. It can only get better through rerolling. R_ONE are the "high roller" variant, meaning that you also reroll single successes on that die, hoping for a double success (only relevant for d10 and d12). But in this case you have the risk of making your roll worse by rerolling. In generel that technique is good on the d12 and bad on the d10 unless ofcourse you are in a situation where you cant win without the double success. Jan 25 at 14:27
• @HugoB Yes. For the >= is for the situation that the player wins in case of a draw (player defends). Replace it with > when the player would lose on a draw (gm defends). Jan 25 at 14:28
• And the plus (+) sign between dice? Does this mean the dice are added or it just counts each success on each dice? Jan 25 at 16:08
• @HugoB Their successes are added. I have defined the dice as having the respective number of successes written on their sides. E.g. the first line 'D_SIX: d{0,0,0,0,0,1}' means that D_SIX is a six sided die that has zeros written on five sides and a one on one side. That makes it much easier to implement dice that can have multiple successes in AnyDice Jan 26 at 7:26

## Interactive calculator

It's not AnyDice, but I have a Year Zero Engine calculator here, powered by my Icepool Python package. This is based on the Year Zero Engine Standard Reference Document v1.0; in particular, 1s are "banes", which cannot be rerolled, and if you choose to push (i.e. reroll at all), any banes showing at the end cause some sort of damage to the roller.

For you, I've added an option to optimize pushing for probability of winning.

The entire source code is embedded in the page itself, or you can view it here. Here are a few key parts.

### Vector-valued die

Fundamentally, we track eight pieces of information:

• The number of successes and banes.
• The number of each die type that rolled zero successes (2-5 raw) and therefore are always positive expected value in terms of successes to push.
• The number of d10s and d12s that rolled a single success, which we could risk for doubles if we really wanted.
@cache
def year_zero_die(sides):
"""success, bane, zero on d6, d8, d10, d12, ones on d10, d12."""
def func(x):
if x == 1:
result = (0, 1, 0, 0, 0, 0, 0, 0)
elif x < 6:
result = (0, 0, sides == 6, sides == 8, sides == 10, sides == 12, 0, 0)
elif x < 10:
result = (1, 0, 0, 0, 0, 0, sides == 10, sides == 12)
else:
result = (2, 0, 0, 0, 0, 0, 0, 0)
return icepool.Vector(result)
return icepool.d(sides).map(func)


### Finding the optimal push strategy

After computing the result of the initial roll, if we didn't win, we will certainly want to push any dice that rolled zero successes (2-5 raw). We may or may not want to push d10s and d12s that rolled single successes; we consider all options, keeping in mind that we would never push a single-success d10 unless we pushed all of the single-success d12s, since the d10 is less likely to double and more likely to zero or bane.

@cache
def calc_maximize_win(success, bane, z6, z8, z10, z12, s10, s12):
"""Try to maximize the chance of winning."""
if success > 0:
return icepool.vectorize(success, 0)
if not can_win(success, bane, z6, z8, z10, z12, s10, s12):
return icepool.vectorize(success, 0)

best = calc_push_everything(success, bane, z6, z8, z10, z12, s10, s12)
best_win = icepool.Die([best]).marginals[0].probability_gt(0)
while True:
if s10 > 0:
s10 -= 1
elif s12 > 0:
s12 -= 1
else:
break
candidate = calc_push_everything(success, bane, z6, z8, z10, z12, s10, s12)
candidate_win = icepool.Die([candidate]).marginals[0].probability_gt(0)
if candidate_win >= best_win:
# candidate wins ties, since it has fewer rerolls = fewer banes
best = candidate
best_win = candidate_win

return best


## Partial Answer: single die analysis##

d6 and d8 are easy. You just reroll them when they have no success so it is the chance of having at least one success in two roll with such a die

• d6 => ~30.5% chance for 1 success
• d8 => ~60.9% chance for 1 success

for d10 and d12 you have the situation that it might be worth the risk to reroll 1 success in hope for 2 successes

• d10 (only reroll 0 success)
15% chance for 2 successes
60% chance for 1 success
25% chance for 0 success
• d10 (also reroll 1 success)
19% chance for 2 successes
36% chance for 1 success
45% chance for 0 success
• d12 (only reroll 0 success)
~35.4% chance for 2 successes
~47.2% chance for 1 success
~17.4% chance for 0 success
• d12 (also reroll 1 success)
45.75% chance for 2 successes
25.00% chance for 1 success
29.25% chance for 0 success