($i < 10 ? 1 : 0), 'hit' => 6); // start with a more exact sample game? $sampleGame = 1; if ($sampleGame) { // A Game with Ira and Jason switch ($i) { case 0: $hunts[$i] = array('num' => 2, 'hit' => 6); break; case 1: $hunts[$i] = array('num' => 1, 'hit' => 6); break; case 2: $hunts[$i] = array('num' => 1, 'hit' => 5); break; case 3: $hunts[$i] = array('num' => 2, 'hit' => 6); break; case 4: $hunts[$i] = array('num' => 2, 'hit' => 6); break; case 5: $hunts[$i] = array('num' => 2, 'hit' => 5); break; case 6: $hunts[$i] = array('num' => 2, 'hit' => 6); break; case 7: $hunts[$i] = array('num' => 2, 'hit' => 5); break; case 8: $hunts[$i] = array('num' => 2, 'hit' => 4); break; case 9: $hunts[$i] = array('num' => 2, 'hit' => 3); break; case 10: $hunts[$i] = array('num' => 4, 'hit' => 6); break; case 11: $hunts[$i] = array('num' => 3, 'hit' => 6); break; default: break; } } if (array_key_exists('num'.$i, $_POST) && is_numeric($_POST['num'.$i])) { // must be at least 0 and no more than 5 $hunts[$i]['num'] = min(max(0, $_POST['num'.$i]), 5); } if (array_key_exists('hit'.$i, $_POST) && is_numeric($_POST['hit'.$i])) { // to hit value must be at least 2 and no more than 6 $hunts[$i]['hit'] = min(max(2, $_POST['hit'.$i]), 6); } $total_dice += $hunts[$i]['num']; if ($hunts[$i]['num'] > 0) { $maxActualHunts++; } } $results = array(); for ($i = 0; $i <= $total_dice; $i++) { // first value is total hits, second value is at least one hit $results[] = array(0, 0); } ?>

A WotR Hunt Simulation with trials

= $toHit) { $hits++; } } return $hits; } function printGames ($start, $atLeastOneHitOption) { global $results; global $tempSum; // rough error checking if ($start < 0 || $start > count($results)) { return; } echo " \n"; echo " ".($start)."\n"; echo " ".$results[$start][$atLeastOneHitOption]."\n"; $tempSum += $results[$start][$atLeastOneHitOption]; echo " ".$tempSum."\n"; echo " \n"; } $totalHitsSum = 0; $totalSuccessfulHuntsSum = 0; for ($g = 0; $g < $GAMES; $g++) { $atLeastOneHit = 0; $totalHits = 0; // for each hunt for ($i = 0; $i < $MAX_HUNTS; $i++) { $hits = calculateHits($hunts[$i]['num'], $hunts[$i]['hit']); $totalHits += $hits; if ($hits > 0) { $atLeastOneHit++; } } // track the results. the second array tracks total hits vs. at least one hit $results[$totalHits][0]++; $results[$atLeastOneHit][1]++; $totalHitsSum += $totalHits; $totalSuccessfulHuntsSum += $atLeastOneHit; } // for each game // Calculate the overall average ?> On average, there were 0 hits per game. On average, there were 0 successful hunts per game.

Hits Frequency Sum
Successful Hunts Frequency Sum
Eyes To Hit
Hunt 1:
Trials: