Hearthstone Random Attack Calculator

Examples

Configuration

Hero Minions Instructions
Player 1
  • Enter minion healths separated by whitespace.
  • Do not include the bombing Bomber as a minion.
  • Add +1-health for a Divine Shield.
  • To avoid friendly-fire, put Player 1 at 0-health.
  • For only enemy minions, put Player 2 at 0-health too.
  • Only simulates random 1-damage attacks.
  • Random Attack Algorithm
Player 2
Attacks Decimal Places
Board
States
I changed the attack limit to unlimited but only the final board state is shown when above 12 attacks.
You can override this setting but the result might be very large (10 MB+) and/or fail.
 Always Show ALL Board States

Statistics

Chance of Individual Result

Player 1Player 2
HPChanceΣ↑
Full12.500%12.50%
29/3037.500%50.00%
28/3037.500%87.50%
27/3012.500%100.00%
HPChanceΣ↑
Full12.500%12.50%
29/3037.500%50.00%
28/3037.500%87.50%
27/3012.500%100.00%

Board States

1 attack (2 outcomes)
ChanceP1P2
50.000%30→3030→29
50.000%30→2930→30
2 attack (3 outcomes)
ChanceP1P2
50.000%30→2930→29
25.000%30→3030→28
25.000%30→2830→30
3 attack (4 outcomes)
ChanceP1P2
37.500%30→2930→28
37.500%30→2830→29
12.500%30→3030→27
12.500%30→2730→30

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