Examples
Configuration
Statistics
- Probability of killing anything: 51.852%
- Probability of killing Player 2: 0.000%
- Probability of killing all 2 minions for Player 2: 0.000%
- Probability of killing at least 1 minion for Player 2: 51.852%
- Probability of killing any 2-health minion: 51.852%
- Probability of any minion at or less than 1-health: 96.296%
- Probability of any minion at or less than 2-health: 100.000%
- Probability of all minions at or less than 1-health: 48.148%
- Probability of all minions at or less than 2-health: 100.000%
Chance of Individual Result
Player 2 | #1 (2hp) | #2 (2hp) |
---|
HP | Chance | Σ↑ |
---|
Full | 25.926% | 25.93% | 29/30 | 48.148% | 74.07% | 28/30 | 22.222% | 96.30% | 27/30 | 3.704% | 100.00% |
| HP | Chance | Σ↑ |
---|
Full | 27.778% | 27.78% | 1/2 | 46.296% | 74.07% | Dead | 25.926% | 100.00% |
| HP | Chance | Σ↑ |
---|
Full | 27.778% | 27.78% | 1/2 | 46.296% | 74.07% | Dead | 25.926% | 100.00% |
|
Board States
1 attack (3 outcomes)Chance | P2 | #1 (2hp) | #2 (2hp) |
---|
33.333% | 30→29 | 2→2 | 2→2 | 33.333% | 30→30 | 2→1 | 2→2 | 33.333% | 30→30 | 2→2 | 2→1 |
| 2 attack (6 outcomes)Chance | P2 | #1 (2hp) | #2 (2hp) |
---|
22.222% | 30→29 | 2→1 | 2→2 | 22.222% | 30→29 | 2→2 | 2→1 | 22.222% | 30→30 | 2→1 | 2→1 | 11.111% | 30→28 | 2→2 | 2→2 | 11.111% | 30→30 | 2→0 | 2→2 | 11.111% | 30→30 | 2→2 | 2→0 |
| 3 attack (8 outcomes)Chance | P2 | #1 (2hp) | #2 (2hp) |
---|
22.222% | 30→29 | 2→1 | 2→1 | 12.963% | 30→29 | 2→0 | 2→2 | 12.963% | 30→29 | 2→2 | 2→0 | 12.963% | 30→30 | 2→0 | 2→1 | 12.963% | 30→30 | 2→1 | 2→0 | 11.111% | 30→28 | 2→1 | 2→2 | 11.111% | 30→28 | 2→2 | 2→1 | 3.704% | 30→27 | 2→2 | 2→2 |
|
Algorithm
// turn an array of healths into a decodable-string
// note: we need strings since php arrays are shit
function encode($a) {
return implode(':', $a);
}
// turn an encoded-string into an array of healths
function decode($s) {
return array_map('intval', explode(':', $s));
}
// given a hash of states: encoded(healths) -> probability
// return the probability of each possible resulting state
// after applying one random attack to all remaining units
function bomb($states) {
$u = array();
foreach ($states as $enc => $prior) {
$x = decode($enc);
$a = array();
for ($i = 0; $i < count($x); $i++) { // collect indices of living units
if ($x[$i] > 0) {
$a[] = $i;
}
}
foreach ($a as $i) { // apply an attack to each unit
$v = $x; // copy the healths
$v[$i]--; // reduce hp by one
$k = encode($v);
$c = array_key_exists($k, $u) ? $u[$k] : 0;
$u[$k] = $c + $prior / count($a); // update probabilities
}
}
return $u;
}
Example
// initial board state
$healths = array(2, 2);
// initial board distribution
// (100% chance we have 2x 2-hp units)
$s0 = array(encode(healths) => 1);
[2:2] => 1.00000
// apply one random attack
$s1 = bomb($s0);
[1:2] => 0.50000
[2:1] => 0.50000
// apply another
$s2 = bomb($s1);
[0:2] => 0.25000
[1:1] => 0.50000
[2:0] => 0.25000