Skip to main content

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.

Build Status

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


Download files

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

Files for bobail, version 1.4.2
Filename, size File type Python version Upload date Hashes
Filename, size bobail-1.4.2.tar.gz (7.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page