Backgammon engine for the Backgammon Network.
Project description
backgammon
Backgammon engine for the Backgammon Network <https://www.bkgmn.net>
_.
Installation
.. code-block:: bash
$ pip install backgammon
Getting Started
.. code-block:: pycon
>>> import backgammon
>>> b = backgammon.Backgammon("4OvgATDgc+QBUA", "cInpAAAAAAAA")
>>> print(b)
Position ID: 4OvgATDgc+QBUA
Match ID : cInpAAAAAAAA
+13-14-15-16-17-18------19-20-21-22-23-24-+
| X O O | | O X |
| X O | | O |
| X O | | O |
| X | | O |
| | | O |
v| |BAR| |
| | | X |
| O | | X |
| O X | | X |
| O X | | X O |
| O X X | X | X O |
+12-11-10--9--8--7-------6--5--4--3--2--1-+
>>> for play in b.generate_plays():
... print(play.moves)
... print(play.position)
...
(Move(pips=3, source=None, destination=22), Move(pips=2, source=13, destination=11))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 0, 0, 2, -4, 3, 0, 0, 0, -3, -1, -5, 0, 0, 1, 0, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=2, source=None, destination=23), Move(pips=3, source=24, destination=21))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 1, 0, 1, 0), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=3, source=None, destination=22), Move(pips=2, source=11, destination=9))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 1, 0, 0, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 1, 0, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=3, source=None, destination=22), Move(pips=2, source=22, destination=20))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 1, 0, 0, 0, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=2, source=None, destination=23), Move(pips=3, source=13, destination=10))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 0, 1, 1, -4, 3, 0, 0, 0, -3, -1, -5, 0, 0, 0, 1, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=2, source=None, destination=23), Move(pips=3, source=8, destination=5))
Position(board_points=(-2, 0, 0, 0, 1, 5, 0, 2, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 0, 1, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=3, source=None, destination=22), Move(pips=2, source=24, destination=22))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 3, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 2, 0, 0), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=3, source=None, destination=22), Move(pips=2, source=6, destination=4))
Position(board_points=(-2, 0, 0, 1, 0, 4, 0, 3, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 1, 0, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=2, source=None, destination=23), Move(pips=3, source=6, destination=3))
Position(board_points=(-2, 0, 1, 0, 0, 4, 0, 3, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 0, 1, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=2, source=None, destination=23), Move(pips=3, source=11, destination=8))
Position(board_points=(-2, 0, 0, 0, 0, 5, 0, 4, 0, 0, 0, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 0, 1, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
(Move(pips=3, source=None, destination=22), Move(pips=2, source=8, destination=6))
Position(board_points=(-2, 0, 0, 0, 0, 6, 0, 2, 0, 0, 1, -4, 4, 0, 0, 0, -3, -1, -5, 0, 0, 1, 0, 1), player_bar=0, player_off=1, opponent_bar=0, opponent_off=0)
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
backgammon-0.1.0.tar.gz
(8.0 kB
view hashes)
Built Distribution
backgammon-0.1.0-py3-none-any.whl
(14.8 kB
view hashes)
Close
Hashes for backgammon-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38c322e8b63e2cfc2120bf958b02adf7088ab2e0b98d22b4b3a3e43c908591b6 |
|
MD5 | 7f49daf40a16d3826e52c92e8d4a52f9 |
|
BLAKE2b-256 | 65f72efc9c2e5832e49859733185a0081a7a864bd0c0238443652ce300077926 |