Skip to main content

Simulator for Craps with various betting strategies

Project description

:game_die::chart_with_upwards_trend: crapssim

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.

Getting Started

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 skent259@gmail.com.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crapssim-0.2.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distributions

crapssim-0.2.0-py3.8.egg (26.2 kB view details)

Uploaded Source

crapssim-0.2.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file crapssim-0.2.0.tar.gz.

File metadata

  • Download URL: crapssim-0.2.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for crapssim-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e54467dd8d6be8389a988789aaafad8533b7e6d50dfa7e5631f183b818cc92e7
MD5 b185513d8c6529cdd75260307102fab5
BLAKE2b-256 b659d4a16a410c96bfe4b8f6db1c3b23b1c47c0bb12844f0f85da8d3d6d5e0eb

See more details on using hashes here.

File details

Details for the file crapssim-0.2.0-py3.8.egg.

File metadata

  • Download URL: crapssim-0.2.0-py3.8.egg
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for crapssim-0.2.0-py3.8.egg
Algorithm Hash digest
SHA256 134c519a46dcf51e8b7638a45dca17d204c6f98b6050df2a89ef7dfb127b599e
MD5 2314ade5b1107a991a82f08f86df266e
BLAKE2b-256 2233afd53179ba77fbacefc2925f30ab15438b3c00b84b666155ac80264020f3

See more details on using hashes here.

File details

Details for the file crapssim-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: crapssim-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for crapssim-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d31fabb14905c9f1f4b6f67b3dcade926eed0d03b5e3af127601b32206a3c27
MD5 8aef01bf2483e1411da67f112dd9564c
BLAKE2b-256 8291ac38507455609276cf304e78692364bfc732c427fc2139bccaa186e83a7a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page