Monte Carlo dice Function




Alright, so our dice works!

Now we need to create a bettor. Eventually, we'll create some more sophisticated bettors, but we'll start extremely basic for now, as even the simplist bettor will actually show us some fascinating things when it comes to chance and possibility, using a monte carlo generator.

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
        print 'Funds:', value



simple_bettor(10000,100,100)
		

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