Backgammon engine core
Project description
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.
Project details
Release history Release notifications | RSS feed
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 pygammon-0.0.3.tar.gz.
File metadata
- Download URL: pygammon-0.0.3.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91f7ed50d4b9fd3c486ddcc9db35cf3624d17960709d6b346130a29d808677bb
|
|
| MD5 |
048850b35fd090d191b5fa1de15a09c9
|
|
| BLAKE2b-256 |
d838a7dae4e6dc91e46f6675e9df99b9204af3e254e549d0bce095c6a17f2248
|
File details
Details for the file pygammon-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pygammon-0.0.3-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59362dacc95bc38fb7cff803a7ea3a2e8c0c2037c5d56695e5f82935182fedd8
|
|
| MD5 |
50c79e50fb841356a0e168a6400641e9
|
|
| BLAKE2b-256 |
cd4574f7710ac0dafdac252c0da4028b8f041c95fcca373a1cc8ee55955fe3de
|