// places a bet on either red or black // and doubles your original bet if you // lose and repeats until you get your // money back. set display mode 320, 240, 32 backdrop on color backdrop 0 sync on sync rate 0 disable escapekey randomize timer() displayData = 1 defaultCash = 100 cash = defaultCash - 1 defaultBet = 1 bet = defaultBet tableLimit = 100 picking = rnd(1) do //wait key randomize timer() box 1, 1, screen width(), screen height(), rgb(0,255,0), 0 , rgb(255,0,0), 0 inc iteration if bet = 1 if picking = 1 picking = 0 else picking = 1 endif endif result = rnd(1) //the 0 if rnd(36) = 0 result = -1 endif if displayData = 1 text 10, 0, "iteration = " + str$(iteration) text 10, 10, "cash = " + str$(cash) text 10, 20, "bet = " + str$(bet) text 10, 30, "PICKED = " + str$(picking) text 10, 40, "RESULT = " + str$(result) text 10, 60, "Spacekey = pause" text 10, 75, "Ctrl = reset escape = exit" endif //work out if you've won if result = picking // we've won, lets add our bet*2 cash = cash + bet + bet // place a new bet bet = defaultBet cash = cash - bet else if bet + bet < tableLimit // we've lost, lets try and get our money back by doubling the bet bet = bet + bet cash = cash - bet else // our new bet would be over the table limit so we have to start again bet = defaultBet cash = cash - bet endif endif if bet > highestBet highestBet = bet endif if cash < lowest lowest = cash endif if controlkey() cash = 99 bet = defaultBet iteration = 0 highestBet = 0 lowest = 0 endif repeat until spacekey() = 0 if displayData = 1 sync endif if escapekey() exit endif loop message "Result?", "Simulated "+str$(iteration)+" games. You started with "+str$(defaultCash)+" and walked away with "+str$(cash)+". Your highest bet was "+str$(highestBet)+" after getting into a debt of "+str$(lowest)+"." end