Backgammon engine core
pygammon is the base of a backgammon engine, written in Python. It provides the core functionality for running a game, given a source of input (player moves) and a destination for output (game state/events).
Installation
The following Python versions are supported:
CPython: 3.8, 3.9, 3.10, 3.11, 3.12
PyPy: 3.8
Install via pip:
$ pip install pygammon
Usage
To build a complete game, you have to provide a function for getting each side’s moves (input), and a function for informing each side about the game state and events (output):
from typing import Optional, Tuple, Union
from pygammon import GameState, InputType, InvalidMoveCode, OutputType, Side, run
def receive_input(side: Side) -> Tuple[InputType, Optional[Tuple[int, Optional[int]]]]:
# Return move of given side
...
def send_output(
output_type: OutputType,
data: Union[GameState, Tuple[int, int], InvalidMoveCode, Side],
side: Optional[Side] = None,
) -> None:
# Show output to given side
...
run(receive_input, send_output)
The input function could send to the game, moves made in any way (calculated by AI, read from stdin, selected from GUI, either locally or through network). Similarly, the output function could do anything with the info it gets from the game (inform AI tactics, write to stdout, show to GUI, either locally or through network).
For more details, see the protocol.
License
Distributed under the MIT License.
Release files for pygammon 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygammon-0.0.3.tar.gz | 17.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygammon-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / pygammon-0.0.3.tar.gz
| Download URL | pygammon-0.0.3.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91f7ed50d4b9fd3c486ddcc9db35cf3624d17960709d6b346130a29d808677bb
|
|
BLAKE2b-256 checksum How to use checksums |
d838a7dae4e6dc91e46f6675e9df99b9204af3e254e549d0bce095c6a17f2248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / pygammon-0.0.3-py3-none-any.whl
| Download URL | pygammon-0.0.3-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59362dacc95bc38fb7cff803a7ea3a2e8c0c2037c5d56695e5f82935182fedd8
|
|
BLAKE2b-256 checksum How to use checksums |
cd4574f7710ac0dafdac252c0da4028b8f041c95fcca373a1cc8ee55955fe3de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|