Skip to content

Instantly share code, notes, and snippets.

@Flyingmana
Created April 13, 2012 21:25
Show Gist options
  • Save Flyingmana/2380277 to your computer and use it in GitHub Desktop.
Save Flyingmana/2380277 to your computer and use it in GitHub Desktop.
<?php
/**
a little simulation for my brother who thought,
you can make money with the right roulette strategy.
**/
$budget = 1000000;
$games = 0;
$stake = 1;
while( $budget > 0){
$games++;
$budget = $budget - $stake;
if( rand(1,38) <= 18 ) //chance the color you chosed wins
{
$budget = $budget + $stake;
$stake = 1;
}else{
$stake = $stake * 2;
}
//echo "Game:$games; Budget: $budget;" . PHP_EOL;
}
echo "Games:$games; Rest Budget:$budget;" . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment