Library for playing a standard game of bobail
Project description
A Python3 library that you can use to play a game of bobail. This is just a set of classes that you can use in your code, it's not an interactive shell for the game.
Assumptions
The rules used are from BoardGameAreana (http://en.doc.boardgamearena.com/Gamehelpbobail). This means an 5x5 board.
Each position on the board is numbered 1 to 25. Each move is represented as an array with two values: starting position and ending position. So if you're starting a new game, one of the available moves is [22, 7]
for player 1.
Each turn (other than the first) will be a series of two moves. First moving the Bobail then a player token.
Usage
Create a new game:
from bobail.game import Game
game = Game()
See whose turn it is:
game.whose_turn() #1 or 2
Get the possible moves:
game.get_possible_moves() #[[9, 13], [9, 14], [10, 14], [10, 15], [11, 15], [11, 16], [12, 16]]
Make a move:
game.move([9, 13])
Check if the game is over:
game.is_over() #True or False
Find out who won:
game.get_winner() #None or 1 or 2
Review the move history:
game.moves #[[int, int], [int, int], ...]
Review the pieces on the board:
for piece in game.board.pieces:
piece.player #1 or 2
piece.other_player #1 or 2
piece.bobail #True or False
piece.captured #True or False
piece.position #1-25
piece.get_possible_moves() #[[int, int], [int, int], ...]
Testing
Run python3 -m unittest discover
from the root.
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
File details
Details for the file bobail-1.4.2.tar.gz
.
File metadata
- Download URL: bobail-1.4.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f4053a1010096cdc992b1fcdc093c6a67cada0e7219d725f881858fbd6a9800 |
|
MD5 | 22d977468d5348b1886a41a315a9dac2 |
|
BLAKE2b-256 | d13c4d7119f1c0cbda23f8ceb4cffe38e2865cb803d0b8f87679f6ae927718fa |