Advertisement
Guest User

Untitled

a guest
Jan 29th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. (
  2. --the roll function
  3. fn Roll =
  4. (
  5. myResult = random 1 51
  6. --print myResult
  7. if (myResult == 51) then (LOSE()) else
  8. --if the result is even
  9. if (mod myResult 2 == 0) then (LOSE()) else (WIN())
  10. )
  11.  
  12. --the LOSE function
  13. fn LOSE =
  14. (
  15.  
  16. print ("LOSE" + "\n" +
  17. "local loss is " + myBet as string + " and now substract " + myTotalLoss as string)
  18. global myTotalLoss = myTotalLoss + myBet
  19. print ("total loss is " + myTotalLoss as string)
  20. global myMoney = (myMoney - myBet)
  21. print ("Money = " + myMoney as string)
  22. global myBet = (myBet * 2)
  23. print ("Bet is now " + myBet as string)
  24. if (myBet > myLargestBet) then myLargestBet = myBet
  25. myAmountOfLosses = (myAmountOfLosses + 1)
  26. Roll()
  27. )
  28.  
  29. --the WIN function
  30. fn WIN =
  31. (
  32. global myTotalWinnings = (myTotalWinnings + myBet)
  33.  
  34. print ("WIN!" + "\n" +
  35. "Local win is " + myBet as string+ "\n" +
  36. "total win is " + myTotalWinnings as string+ "\n" +
  37. "Money = " + myMoney as string + " plus my winning amount of " + myBet as string)
  38. global myMoney = (myMoney + myBet)
  39. print ("So now Money = " + myMoney as string + "\n"
  40. "and Im up " + (myTotalWinnings - myTotalLoss) as string)
  41. myAmountOfWins = (myAmountOfWins + 1)
  42. )
  43.  
  44. --setting the initial variables
  45. global myBet = 5 --the initial bet amount
  46. global myMoney = 2560 --the amount of money you have
  47. global myTotalLoss = 0 --initial amount of lost money
  48. global myTotalWinnings = 0 --initial amount of won money
  49. global myLargestBet = 0 --I'll track the largest bet that I make
  50. global myAmountOfWins = 0 --Counts the wins
  51. global myAmountOfLosses = 0 --Counts the losses
  52.  
  53. for i = 1 to 100 do
  54. (
  55. Print ("Round " + i as string)
  56. myBet = 5
  57. Roll()
  58. )
  59.  
  60. --prints the final stats.
  61. finalCashflow = (myTotalWinnings - myTotalLoss)
  62. print ("\n" + "final result = $" + finalCashflow as string+ "\n" +
  63. "my largest bet was $" + myLargestBet as string + "\n" +
  64. "Amount of wins " + myAmountOfWins as string + "\n" +
  65. "Amount of losses " + myAmountOfLosses as string + "\n")
  66. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement