Skip to main content

Backgammon engine core

Project description

Backgammon engine core

PyPI PyPI - License PyPI - Python Version Coverage CircleCI Documentation Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygammon-0.0.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

pygammon-0.0.3-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

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

Hashes for pygammon-0.0.3.tar.gz
Algorithm Hash digest
SHA256 91f7ed50d4b9fd3c486ddcc9db35cf3624d17960709d6b346130a29d808677bb
MD5 048850b35fd090d191b5fa1de15a09c9
BLAKE2b-256 d838a7dae4e6dc91e46f6675e9df99b9204af3e254e549d0bce095c6a17f2248

See more details on using hashes here.

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

Hashes for pygammon-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 59362dacc95bc38fb7cff803a7ea3a2e8c0c2037c5d56695e5f82935182fedd8
MD5 50c79e50fb841356a0e168a6400641e9
BLAKE2b-256 cd4574f7710ac0dafdac252c0da4028b8f041c95fcca373a1cc8ee55955fe3de

See more details on using hashes here.

Supported by

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