#! /usr/bin/env python
## This simulator test whether a floating point draw
## game has the propensity to offer an advantage to
## a punter.
### RULES: Draw a number between 0 and 1 for floating
### values of 0.1. For every number drawn, if its sum
### is less than 1 for all previously drawn numbers,
### they player has the posibility to win 100 per draw.
### EX: [0.1, 0.3, 0.7]. Ths makes 1.1 so the game stops.//
### //The player will then make 300 dollars. This is after
### the player has paid 250 for a round.
import random
# Object section where the 'deck', called set_hand
# hold all possible numbers drawn. bankroll is zero
# for simulation purposes. test allows one to set the
# number of rounds for the simulation
set_hand = []
bankroll = 0
test = int(raw_input("Enter number of rounds: "))
test_start = test
# Conditional sets the set_hand list
# for elements to be drawn in the game.
for i in range(0, 11):
call = float(i)
set_hand.append(call/10)
## This should produce numbers 0.0 to 1.0
## in steps of 0.1.
if test > 0:
## Tests games under total number of rounds test.
while test > 0:
### runner holds the running count
### counter holds the number of floating//
### //values drawn in a round
### bankroll variable is changed throughout//
### //simulation
runner = 0
counter = 0
bankroll -= 250
### As long as the running count is less than 1.0
### floating values shall be drawn.
while runner < 1.0:
draw = random.choice(set_hand)
runner += draw
counter += 1
### After the running count reaches >= 1.0,
### compute payout based on 100 units per
### drawn floating element.
bankroll += counter*100
### Decrement the round and test conditional again.
test -= 1
else:
## Quasi-error message
print "Must be greater than zero(0)!"
# Prints bankroll after simulation
# Prints house edge after simulation
print bankroll
print float(bankroll)/float(test_start)