fork download
  1. #! /usr/bin/env python
  2.  
  3. ## This simulator test whether a floating point draw
  4. ## game has the propensity to offer an advantage to
  5. ## a punter.
  6.  
  7. ### RULES: Draw a number between 0 and 1 for floating
  8. ### values of 0.1. For every number drawn, if its sum
  9. ### is less than 1 for all previously drawn numbers,
  10. ### they player has the posibility to win 100 per draw.
  11. ### EX: [0.1, 0.3, 0.7]. Ths makes 1.1 so the game stops.//
  12. ### //The player will then make 300 dollars. This is after
  13. ### the player has paid 250 for a round.
  14.  
  15. import random
  16.  
  17. # Object section where the 'deck', called set_hand
  18. # hold all possible numbers drawn. bankroll is zero
  19. # for simulation purposes. test allows one to set the
  20. # number of rounds for the simulation
  21.  
  22. set_hand = []
  23. bankroll = 0
  24. test = int(raw_input("Enter number of rounds: "))
  25. test_start = test
  26.  
  27. # Conditional sets the set_hand list
  28. # for elements to be drawn in the game.
  29.  
  30. for i in range(0, 11):
  31. call = float(i)
  32. set_hand.append(call/10)
  33.  
  34. ## This should produce numbers 0.0 to 1.0
  35. ## in steps of 0.1.
  36.  
  37. if test > 0:
  38.  
  39. ## Tests games under total number of rounds test.
  40.  
  41. while test > 0:
  42.  
  43. ### runner holds the running count
  44. ### counter holds the number of floating//
  45. ### //values drawn in a round
  46. ### bankroll variable is changed throughout//
  47. ### //simulation
  48.  
  49. runner = 0
  50. counter = 0
  51. bankroll -= 250
  52.  
  53. ### As long as the running count is less than 1.0
  54. ### floating values shall be drawn.
  55.  
  56. while runner < 1.0:
  57. draw = random.choice(set_hand)
  58. runner += draw
  59. counter += 1
  60.  
  61. ### After the running count reaches >= 1.0,
  62. ### compute payout based on 100 units per
  63. ### drawn floating element.
  64.  
  65. bankroll += counter*100
  66.  
  67. ### Decrement the round and test conditional again.
  68.  
  69. test -= 1
  70. else:
  71.  
  72. ## Quasi-error message
  73.  
  74. print "Must be greater than zero(0)!"
  75.  
  76. # Prints bankroll after simulation
  77. # Prints house edge after simulation
  78.  
  79. print bankroll
  80. print float(bankroll)/float(test_start)
Runtime error #stdin #stdout #stderr 0.03s 44896KB
stdin
Standard input is empty
stdout
Enter number of rounds: 
stderr
Traceback (most recent call last):
  File "<builtin>/app_main.py", line 75, in run_toplevel
  File "prog.py", line 24, in <module>
    test = int(raw_input("Enter number of rounds: "))
EOFError