Last active
January 24, 2019 19:31
-
-
Save onatbas/fab305dee0d40c37e853233e35471f77 to your computer and use it in GitHub Desktop.
roulette with geometric betting
This file contains 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 cash = 5000; | |
var originalBid = 80; | |
var bid = originalBid; | |
var adjuster = 100; | |
var adjustee = 80; | |
var turn = 0; | |
var consecutive = 0; | |
var previous = false; | |
var target = 250000; | |
var maxConsLoss = 0; | |
var maxConsWin = 0; | |
var allTimeLow = target; | |
var exit = false; | |
var buyIn = 5; | |
function doTurn(){ | |
return Math.random() < 0.474; | |
} | |
function adjust(){ | |
var adjusted = cash / adjustee; | |
console.log("*****\nADJUST original bet: " + originalBid + "--->"+adjusted); | |
originalBid = adjusted; | |
} | |
while (cash > 0 && !exit){ | |
if (bid < buyIn) bid = buyIn; | |
bid = bid - (bid % 1); | |
if (allTimeLow > cash) allTimeLow = cash; | |
if (cash > target){ | |
console.log("Consecutive " + (previous ? "win" : "loss") + ", " + consecutive); | |
console.log("***************"); | |
console.log("WINS " + cash + " - All time low: " + allTimeLow); | |
exit = true; | |
continue; | |
} | |
if (turn >= adjuster && turn % adjuster == 0){ | |
adjust(); | |
} | |
//console.log("Turn " + turn++ + ", Cash " + cash + ", Bid " + bid); | |
cash -= bid; | |
if (doTurn()){ | |
cash += 2*bid; | |
bid = originalBid; | |
if (previous == true){ | |
consecutive++; | |
if (maxConsWin<consecutive) maxConsWin=consecutive; | |
}else{ | |
//console.log("Consecutive " + (previous ? "win" : "loss") + ", " + consecutive); | |
//console.log("***************"); | |
previous = true; | |
consecutive = 1; | |
} | |
}else{ | |
bid += originalBid; | |
if (previous == false){ | |
if (consecutive%5 == 0){ | |
adjust(); | |
bid = originalBid; | |
} | |
consecutive++; | |
if (maxConsLoss<consecutive) maxConsLoss=consecutive; | |
}else{ | |
//console.log("Consecutive " + (previous ? "win" : "loss") + ", " + consecutive); | |
//console.log("***************"); | |
previous = false; | |
consecutive = 1; | |
} | |
} | |
} | |
console.log("Consecutive " + (previous ? "win" : "loss") + ", " + consecutive); | |
console.log("Max Consecutives: Win " + maxConsWin + ", Loss: " + maxConsLoss ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment