Skip to main content

High-performance Python chess library in C: legal move generation, SAN/UCI parsing, and NumPy tensor export

Project description

fastchess

A high-performance chess library written in C with Python bindings. Designed as a fast drop-in replacement for python-chess in data pipelines and machine learning workflows.

Installation

pip install fastchess

Requires a C compiler and NumPy. On most systems pip will handle this automatically.

Usage

import fastchess

board = fastchess.Board()                  # start position
board = fastchess.Board("rnbqkbnr/...")    # from FEN

# Move generation
moves = board.legal_moves_uci()           # ['e2e4', 'd2d4', ...]

# Apply moves
board.push_uci("e2e4")
board.push_san("e5")

# Board state
print(board.fen())
print(board.turn)                         # fastchess.WHITE or fastchess.BLACK
print(board.is_check())

# Tensor for ML (18 x 8 x 8 numpy array)
tensor = board.to_tensor(canonical=True)

# Mirroring
mirrored = board.mirror()

API

fastchess.Board(fen=None)

Method Description
copy() Return a copy of the board
mirror() Return a vertically mirrored copy with swapped colors
push_uci(uci) Apply a UCI move (e.g. "e2e4")
push_san(san) Apply a SAN move; returns the UCI string
legal_moves_uci() List all legal moves as UCI strings
piece_at(sq) (piece_type, color) at square index, or None
is_check() True if the side to move is in check
has_kingside_castling_rights(color) Castling rights query
has_queenside_castling_rights(color) Castling rights query
has_legal_en_passant() True if a legal en passant capture exists
to_tensor(canonical=False) Board as (18, 8, 8) numpy array
fen() Current FEN string

Constants

WHITE, BLACK, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING

License

MIT

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

fastchess-0.1.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distributions

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

fastchess-0.1.2-cp312-cp312-win_amd64.whl (17.9 kB view details)

Uploaded CPython 3.12Windows x86-64

fastchess-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (16.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fastchess-0.1.2-cp311-cp311-win_amd64.whl (17.9 kB view details)

Uploaded CPython 3.11Windows x86-64

fastchess-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (16.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fastchess-0.1.2-cp310-cp310-win_amd64.whl (17.9 kB view details)

Uploaded CPython 3.10Windows x86-64

fastchess-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (16.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

fastchess-0.1.2-cp39-cp39-win_amd64.whl (17.9 kB view details)

Uploaded CPython 3.9Windows x86-64

fastchess-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (16.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file fastchess-0.1.2.tar.gz.

File metadata

  • Download URL: fastchess-0.1.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastchess-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d7a3dd3efc92441196cddf07add38b3811fd7420436b493a3ffcdb45479e1657
MD5 013930490c14d2c97ac66e89eaa362c5
BLAKE2b-256 05d47681608c90150ba6ef366228d1c01f38cca0f06a00250a06416b3a76e87d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2.tar.gz:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fastchess-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastchess-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 19d4f37309accf87f9ffd7df009c4ba2c6cdaf82f21cea134d9ce831f67423c1
MD5 47f9eb3bdef95619b923cddfad940c09
BLAKE2b-256 d7419f1b47e1f2c51e5796f14f0ba12be0d401de0564672d6d3178da4f3fc7f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a0990650d50a7f24da5f1919800159685f19a4ced4b637bd74b94ea6df6e7ed
MD5 cd0d9562d25f7f71d0e4058b85724404
BLAKE2b-256 30a67d8c22d56f35cb80d2a0d1022e8c34f503629d6a25f0b289c61ef4d97511

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fastchess-0.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastchess-0.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3f5b07c59c51f265c920ba22ff0953fff5334fdaf2ccdf72d318543c0aeb7f6f
MD5 bb6b526a24c46d1413e747a4386672aa
BLAKE2b-256 5514eda40334763f6ff0b2791039f314b04a96bced0d3e9b894a3cb10f774e6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37cbc0ef85f734959f13f253b43aed508a769635208d9c978136c2f6f7e72530
MD5 def20c3585e80d4e1b221a83140eba84
BLAKE2b-256 a728d0b65e71d2b8804cfc2c062362d521f2ecda2a495c4a513562821cf401c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fastchess-0.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastchess-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6b93f997359dcc3d5a8a0a3933aa8d9a6fcda482bd1ffdb950f02cd377861d27
MD5 9134c56f2605a197da301e474a206fc8
BLAKE2b-256 9564890efbffae0938fee6963be2a882470339e141e718eb9ab4a102e97e087e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9dd2f06226ab1c3431e39fb4b41911926fed2790b5776ee65abc37f4c4298be
MD5 060ef2af8ba73b202a48e1b5b9210d32
BLAKE2b-256 e95acd19a4573222a1bbf1e155746558d0474d7fcee83d083770e7149b1454c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fastchess-0.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastchess-0.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c6b66b445508dde5d02066623c482b5b3763bb44773005a2fd506f912c47bc9c
MD5 54e1b523f226c0fd8d90cc38b3b3d168
BLAKE2b-256 8488cc40045370fcf3d48de262681f7969108f64110667ca21bb4842e7e1ad01

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp39-cp39-win_amd64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastchess-0.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e42aa1b1c8d009b7ba285055d26fe629006b03cbfa2ed888c1e7c1d640b9529c
MD5 c691c7edd20d755c37b4a3eefe2dcf9a
BLAKE2b-256 5a72929a4a90a3bf0d84d5e032193425ac59d64504f0d8a5580a7d485a6c9ffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastchess-0.1.2-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: publish.yml on PeargentLabs/fastchess

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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