Last active
April 22, 2018 14:49
-
-
Save listenlight/15bf7d17aa2b788f026541252b78acf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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