Giter Site home page Giter Site logo

crapssim's Introduction

๐ŸŽฒ๐Ÿ“ˆ crapssim

PyPI GitHub Repo stars

A python package to run all of the necessary elements of a Craps table. The package follows some natural logic:

  • a CrapsTable has Player(s) and Dice on it
  • the Player(s) have Bet(s) on the CrapsTable as prescribed by their strategies.

With these building blocks, crapssim supports

  • running 1 session with 1 player/strategy to test a realistic day at the craps table,
  • running many sessions with 1 player/strategy to understand how a strategy performs in the long term, or
  • running many sessions with many players/strategies to simulate how they compare to each other

These powerful options can lead to some unique analysis of the game of craps, such as the following figure comparing 4 strategies with a budget of $200:

best-budget-strategies

Results

I will post results from this simulator on my site: http://pages.stat.wisc.edu/~kent/blog.

Current blog posts include:

Installation

You can install crapssim with

pip install crapssim

This requires Python >=3.6 and pip to be installed on your computer. You will also need a recent version of numpy, which can be installed by pip install numpy.

Getting Started

There's a few good resources for getting started:

  1. Try the interactive google collab notebook to test a single strategy and see how the interface works
  2. Check out Corey Brown's scripts to define strategies and compare them: https://github.com/coreyabrown/CoreyCrapsSim
  3. Looks at the minimal working examples below

To see how a single session might play out for you using a pass line bet with double odds, over 20 rolls, one might run:

import crapssim as craps

table = craps.Table()
your_strat = craps.strategy.passline_odds2
you = craps.Player(bankroll=200, bet_strategy=your_strat)

table.add_player(you)
table.run(max_rolls=20)

To evaluate a couple of strategies across many table sessions, you can run:

import crapssim as craps 

n_sim = 20
bankroll = 300
strategies = {
    "place68": craps.strategy.place68, 
    "ironcross": craps.strategy.ironcross 
}

for i in range(n_sim):
    table = craps.Table() 
    for s in strategies:
        table.add_player(craps.Player(bankroll, strategies[s], s))

    table.run(max_rolls=float("inf"), max_shooter=10, verbose=False)
    for s in strategies:
        print(f"{i}, {s}, {table._get_player(s).bankroll}, {bankroll}, {table.dice.n_rolls}")

For more advanced strategies, you need to write a custom function that can perform the strategy. Some building blocks and examples can be found in strategy.py

Contributing

If you discover something interesting using this simulator, please let me know so that I can highlight those results here. You can find me at [email protected].

Those looking to contribute to this project are welcome to do so. Currently, the top priority is to improve

crapssim's People

Contributors

skent259 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.