= roll(100)) { $injail = 1; $progress = $jail_space - $current_space - $progress - $d1 - $d2; } } } // store progress if (!$injail) { $progress += $d1 + $d2; // if we just passed go and are on doubles, credit the Go now if ($current_space + $progress >= $max_space && $d1 == $d2) { $current_space = $current_space + $progress - $max_space; $interim_progress = $progress; $progress = 0; $go_count++; } } // error checking $dice_results[] = $d1; $dice_results[] = $d2; } // while we're rolling // update current space if ($injail) { $jail_count++; $current_space = $jail_space; } else { $current_space += $progress; } // did we pass go? while ($current_space >= $max_space) { $current_space -= $max_space; $go_count++; } // keep track of the results // if we passed go in the middle of the roll // and we went to jail, then it's simple if ($injail) { $results[$progress]++; } // if we didn't go to jail, we need to add interim progress else { $results[$progress + $interim_progress]++; } $g++; } // for each roll krsort($results); // Calculate the average squares advanced per roll $averageProgress = 0; $freqErrorCheck = 0; foreach ($results as $progress => $freq) { $averageProgress += $progress * $freq; $freqErrorCheck += $freq; } $averageProgress /= $g; // Calculate the averages $rollspergo = $g / $go_count; $averageJailChance = $jail_count / $g * 100; ?>

A Monopoly simulation with rolls

The average squares advanced per roll is 0.
The average number of rolls to Pass Go is 0.
The chance of going to Jail on a roll is 0%.
0) { echo "
In this simulation, it took "; echo "".round($g/$rollsperminute,0)." minutes to pass Go "; echo $limitbygo." times.
"; } ?>

$freq) { ?>
Roll Progress Frequency Percentage
0%
Avoid Go To Jail space?
(If checked, player will never land there)
Avoid Triple Doubles?
(If checked, player will never roll 3 doubles)
Percentage probability of
going to Jail from a Chance card:
Rolls:
(Max 100,000)
Stop after Passing Go a certain # of times:
(0 = no limit)
Rolls per Minute:
Show Dice Rolls?

"; $i = 1; while ($i < count($dice_results) && $i < 100) { echo "(".$dice_results[$i-1]." ".$dice_results[$i].") "; $i += 2; } } ?>