/PyChess

A simple python chess wrapper for the stockfish engine

Primary LanguagePythonMIT LicenseMIT

PythonChess

size licence python version os support

A pygame wrapper for the stockfish chess engine. For more details, check their GitHub repository. The wrapper is based on the python package stockfish. The view is developped using my pygame-toolkit, helping to create gui-like views in pygame.

Cloning

Stockfish is not cloned as a submodule, clone it as follows:

git clone https://github.com/Hardcode3/PyChess.git

The content of the repository corresponding to the official realease is located under the chess/external/stockfish path. Consider checking their website.

Launching the app

To run the app, create a virtual environment or pip install the requirements.

To create and activate a virtual environment on UNIX like systems

python3 -m venv venv
source venv/bin/activate

To create and activate a virtual environment on Windows systems

python3 -m venv venv
.\venv\Scripts\activate

To install the dependencies

pip install -r requirements.txt

If the requirements.txt installation process fails, then try to install pygame in the virtual environment using the last dev version by manually typing: The version used in the requirements file is indeed not compatible with python 3.11, but the dev version fixes the problem.

pip install pygame --pre

After this step, pip should have installed the dependencies and you should be able to launch the main program using:

python3 main.py

Note that the main.py file handles the compilation of the Stockfish code for UNIX systems. For windows systems, it downloads the latest binaries and extract it. If a stockfish executable is found, skips the compilation process, otherwise compiles and download necessary files using the included Makefile. The game launches automatically after the process is done.

Compatibility

This version is compatible with UNIX systems and now with Windows ones. Just launch the main file and python does it for you. Stockfish for python uses the compiled executable file available in chess/external/src/ as stockfish).

Screenshots

Main menu The game itself