Simulator for Craps with various betting strategies
Project description
:game_die::chart_with_upwards_trend: crapssim
When playing craps in a casino, there are unlimited combinations of ways that that players can place their bets. But, with this freedom comes complexity, and players deserve to know how a strategy could perform in each session. The 'crapssim' package is designed answer these tough questions: What's a fun strategy involving multiple numbers where the house edge doesn't increase too much? What's the best amount of passline or don't pass odds for my bankroll? Does hedging my bet improve my net winnings?
Crapssim is a python package which runs all of the necessary elements of a Craps table. The package follows some natural logic:
- a
TablehasPlayer(s) andDiceon it - the
Player(s) haveBet(s) on theTable - each
Player'sStrategycan automatically set upBet(s)
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:
It's easy to get 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
from crapssim.strategy import BetPassLine, PassLineOddsMultiplier
table = craps.Table()
your_strat = BetPassLine(5) + PassLineOddsMultiplier(2)
table.add_player(strategy=your_strat)
table.run(max_rolls=20, verbose=True)
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.examples.PassLinePlace68(5),
"ironcross": craps.strategy.examples.IronCross(5),
}
for i in range(n_sim):
table = craps.Table()
for s in strategies:
table.add_player(bankroll, strategy=strategies[s], name=s)
table.run(max_rolls=float("inf"), max_shooter=10, verbose=False)
for p in table.players:
print(f"{i}, {p.name}, {p.bankroll}, {bankroll}, {table.dice.n_rolls}")
For more advanced strategies, you can either write your own custom Strategy class or add strategy components together. To see the many possibilities, start with the tutorials on documentation site:
Installation
For a normal user, it is recommended to install the official release. You will need an installation of python version 3.10 or newer. Then, run the following code in your terminal:
pip install crapssim
Development installation instructions are also available.
Results
Some results from this simulator have been posted to http://pages.stat.wisc.edu/~kent/blog:
- One Surprising Feature of Dark Side Betting
- 5 Systems to Try at the Craps Table
- Craps: Best Strategies on a Budget
- All Bets Are Off: Re-learning the Pass Line Bet in Craps
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
- Supported strategies (see strategy)
- Documentation
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crapssim-0.4.0.tar.gz.
File metadata
- Download URL: crapssim-0.4.0.tar.gz
- Upload date:
- Size: 68.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4a9e2dd2567078c7f54464fc3e7dd39dc896f7dc648efa02a85e71ae38f6588
|
|
| MD5 |
750d3a195f87834cb2e48d735beacffb
|
|
| BLAKE2b-256 |
8bb0c2e936d45f4c3a39aa68eb8df90ebc623d30f8bc7920594bcea0b4492a71
|
Provenance
The following attestation bundles were made for crapssim-0.4.0.tar.gz:
Publisher:
python-publish.yml on skent259/crapssim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crapssim-0.4.0.tar.gz -
Subject digest:
d4a9e2dd2567078c7f54464fc3e7dd39dc896f7dc648efa02a85e71ae38f6588 - Sigstore transparency entry: 708128999
- Sigstore integration time:
-
Permalink:
skent259/crapssim@025978a1a1d7c32e1b516107612d1545936cad4f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/skent259
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@025978a1a1d7c32e1b516107612d1545936cad4f -
Trigger Event:
release
-
Statement type:
File details
Details for the file crapssim-0.4.0-py3-none-any.whl.
File metadata
- Download URL: crapssim-0.4.0-py3-none-any.whl
- Upload date:
- Size: 81.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a006733ee2c36f5bb7a6512dd4aecf4ceac8f634fcd75c5a05242093182a92b4
|
|
| MD5 |
77e966fb7361228675ec72cfcf6ac73f
|
|
| BLAKE2b-256 |
3fd4bde8c8e8de7eebf31086447acfec43219060e289c9871355f5ad0797a380
|
Provenance
The following attestation bundles were made for crapssim-0.4.0-py3-none-any.whl:
Publisher:
python-publish.yml on skent259/crapssim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crapssim-0.4.0-py3-none-any.whl -
Subject digest:
a006733ee2c36f5bb7a6512dd4aecf4ceac8f634fcd75c5a05242093182a92b4 - Sigstore transparency entry: 708129000
- Sigstore integration time:
-
Permalink:
skent259/crapssim@025978a1a1d7c32e1b516107612d1545936cad4f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/skent259
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@025978a1a1d7c32e1b516107612d1545936cad4f -
Trigger Event:
release
-
Statement type: