The fastest client for the Stockfish chess engine using C++ extension.
Project description
Native Stockfish Python Client
Native Stockfish is a minimal-overhead Python interface to the Stockfish chess engine. Stockfish runs as a native process, with all UCI communication handled in C to avoid Python becoming a performance bottleneck.
Prerequisites
- Python 3.8+
- A compiled Stockfish binary. You can compile Stockfish from the official source or use the submodule included in this repository.
Compiling Stockfish
If you have the Stockfish submodule checked out:
cd Stockfish/src
make -j profile-build
Or you can use use the binray from the website.
Installation
From Source
pip install .
Usage
See examples/basic_usage.py for a complete example.
import native_stockfish
# Path to your compiled Stockfish binary
stockfish_path = "./Stockfish/src/stockfish"
client = native_stockfish.StockfishClient(stockfish_path)
client.start()
# Analyze a position (FEN string)
# top_moves(fen, depth, count)
moves = client.top_moves("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 15, 3)
print(moves)
client.stop()
API
StockfishClient(path)
Initializes the client with the path to the Stockfish executable.
client.start()
Starts the Stockfish engine process.
client.status()
Returns the status of the engine (e.g., "running", "stopped").
client.top_moves(fen, depth, count)
Analyzes the given FEN position.
fen: The FEN string of the position to analyze.depth: The search depth.count: The number of top moves to return.
Returns a list of top moves.
client.stop()
Stops the Stockfish engine process.
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
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 native_stockfish-0.1.0.tar.gz.
File metadata
- Download URL: native_stockfish-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ab2b8e5211ade0f8b171bafde8f61175676aab05e6b30af910413964ca045af
|
|
| MD5 |
ba61aa85c5146e648b5fe68fb94f5664
|
|
| BLAKE2b-256 |
b6faba6c77b6455e0831ac16c70e4dc9b2efb73003dd7891c73f04b664cefc7f
|
File details
Details for the file native_stockfish-0.1.0-cp314-cp314-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: native_stockfish-0.1.0-cp314-cp314-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 78.7 kB
- Tags: CPython 3.14, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04479c10d3e1e4126f134798f333934996b6825e69098d0620dbce14b7571cf6
|
|
| MD5 |
6e0da6418106452402cb137d029babfe
|
|
| BLAKE2b-256 |
21c26e4ba5828b3c2040d891e601bae9c1fa355d7b8936b2d7c55dc0c68387a4
|