Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simulator for craps with various betting strategies

License

NotificationsYou must be signed in to change notification settings

skent259/crapssim

Repository files navigation

PyPIGitHub Repo stars

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:

  • aTable hasPlayer(s) andDice on it
  • thePlayer(s) haveBet(s) on theTable
  • eachPlayer'sStrategy can automatically set upBet(s)

With these building blocks, crapssim supports

  • running1 session with1 player/strategy to test a realistic day at the craps table,
  • runningmany sessions with1 player/strategy to understand how a strategy performs in the long term, or
  • runningmany sessions withmany 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

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:

importcrapssimascrapsfromcrapssim.strategyimportBetPassLine,PassLineOddsMultipliertable=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:

importcrapssimascrapsn_sim=20bankroll=300strategies= {"place68":craps.strategy.examples.PassLinePlace68(5),"ironcross":craps.strategy.examples.IronCross(5),}foriinrange(n_sim):table=craps.Table()forsinstrategies:table.add_player(bankroll,strategy=strategies[s],name=s)table.run(max_rolls=float("inf"),max_shooter=10,verbose=False)forpintable.players:print(f"{i},{p.name},{p.bankroll},{bankroll},{table.dice.n_rolls}")

For more advanced strategies, you can either write your own customStrategy 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 willneed an installation of python version 3.10 or newer. Then, run the followingcode in your terminal:

pipinstallcrapssim

Development installation instructions arealso available.

Results

Some results from this simulator have been posted tohttp://pages.stat.wisc.edu/~kent/blog:

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

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

  • Supported bets (seebet.py)
  • Supported strategies (seestrategy)
  • Documentation

[8]ページ先頭

©2009-2025 Movatter.jp