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.1.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.1-cp312-cp312-win_amd64.whl (17.9 kB view details)

Uploaded CPython 3.12Windows x86-64

fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (16.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (16.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (16.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (16.4 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Hashes for fastchess-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0951950acb2c35ee4cb164913bb4e4b65960878189da62e2ff814df3659e771d
MD5 c8a13e084b9942424223675575788975
BLAKE2b-256 7e6fb44aebc15b3c200dd90f7e1816b296dd86b266a52c55763c5e04d7caedc0

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on Peargent-Labs/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.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

Hashes for fastchess-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 153e6ec99b65fb3ee54feb6c36529cb2cac3cceeff2d1a25239d8c2ef4d41323
MD5 b2550f86fc5370f1b60ebcd69ffe6f29
BLAKE2b-256 be3c90102e6f40569f7bf91df0c00eb6cacabae956962b1b2efc0838ff42eb92

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on Peargent-Labs/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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33145f1a72367ff5a07db311e170dc2851ca3b53ea232fa21fc89bffbdd2a3cc
MD5 9b5b36ac10afbc32b6ff5b08e0e50ee8
BLAKE2b-256 a216fa7ce5eeabe645286f2c96f0ad43ded217e32ec8e56dad49f5cda38fb3aa

See more details on using hashes here.

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

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.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

Hashes for fastchess-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 405715f9d40ba4226217e3b4710b68a4768166c7e2da401b7e8bc41b46043b56
MD5 747822596ae40d03388a6ed2d0ef08c5
BLAKE2b-256 2237e9f61debda002a829774142b94e03f1a19fd685ac0332a6b727bfd1664a8

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on Peargent-Labs/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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 96113ee24d18d0a7384fc0ddaad027b260f1ff514ac77422ab621559281a73b6
MD5 59a4e90831bfabe96be318c4c9ff7620
BLAKE2b-256 c88ca25f035cc4a5c64e07f9593df79347fac7912f637983395cfc99333b9ff2

See more details on using hashes here.

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

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.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

Hashes for fastchess-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5b917721ec897eb308b01a2bac4286ccbce1b23e0d47a638e1a17298eb28f327
MD5 ae0816cc03f77358bce6ee5d15283e4b
BLAKE2b-256 4264bd329c63af9b5a32ff43236e9451c920534f4cb267d55e4be566a55d0322

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on Peargent-Labs/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.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52fbbc16a0dd3be1fad3ae13cba9e4abae26111067f747912f879625c4aa0cdb
MD5 ebc66b11e0b35da2d9b7989061e4c686
BLAKE2b-256 e0f8989c2fc556fbc8bf99b08ef24c63ac0e822ab7f74db9e40d076a0182ed88

See more details on using hashes here.

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

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.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

Hashes for fastchess-0.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d9e67775126d8feb9ad4a228fe09527efbf2ba1ffdac11c41a70b2c9561bcf19
MD5 c3d67d9890125fa057119860c60638e0
BLAKE2b-256 16fa6fad974c5e00f81bd5fc0ccb106811d82a7d073e260605e7a539697383e6

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on Peargent-Labs/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.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastchess-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ba01132bcf683cc72069c7d4dce43ae624e28adbafd6464f570b6c896152fd4
MD5 8ff54076adc723d90e8508b15531baf7
BLAKE2b-256 736f7a63c4e295bbcfdffc97f4f15201d66ad39c656fe4376fe9ccf75590057f

See more details on using hashes here.

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

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