Skip to main content

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.5.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyquoridor-0.0.5-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file pyquoridor-0.0.5.tar.gz.

File metadata

  • Download URL: pyquoridor-0.0.5.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for pyquoridor-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1d61aa6067a871453bca0400cd132d0c1091165637f8067a0bb936be04515f7a
MD5 480e16203a900484da1c31c3d5d16db0
BLAKE2b-256 1769fd0f647fa9b634fda59f06a91392b90158faa65962f41f925059277eb7dd

See more details on using hashes here.

File details

Details for the file pyquoridor-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pyquoridor-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for pyquoridor-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f2006f532358374a4cc19c25bb18b4f50a9a6a8b883ad73c5da9d7679a03a926
MD5 5f9c33784c93ab5a2c1af41787016cba
BLAKE2b-256 baa68d0567670a316f5a70c68ca997bbf3e60a839e90b419e4218721b249cfe4

See more details on using hashes here.

Supported by

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