An easy-to-use, lightweight Python library for Quoridor
Project description
Quoridor logic in Python
Install
pip install pyquoridor
Usage
from pyquoridor.board import Board
from pyquoridor.utils import print_board
board = Board()
# Place fences
board.place_fence(row=0, col=0, orientation='h')
board.place_fence(row=7, col=0, orientation='h')
board.place_fence(row=3, col=2, orientation='v')
board.place_fence(row=1, col=0, orientation='v')
# Move pawn
board.move_pawn(player='white', target_row=1, target_col=4)
# Show board
print_board(board)
"""
··· ··· ··· ··· ··· ··· ··· ··· ···
8 : : : : : b : : : : :
---*--- ··· ··· ··· ··· ··· ··· ···
7 : : : : : : : : : :
··· ··· ··· ··· ··· ··· ··· ··· ···
6 : : : : : : : : : :
··· ··· ··· ··· ··· ··· ··· ··· ···
5 : : : : : : : : : :
··· ··· ··· ··· ··· ··· ··· ··· ···
4 : : : | : : : : : :
··· ··· ···*··· ··· ··· ··· ··· ···
3 : : : | : : : : : :
··· ··· ··· ··· ··· ··· ··· ··· ···
2 : | : : : : : : : :
···*··· ··· ··· ··· ··· ··· ··· ···
1 : | : : : w : : : : :
---*--- ··· ··· ··· ··· ··· ··· ···
0 : : : : : : : : : :
··· ··· ··· ··· ··· ··· ··· ··· ···
0 1 2 3 4 5 6 7 8
"""
Exceptions for invalid moves
The logic raises exceptions for:
- Invalid pawn moves, including out-of-board and illegal jumping events (
exceptions.InvalidMove) - Invalid fence placements, including out-of-board fences, overlapping fences, and fences that block unique pawn paths (
exceptions.InvalidFence) - Moves after game is over (
exceptions.GameOver)
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
pyquoridor-0.0.2.tar.gz
(10.2 kB
view details)
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 pyquoridor-0.0.2.tar.gz.
File metadata
- Download URL: pyquoridor-0.0.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8312139b535719c4615fb985dafc5407862638e669e600d7a7146aa9187d1ad3
|
|
| MD5 |
bc08ab8c6e8a61203e96ec52279382ba
|
|
| BLAKE2b-256 |
1fac4ad02edd1e30778d38b771a9ec54afd6924dc6f45f29ac0339658e0fbb39
|
File details
Details for the file pyquoridor-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyquoridor-0.0.2-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae2be7ee984afec8872e2146bed2b5c38342b46b003e92614eadd527039ae8c5
|
|
| MD5 |
fa1ab24c008a4df599d47552c6cb9a25
|
|
| BLAKE2b-256 |
5cf24630fd99957ad3059661b360d45bd73705d24ad3c0a8aaa6c73292a359fe
|