# The hard math of killing zombies in Zombicide

I happen to play Zombicide. It's cooperative board game set in some kind of post-apocalyptic, zombie-infested, world.

Despite the general theme, lots of people like it, so we play it quite a lot.

One thing that bugged us, was : in given scenario, which weapon it's best to use?

Weapons in zombicide work by providing 2 numbers: how many die you have to roll, and what is the minimum score on a dice to count for a hit.

For example, you can have “nailbat", which uses 2 die, and hit is counted for each die from the roll that generated 3 or more.

So, I can have 0 hits, 1 hit, or 2 hits (naturally, I can't have more hits than I rolled die).

Then there are weapons like chainsaw, which use 5 die, but hit is counted from 5 on a dice.

The question is – assuming I am attacking (for example) 2 zombies – is it better to use nailbat, or chainsaw? Nailbat has 66% chance of hitting with each dice, but on the other hand chainsaw uses more die, so perhaps it evens out?

In this particular case, it's better to use chainsaw. Nailbat has 44.44% of chance of generating two hits, and chainsaw gives me over 53% of chances that I will get 2 (or more) hits, thus killing those two zombies.

But how to calculate it? And what about more complex cases, like rolling 12 die?

After quite a long research, lots of frustration, I got help from a guy on irc.

With him, I read parts of Binominal distribution (on wikipedia), and then was able to write this:

```#!/usr/bin/env ruby
# encoding: utf-8

def factorial (n)
if n<=1
1
else
n * factorial(n-1)
end
end

def probability(dice, kills_from, monsters)
hit_probability = (7.0 - kills_from.to_f ) / 6.to_f;
result = 0

monsters.upto(dice) do | actual_monsters |
part_a = factorial(dice).to_f / ( factorial(actual_monsters).to_f * factorial( dice - actual_monsters ).to_f )
part_b = hit_probability.to_f ** actual_monsters.to_f
part_c = ( 1.0 - hit_probability) ** (dice - actual_monsters)
result += part_a * part_b * part_c
end
result
end

2.upto(6) do |kills_from|
puts "Weapon kills from #{kills_from}"
1.upto(20) do |dice|
printf '* %2d %-4s: ', dice, dice > 1 ? "die" : "dice"
1.upto(dice) do |monsters|
printf "%2d+: %5.2f ; ", monsters, (probability( dice, kills_from, monsters ) * 10000).floor.to_f / 100
end
puts
end
end```

It probably can be optimized, and/or made nicer, but the fact is that it generates all statistics for up to 20 die in 0.04s. Fast enough.

And if you'd need these statistics:

# Weapon kills from 2:

dice # kill count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 83.33%
2 97.22% 69.44%
3 99.53% 92.59% 57.87%
4 99.92% 98.37% 86.80% 48.22%
5 99.98% 99.66% 96.45% 80.37% 40.18%
6 99.99% 99.93% 99.12% 93.77% 73.67% 33.48%
7 99.99% 99.98% 99.79% 98.23% 90.42% 66.97% 27.90%
8 99.99% 99.99% 99.95% 99.53% 96.93% 86.51% 60.46% 23.25%
9 99.99% 99.99% 99.99% 99.88% 99.10% 95.19% 82.17% 54.26% 19.38%
10 99.99% 99.99% 99.99% 99.97% 99.75% 98.45% 93.02% 77.52% 48.45% 16.15%
11 99.99% 99.99% 99.99% 99.99% 99.93% 99.53% 97.54% 90.44% 72.67% 43.06% 13.45%
12 99.99% 99.99% 99.99% 99.99% 99.98% 99.87% 99.20% 96.36% 87.48% 67.74% 38.13% 11.21%
13 99.99% 99.99% 99.99% 99.99% 99.99% 99.96% 99.76% 98.73% 94.88% 84.19% 62.80% 33.64% 9.34%
14 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.93% 99.58% 98.09% 93.10% 80.62% 57.94% 29.59% 7.78%
15 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.98% 99.87% 99.33% 97.26% 91.02% 76.84% 53.22% 25.96% 6.49%
16 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.96% 99.78% 98.99% 96.22% 88.66% 72.91% 48.67% 22.71% 5.40%
17 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.98% 99.93% 99.65% 98.53% 94.96% 86.03% 68.87% 44.35% 19.83% 4.50%
18 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.98% 99.88% 99.46% 97.93% 93.47% 83.17% 64.78% 40.26% 17.27% 3.75%
19 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.96% 99.81% 99.21% 97.19% 91.75% 80.11% 60.69% 36.43% 15.02% 3.13%
20 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.99% 99.98% 99.94% 99.71% 98.87% 96.28% 89.81% 76.87% 56.65% 32.86% 13.04% 2.60%

# Weapon kills from 3:

dice # kill count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 66.66%
2 88.88% 44.44%
3 96.29% 74.07% 29.62%
4 98.76% 88.88% 59.25% 19.75%
5 99.58% 95.47% 79.01% 46.09% 13.16%
6 99.86% 98.21% 89.98% 68.03% 35.11% 8.77%
7 99.95% 99.31% 95.47% 82.67% 57.06% 26.33% 5.85%
8 99.98% 99.74% 98.03% 91.20% 74.13% 46.82% 19.50% 3.90%
9 99.99% 99.90% 99.17% 95.75% 85.51% 65.03% 37.71% 14.30% 2.60%
10 99.99% 99.96% 99.65% 98.03% 92.34% 78.68% 55.92% 29.91% 10.40% 1.73%
11 99.99% 99.98% 99.86% 99.11% 96.13% 87.79% 71.10% 47.25% 23.41% 7.51% 1.15%
12 99.99% 99.99% 99.94% 99.61% 98.12% 93.35% 82.22% 63.15% 39.30% 18.11% 5.39% 0.77%
13 99.99% 99.99% 99.97% 99.83% 99.11% 96.53% 89.64% 75.86% 55.20% 32.24% 13.87% 3.85% 0.51%
14 99.99% 99.99% 99.99% 99.93% 99.59% 98.25% 94.23% 85.05% 68.98% 47.55% 26.11% 10.53% 2.74% 0.34%
15 99.99% 99.99% 99.99% 99.97% 99.81% 99.14% 96.91% 91.17% 79.69% 61.83% 40.40% 20.92% 7.93% 1.94% 0.22%
16 99.99% 99.99% 99.99% 99.98% 99.92% 99.59% 98.40% 95.00% 87.34% 73.74% 54.69% 33.91% 16.59% 5.93% 1.37% 0.15%
17 99.99% 99.99% 99.99% 99.99% 99.96% 99.81% 99.19% 97.27% 92.45% 82.81% 67.39% 47.76% 28.13% 13.04% 4.41% 0.96% 0.10%
18 99.99% 99.99% 99.99% 99.99% 99.98% 99.91% 99.60% 98.55% 95.66% 89.23% 77.67% 60.85% 41.22% 23.10% 10.16% 3.26% 0.67% 0.06%
19 99.99% 99.99% 99.99% 99.99% 99.99% 99.96% 99.81% 99.25% 97.59% 93.52% 85.38% 72.06% 54.30% 35.18% 18.79% 7.86% 2.40% 0.47% 0.04%
20 99.99% 99.99% 99.99% 99.99% 99.99% 99.98% 99.91% 99.62% 98.70% 96.23% 90.81% 80.94% 66.14% 47.93% 29.72% 15.15% 6.04% 1.75% 0.33% 0.03%

# Weapon kills from 4:

dice # kill count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 50.00%
2 75.00% 25.00%
3 87.50% 50.00% 12.50%
4 93.75% 68.75% 31.25% 6.25%
5 96.87% 81.25% 50.00% 18.75% 3.12%
6 98.43% 89.06% 65.62% 34.37% 10.93% 1.56%
7 99.21% 93.75% 77.34% 50.00% 22.65% 6.25% 0.78%
8 99.60% 96.48% 85.54% 63.67% 36.32% 14.45% 3.51% 0.39%
9 99.80% 98.04% 91.01% 74.60% 50.00% 25.39% 8.98% 1.95% 0.19%
10 99.90% 98.92% 94.53% 82.81% 62.30% 37.69% 17.18% 5.46% 1.07% 0.09%
11 99.95% 99.41% 96.72% 88.67% 72.55% 50.00% 27.44% 11.32% 3.27% 0.58% 0.04%
12 99.97% 99.68% 98.07% 92.70% 80.61% 61.27% 38.72% 19.38% 7.29% 1.92% 0.31% 0.02%
13 99.98% 99.82% 98.87% 95.38% 86.65% 70.94% 50.00% 29.05% 13.34% 4.61% 1.12% 0.17% 0.01%
14 99.99% 99.90% 99.35% 97.13% 91.02% 78.80% 60.47% 39.52% 21.19% 8.97% 2.86% 0.64% 0.09%
15 99.99% 99.95% 99.63% 98.24% 94.07% 84.91% 69.63% 50.00% 30.36% 15.08% 5.92% 1.75% 0.36% 0.04%
16 99.99% 99.97% 99.79% 98.93% 96.15% 89.49% 77.27% 59.81% 40.18% 22.72% 10.50% 3.84% 1.06% 0.20% 0.02%
17 99.99% 99.98% 99.88% 99.36% 97.54% 92.82% 83.38% 68.54% 50.00% 31.45% 16.61% 7.17% 2.45% 0.63% 0.11% 0.01%
18 99.99% 99.99% 99.93% 99.62% 98.45% 95.18% 88.10% 75.96% 59.27% 40.72% 24.03% 11.89% 4.81% 1.54% 0.37% 0.06%
19 99.99% 99.99% 99.96% 99.77% 99.03% 96.82% 91.64% 82.03% 67.61% 50.00% 32.38% 17.96% 8.35% 3.17% 0.96% 0.22% 0.03%
20 99.99% 99.99% 99.97% 99.87% 99.40% 97.93% 94.23% 86.84% 74.82% 58.80% 41.19% 25.17% 13.15% 5.76% 2.06% 0.59% 0.12% 0.02%

# Weapon kills from 5:

dice # kill count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 33.33%
2 55.55% 11.11%
3 70.37% 25.92% 3.70%
4 80.24% 40.74% 11.11% 1.23%
5 86.83% 53.90% 20.98% 4.52% 0.41%
6 91.22% 64.88% 31.96% 10.01% 1.78% 0.13%
7 94.14% 73.66% 42.93% 17.32% 4.52% 0.68% 0.04%
8 96.09% 80.49% 53.17% 25.86% 8.79% 1.96% 0.25% 0.01%
9 97.39% 85.69% 62.28% 34.96% 14.48% 4.24% 0.82% 0.09%
10 98.26% 89.59% 70.08% 44.07% 21.31% 7.65% 1.96% 0.34% 0.03%
11 98.84% 92.48% 76.58% 52.74% 28.89% 12.20% 3.86% 0.88% 0.13% 0.01%
12 99.22% 94.60% 81.88% 60.69% 36.84% 17.77% 6.64% 1.87% 0.38% 0.05%
13 99.48% 96.14% 86.12% 67.75% 44.79% 24.13% 10.35% 3.46% 0.88% 0.16% 0.02%
14 99.65% 97.25% 89.46% 73.88% 52.44% 31.01% 14.94% 5.76% 1.74% 0.40% 0.06%
15 99.77% 98.05% 92.06% 79.07% 59.59% 38.16% 20.30% 8.82% 3.08% 0.85% 0.18% 0.02%
16 99.84% 98.62% 94.06% 83.40% 66.08% 45.30% 26.25% 12.65% 4.99% 1.59% 0.40% 0.07% 0.01%
17 99.89% 99.03% 95.58% 86.95% 71.86% 52.23% 32.60% 17.18% 7.54% 2.72% 0.80% 0.18% 0.03%
18 99.93% 99.32% 96.73% 89.83% 76.89% 58.77% 39.14% 22.32% 10.76% 4.33% 1.44% 0.39% 0.08% 0.01%
19 99.95% 99.52% 97.59% 92.13% 81.20% 64.81% 45.69% 27.93% 14.61% 6.47% 2.40% 0.74% 0.18% 0.03%
20 99.96% 99.66% 98.24% 93.95% 84.84% 70.27% 52.06% 33.85% 19.05% 9.18% 3.76% 1.29% 0.37% 0.08% 0.01%

# Weapon kills from 6:

dice # kill count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 16.66%
2 30.55% 2.77%
3 42.12% 7.40% 0.46%
4 51.77% 13.19% 1.62% 0.07%
5 59.81% 19.62% 3.54% 0.33% 0.01%
6 66.51% 26.32% 6.22% 0.87% 0.06%
7 72.09% 33.02% 9.57% 1.76% 0.20% 0.01%
8 76.74% 39.53% 13.48% 3.06% 0.46% 0.04%
9 80.61% 45.73% 17.82% 4.80% 0.89% 0.11%
10 83.84% 51.54% 22.47% 6.97% 1.54% 0.24% 0.02%
11 86.54% 56.93% 27.32% 9.55% 2.45% 0.46% 0.06%
12 88.78% 61.86% 32.25% 12.51% 3.63% 0.79% 0.12% 0.01%
13 90.65% 66.35% 37.19% 15.80% 5.11% 1.26% 0.23% 0.03%
14 92.21% 70.40% 42.05% 19.37% 6.89% 1.90% 0.41% 0.06%
15 93.50% 74.03% 46.77% 23.15% 8.97% 2.73% 0.66% 0.12% 0.01%
16 94.59% 77.28% 51.32% 27.08% 11.33% 3.77% 1.00% 0.21% 0.03%
17 95.49% 80.16% 55.64% 31.12% 13.96% 5.03% 1.46% 0.34% 0.06% 0.01%
18 96.24% 82.72% 59.73% 35.21% 16.82% 6.52% 2.06% 0.53% 0.11% 0.01%
19 96.86% 84.97% 63.56% 39.30% 19.88% 8.24% 2.80% 0.78% 0.18% 0.03%
20 97.39% 86.95% 67.13% 43.34% 23.12% 10.18% 3.71% 1.12% 0.28% 0.05% 0.01%

## One thought on “The hard math of killing zombies in Zombicide”

1. Tim says:

Thx a lot, very usefull. Impressive!