Skip to content

Instantly share code, notes, and snippets.

@listenlight
Last active April 22, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save listenlight/15bf7d17aa2b788f026541252b78acf1 to your computer and use it in GitHub Desktop.
Save listenlight/15bf7d17aa2b788f026541252b78acf1 to your computer and use it in GitHub Desktop.
var hsh = {win: 0, lose: 0, balance: 1000, bet: 1, biggestBet: 0, odds: 0.66 }
for(i = 1; i <= 1000; i++) {
if(Math.random() <= hsh.odds) {
hsh.win++;
hsh.balance += hsh.bet * 1.5
hsh.bet = 1;
} else {
hsh.lose++;
hsh.balance -= hsh.bet;
hsh.bet *= 3;
if(hsh.bet > hsh.biggestBet) {
hsh.biggestBet = hsh.bet;
}
}
}
hsh.odds = hsh.win / (hsh.win + hsh.lose);
console.log(hsh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment