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
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 Distributions
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 fastchess-0.1.1.tar.gz.
File metadata
- Download URL: fastchess-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0951950acb2c35ee4cb164913bb4e4b65960878189da62e2ff814df3659e771d
|
|
| MD5 |
c8a13e084b9942424223675575788975
|
|
| BLAKE2b-256 |
7e6fb44aebc15b3c200dd90f7e1816b296dd86b266a52c55763c5e04d7caedc0
|
Provenance
The following attestation bundles were made for fastchess-0.1.1.tar.gz:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1.tar.gz -
Subject digest:
0951950acb2c35ee4cb164913bb4e4b65960878189da62e2ff814df3659e771d - Sigstore transparency entry: 1668550216
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fastchess-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
153e6ec99b65fb3ee54feb6c36529cb2cac3cceeff2d1a25239d8c2ef4d41323
|
|
| MD5 |
b2550f86fc5370f1b60ebcd69ffe6f29
|
|
| BLAKE2b-256 |
be3c90102e6f40569f7bf91df0c00eb6cacabae956962b1b2efc0838ff42eb92
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp312-cp312-win_amd64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp312-cp312-win_amd64.whl -
Subject digest:
153e6ec99b65fb3ee54feb6c36529cb2cac3cceeff2d1a25239d8c2ef4d41323 - Sigstore transparency entry: 1668550478
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 16.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33145f1a72367ff5a07db311e170dc2851ca3b53ea232fa21fc89bffbdd2a3cc
|
|
| MD5 |
9b5b36ac10afbc32b6ff5b08e0e50ee8
|
|
| BLAKE2b-256 |
a216fa7ce5eeabe645286f2c96f0ad43ded217e32ec8e56dad49f5cda38fb3aa
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
33145f1a72367ff5a07db311e170dc2851ca3b53ea232fa21fc89bffbdd2a3cc - Sigstore transparency entry: 1668550896
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: fastchess-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
405715f9d40ba4226217e3b4710b68a4768166c7e2da401b7e8bc41b46043b56
|
|
| MD5 |
747822596ae40d03388a6ed2d0ef08c5
|
|
| BLAKE2b-256 |
2237e9f61debda002a829774142b94e03f1a19fd685ac0332a6b727bfd1664a8
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp311-cp311-win_amd64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp311-cp311-win_amd64.whl -
Subject digest:
405715f9d40ba4226217e3b4710b68a4768166c7e2da401b7e8bc41b46043b56 - Sigstore transparency entry: 1668551595
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 16.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96113ee24d18d0a7384fc0ddaad027b260f1ff514ac77422ab621559281a73b6
|
|
| MD5 |
59a4e90831bfabe96be318c4c9ff7620
|
|
| BLAKE2b-256 |
c88ca25f035cc4a5c64e07f9593df79347fac7912f637983395cfc99333b9ff2
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
96113ee24d18d0a7384fc0ddaad027b260f1ff514ac77422ab621559281a73b6 - Sigstore transparency entry: 1668551388
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: fastchess-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b917721ec897eb308b01a2bac4286ccbce1b23e0d47a638e1a17298eb28f327
|
|
| MD5 |
ae0816cc03f77358bce6ee5d15283e4b
|
|
| BLAKE2b-256 |
4264bd329c63af9b5a32ff43236e9451c920534f4cb267d55e4be566a55d0322
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp310-cp310-win_amd64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp310-cp310-win_amd64.whl -
Subject digest:
5b917721ec897eb308b01a2bac4286ccbce1b23e0d47a638e1a17298eb28f327 - Sigstore transparency entry: 1668550343
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 16.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52fbbc16a0dd3be1fad3ae13cba9e4abae26111067f747912f879625c4aa0cdb
|
|
| MD5 |
ebc66b11e0b35da2d9b7989061e4c686
|
|
| BLAKE2b-256 |
e0f8989c2fc556fbc8bf99b08ef24c63ac0e822ab7f74db9e40d076a0182ed88
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
52fbbc16a0dd3be1fad3ae13cba9e4abae26111067f747912f879625c4aa0cdb - Sigstore transparency entry: 1668551176
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: fastchess-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9e67775126d8feb9ad4a228fe09527efbf2ba1ffdac11c41a70b2c9561bcf19
|
|
| MD5 |
c3d67d9890125fa057119860c60638e0
|
|
| BLAKE2b-256 |
16fa6fad974c5e00f81bd5fc0ccb106811d82a7d073e260605e7a539697383e6
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp39-cp39-win_amd64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp39-cp39-win_amd64.whl -
Subject digest:
d9e67775126d8feb9ad4a228fe09527efbf2ba1ffdac11c41a70b2c9561bcf19 - Sigstore transparency entry: 1668551025
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 16.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ba01132bcf683cc72069c7d4dce43ae624e28adbafd6464f570b6c896152fd4
|
|
| MD5 |
8ff54076adc723d90e8508b15531baf7
|
|
| BLAKE2b-256 |
736f7a63c4e295bbcfdffc97f4f15201d66ad39c656fe4376fe9ccf75590057f
|
Provenance
The following attestation bundles were made for fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl:
Publisher:
publish.yml on Peargent-Labs/fastchess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl -
Subject digest:
8ba01132bcf683cc72069c7d4dce43ae624e28adbafd6464f570b6c896152fd4 - Sigstore transparency entry: 1668550721
- Sigstore integration time:
-
Permalink:
Peargent-Labs/fastchess@459a66680320edc874a11904fa085cf168e3c679 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Peargent-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@459a66680320edc874a11904fa085cf168e3c679 -
Trigger Event:
push
-
Statement type: