Creating a simple Bettor




'''
so now we've got a bettor, he's working, and we've seen some basic outcomes
but now we want to see some longer-term outcomes, so first let's do that. 
'''


import random


# let us go ahead and change this to return a simple win/loss
def rollDice():
    roll = random.randint(1,100)

    if roll == 100:
        #print roll,'roll was 100, you lose. What are the odds?! Play again!'
        return False
    elif roll <= 50:
        #print roll,'roll was 1-50, you lose.'
        return False
    elif 100 > roll >= 50:
        #print roll,'roll was 51-99, you win! *pretty lights flash* (play more!)'
        return True


'''
Simple bettor, betting the same amount each time.
'''
def simple_bettor(funds,initial_wager,wager_count):
    value = funds
    wager = initial_wager

    currentWager = 0

    while currentWager < wager_count:
        if rollDice():
            value += wager
        else:
            value -= wager

        currentWager += 1

    # changed to reduce spam
    if value < 0:
        value = 'Broke!'
    print 'Funds:', value

# lots of wagers now....
x = 0

while x < 100:
    simple_bettor(10000,100,50)
    x += 1

		

Interestingly enough, you can see there is quite the spread here.

Keep in mind, the odds are only 1% against you.

Now we can see most people have gone broke, all but 1 person is either broke or a loser. Interestingly sometimes you find people actually make large profits.

This visualization, however, is sub par. let's add to this, shall we?

The next tutorial:





  • Monte Carlo Introduction
  • Monte Carlo dice Function
  • Creating a simple Bettor
  • Plotting Results with Matpltolib
  • Martingale Strategy
  • Bettor Statistics
  • More comparison
  • Graphing Monte Carlo
  • Fixing Debt Issues
  • Analyzing Monte Carlo results
  • Using Monte Carlo to find Best multiple
  • Checking betting results
  • D'Alembert Strategy
  • 50/50 Odds
  • Analysis of D'Alembert
  • Comparing Profitability
  • Finding best D'Alembert Multiple
  • Two dimensional charting monte carlo
  • Monte Carlo Simulation and Python
  • Labouchere System for Gambling Tested