Skip to main content

A table game engine.

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn

craps


Logo

A lightweight table game simulator.

· Report Bug · Request Feature

Installation

Install with pip (recommended)

pip install craps

Usage

!pip install craps
from craps import Game, PassBet, LineOddsBet, ComeBet, PointOddsBet
Collecting craps
  Downloading craps-1.1.0-py3-none-any.whl (9.9 kB)
Installing collected packages: craps
Successfully installed craps-1.1.0
# Start a game with $100 at a table with a $10 minimum
g = Game(arrival_cash = 100, minimum_bet=10)

# Place a bet for $10, then roll the dice!
g.bet(PassBet(10))
g.roll()
[Bet] You made a PassBet on the box for 10
[Rail] You have 990.0 on the rail
[Table] The shooter is ready, the point is off
[Table] PassBet for 10 is working on the box
[Roll] Shooter rolled 10
[Roll] The point is 10
[Rail] You have 990.0 on the rail
# Put $20 odds on line bet
g.bet(LineOddsBet(20, g.puck))

# And place an additional come bet for the table minimum
g.bet(ComeBet(g.minimum_bet))
[Bet] You made a LineOddsBet on 10 for 20
[Rail] You have 970.0 on the rail
[Bet] You made a ComeBet on the box for 10.0
[Rail] You have 960.0 on the rail
# Roll!
g.roll()
[Table] The shooter is ready, the point is 10
[Table] PassBet for 10 is working on 10
[Table] LineOddsBet for 20 is working on 10
[Table] ComeBet for 10.0 is working on the box
[Roll] Shooter rolled 8
[Roll] 2+6=8 came easy
[Bet] ComeBet for 10.0 was moved to the 8
[Rail] You have 960.0 on the rail
# Check your bets
g.callout()
[Table] PassBet for 10 is working on 10
[Table] LineOddsBet for 20 is working on 10
[Table] ComeBet for 10.0 is working on 8
# Put $30 odds on your 8
g.bet(PointOddsBet(30, 8))
[Bet] You made a PointOddsBet on 8 for 30
[Rail] You have 930.0 on the rail
# Roll!
g.roll()
[Table] The shooter is ready, the point is 10
[Table] PassBet for 10 is working on 10
[Table] LineOddsBet for 20 is working on 10
[Table] ComeBet for 10.0 is working on 8
[Table] PointOddsBet for 30 is working on 8
[Roll] Shooter rolled 10
[Roll] Winner!!, 10
[Payout] PassBet on 10 paid out 20
[Payout] LineOddsBet on 10 paid out 60.0
[Rail] You have 1010.0 on the rail

(back to top)

Roadmap

  • Add Bet types to model.py
  • Strategy constructor / builder
    • Logic layer to facilitate strategy construction in a low code environment. For example:
      • IF the game puck is off AND I do not have a place bet, THEN make a place bet.
      • IF the game puck is on AND I do not have odds on a place or come bet, THEN put f(x) odds on it.

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Mike Hegarty - @mjhegarty - mike@petorca.com

Project Link: https://github.com/mhegarty/craps

Acknowledgments

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

craps-2.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

craps-2.0.0-py2.py3-none-any.whl (16.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file craps-2.0.0.tar.gz.

File metadata

  • Download URL: craps-2.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

File hashes

Hashes for craps-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a42bf47f8709992f501349a9284c5bedc99ba7cb63b07b4ca556d52654b61449
MD5 ec82fd98ff8d11a4a4c9d39cda397aeb
BLAKE2b-256 7285c473cc284e22537b72e7565b94c519d8212c57a9e1441139595b1a2139e4

See more details on using hashes here.

File details

Details for the file craps-2.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: craps-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

File hashes

Hashes for craps-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5cb7a999ed64b49cd4531e1b262d7f04d0651dd8cd0b7a6c4b438ecb5b25876a
MD5 cf460b53887b24b0bf1caff08b72725a
BLAKE2b-256 df177499624b9a37896ef71d8a27e6ec5f5fcb3c698a30c3c35b8db470f6129a

See more details on using hashes here.

Supported by

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