pyhtzee
Yahtzee game engine supporting regular Yahtzee rules (maximum 1480), Joker rules (maximum 1575) and Yatzy aka. Scandinavian Yahtzee rules (maximum 305). Example code:
from pyhtzee import Pyhtzee
from pyhtzee.classes import Category, Rule
from pyhtzee.utils import category_to_action_map, dice_roll_to_action_map
pyhtzee = Pyhtzee(rule=Rule.FREE_CHOICE_JOKER)
print(pyhtzee.dice)
This shows the dice:
[2, 5, 6, 1, 6]
Next reroll dice 1, 2 and 5:
action = dice_roll_to_action_map[(True, True, False, False, True)]
pyhtzee.take_action(action)
print(pyhtzee.dice)
Now we have two pairs:
[4, 6, 6, 1, 1]
Let's reroll just the first die to see if we can get a full house:
action = dice_roll_to_action_map[(True, False, False, False, False)]
pyhtzee.take_action(action)
print(pyhtzee.dice)
Bingo!
[6, 6, 6, 1, 1]
Now let's choose the action for full house and check the scorecard:
action = category_to_action_map[Category.FULL_HOUSE]
reward = pyhtzee.take_action(action)
print(f'Reward: {reward}, Scorecard: {pyhtzee.scores}')
This shows that we got a reward of 25, which can be confirmed in the scorecard:
Reward: 25, Scorecard: {<Category.FULL_HOUSE: 8>: 25}
Developers guide
Pipenv is recommended for setting up a development environment. Prior to installing
pipenv, creating a .env file with the following contents is recommended:
PYTHONPATH=.
To install pipenv and the required dependencies run the following commands:
pip install pipenv
pipenv install -r requirements.txt
pipenv shell
Updating dependencies
requirements.txt is dynamically generated using pip-compile. To regenerate the
requirements.txtfile run the following command:
pip-compile -U --output-file requirements.txt setup.py requirements-dev.in
Pre-commit hooks
This project uses Git pre-commit hooks courtesy of pre-commit. To install run the following:
pre-commit install
Metadata
Release files for pyhtzee 1.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyhtzee-1.2.7.tar.gz | 6.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyhtzee-1.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / pyhtzee-1.2.7.tar.gz
| Download URL | pyhtzee-1.2.7.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1f034c64e990778c470d05b3d2c225daada317e30b21ca03bf0f1d866aa9481
|
|
BLAKE2b-256 checksum How to use checksums |
f841590eb6a4b8381e92103d8d5d8af87b08f17bc0e88741f0d3cf32d2f2f60a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
|
Release files / pyhtzee-1.2.7-py3-none-any.whl
| Download URL | pyhtzee-1.2.7-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23ccfd363c82bd7081ee291f3a75889e4c52a42fc51af2a7033840e2c89088d5
|
|
BLAKE2b-256 checksum How to use checksums |
83d4b3883ee193e6b9e8b7051022bb761ff4a9c23a8e4648f320766765911bb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
|
Security for pyhtzee 1.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.