Skip to main content

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


Download files

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

Source Distribution

native_stockfish-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

native_stockfish-0.1.0-cp314-cp314-manylinux_2_38_x86_64.whl (78.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

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

Hashes for native_stockfish-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ab2b8e5211ade0f8b171bafde8f61175676aab05e6b30af910413964ca045af
MD5 ba61aa85c5146e648b5fe68fb94f5664
BLAKE2b-256 b6faba6c77b6455e0831ac16c70e4dc9b2efb73003dd7891c73f04b664cefc7f

See more details on using hashes here.

File details

Details for the file native_stockfish-0.1.0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for native_stockfish-0.1.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 04479c10d3e1e4126f134798f333934996b6825e69098d0620dbce14b7571cf6
MD5 6e0da6418106452402cb137d029babfe
BLAKE2b-256 21c26e4ba5828b3c2040d891e601bae9c1fa355d7b8936b2d7c55dc0c68387a4

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