Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (
- --the roll function
- fn Roll =
- (
- myResult = random 1 51
- --print myResult
- if (myResult == 51) then (LOSE()) else
- --if the result is even
- if (mod myResult 2 == 0) then (LOSE()) else (WIN())
- )
- --the LOSE function
- fn LOSE =
- (
- print ("LOSE" + "\n" +
- "local loss is " + myBet as string + " and now substract " + myTotalLoss as string)
- global myTotalLoss = myTotalLoss + myBet
- print ("total loss is " + myTotalLoss as string)
- global myMoney = (myMoney - myBet)
- print ("Money = " + myMoney as string)
- global myBet = (myBet * 2)
- print ("Bet is now " + myBet as string)
- if (myBet > myLargestBet) then myLargestBet = myBet
- myAmountOfLosses = (myAmountOfLosses + 1)
- Roll()
- )
- --the WIN function
- fn WIN =
- (
- global myTotalWinnings = (myTotalWinnings + myBet)
- print ("WIN!" + "\n" +
- "Local win is " + myBet as string+ "\n" +
- "total win is " + myTotalWinnings as string+ "\n" +
- "Money = " + myMoney as string + " plus my winning amount of " + myBet as string)
- global myMoney = (myMoney + myBet)
- print ("So now Money = " + myMoney as string + "\n"
- "and Im up " + (myTotalWinnings - myTotalLoss) as string)
- myAmountOfWins = (myAmountOfWins + 1)
- )
- --setting the initial variables
- global myBet = 5 --the initial bet amount
- global myMoney = 2560 --the amount of money you have
- global myTotalLoss = 0 --initial amount of lost money
- global myTotalWinnings = 0 --initial amount of won money
- global myLargestBet = 0 --I'll track the largest bet that I make
- global myAmountOfWins = 0 --Counts the wins
- global myAmountOfLosses = 0 --Counts the losses
- for i = 1 to 100 do
- (
- Print ("Round " + i as string)
- myBet = 5
- Roll()
- )
- --prints the final stats.
- finalCashflow = (myTotalWinnings - myTotalLoss)
- print ("\n" + "final result = $" + finalCashflow as string+ "\n" +
- "my largest bet was $" + myLargestBet as string + "\n" +
- "Amount of wins " + myAmountOfWins as string + "\n" +
- "Amount of losses " + myAmountOfLosses as string + "\n")
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement