Skip to main content

esca

crates.io docs.rs PyPI Python CI MIT

A chess model that answers what is true about a position — a Rust crate and a Python package built from it.

The esca is the anglerfish's lure: the small thing that lights up what is in front of it.

Position is placement and state and nothing else. Rules live in Variant implementations — Classic and Chess960 — so a position can be asked the same question under different rules, and a new variant is a new implementation and nothing else. A Game pairs a variant with the moves played, which is what repetition and claimable draws need. Facts answers what is true about a position, both as prose a reader can check and as the flat f32 row a net consumes.

Rust

[dependencies]
esca = "0.1"
use esca::{Game, Schema, Side, classic};

let mut game = Game::new(classic());   // Chess960 rules: `esca::chess960()`
game.play_san("e4").unwrap();
game.play_uci("e7e5").unwrap();
println!("{}", game.position().fen());

let facts = game.facts();              // side-relative, in the mover's view
println!("{}", facts.tactics[Side::Us.index()].legal_move_count);
println!("{}", facts.summary());

let schema = Schema::v1();             // the row a net eats: 2039 f32
println!("{}", facts.encode(schema, schema.all()).len());

Cargo features, none on by default: lichess (streaming reader for the Lichess evaluation dump), pgn (reading and writing games as PGN), polyglot (opening books), openings (the bundled ECO catalogue) and python (the PyO3 module the wheel is built from). Position::polyglot_key needs no feature.

Python

pip install esca
import esca

game = esca.Game()  # Chess960 rules: esca.Game(variant=esca.CHESS960)
game.play_san("e4")
game.play("e7e5")
print(game.position.fen)

facts = game.facts()  # side-relative: index with esca.US / esca.THEM
print(facts.tactics[esca.US].legal_move_count)
print(facts.summary())

rows = esca.encode([game.position.fen])  # (1, 2039) float32, ready for a net
print(rows.shape, esca.SCHEMA_ID)

Wheels are abi3 for Python 3.12 and up. esca.lichess.batches() streams the evaluation dump as encoded batches with their targets.

What it covers

  • Classic chess and Chess960, behind one Variant trait.
  • FEN and EPD, reading KQkq and the AHah of X-FEN and Shredder-FEN alike, and writing KQkq whenever the rook files allow it.
  • Legal move generation into a MoveList that never allocates.
  • UCI move text in either castling spelling, and SAN with the disambiguation it needs.
  • Checkmate, stalemate, insufficient material, the fifty- and seventy-five-move rules, and threefold and fivefold repetition.
  • Facts: fourteen groups of cheap position facts — the board itself, game state, material, pawns, pieces, king, mobility, attacks, exchanges, threats, one-ply tactics, endgame, history and attack planes — plus MoveFacts for every legal move, all side-relative and in the mover's view.
  • Schema, a versioned manifest with a schema_id, and batch encoders that write f32 rows without allocating.
  • Polyglot opening books: the format's own key on every Position, books read, drawn from and built, and an ECO code and name for some 3,800 named positions.

Documentation

License

MIT — see LICENSE.

Acknowledgements

  • cozy-chess (MIT) — the move generator esca stands on.
  • Lichess — the evaluation dump the trainer learns from, the game database, and lichess-org/chess-openings, whose opening names the openings feature bundles (CC0 1.0 Universal Public Domain Dedication).
  • The Polyglot opening-book format and its key scheme, by Fabien Letouzey; the key constants are those published in polyglot-book-rs (MIT OR Apache-2.0).
  • Stockfish and Leela Chess Zero, the engines the UCI client is tested against.

Download files

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

Source Distribution

esca-0.3.0.tar.gz (533.4 kB view details)

Uploaded Source

Built Distributions

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

esca-0.3.0-cp312-abi3-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12+Windows x86-64

esca-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

esca-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

esca-0.3.0-cp312-abi3-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

esca-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file esca-0.3.0.tar.gz.

File metadata

  • Download URL: esca-0.3.0.tar.gz
  • Upload date:
  • Size: 533.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for esca-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b504d340c3d8e24f5d7d0f7f65d57565141447fa7a01a9473270f24f61e5c436
MD5 e5f2e97935b91724893b53d3ba7390a7
BLAKE2b-256 64043b7847dbf262a07e40c51b408c20d6c618bbb117fd57326ccf9efc0d63a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0.tar.gz:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

File details

Details for the file esca-0.3.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: esca-0.3.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for esca-0.3.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9caaf8ea4649d9a1b482e646cb35a855de20102182e47daac89ac9b34e761916
MD5 09354ef317bf3c0933f30ee8c5dbcb2c
BLAKE2b-256 a330d8443b3a05e27e568dd2abac59d03d1a931a8e48b227a0b1a734f846a4eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0-cp312-abi3-win_amd64.whl:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

File details

Details for the file esca-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for esca-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c00f203f40f27943cf3dce37d983c78d93e6ea5e5df7b91f9cf105a8f19151a
MD5 cff9625206a9d07a9d4dda8620792f96
BLAKE2b-256 4c7a5a52d6556d16760017213abd0a5b87aa2c6ccfbb136243c5d3a76034fd75

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

File details

Details for the file esca-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for esca-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 598fde0423fa98062f6d8cd17bf27f49781cf647e051e068f0d9dd7332a41025
MD5 112486e37356fa5b09ef18d51ff0385d
BLAKE2b-256 8570b258f06e87fef2d5c39453e16fa656da8c8fbfb91c8d4ea1c51406ae170c

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

File details

Details for the file esca-0.3.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: esca-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for esca-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a518855be3443da7c1cc39775bce66d65b845ca87af0c50a9ede4e46afe72f4c
MD5 5f8ff492d29c4485d9fd2e4c046004f0
BLAKE2b-256 ee17ad1e1f131634d73c25453d410f0334e830261650c9b600756d41ae947ab6

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

File details

Details for the file esca-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for esca-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1d2732e30a5b05e6c5be01b75cca76bcd5d03174f161aafc54c41e4a877ad9dc
MD5 e346d6be8dc8948a66b9d09b7d774078
BLAKE2b-256 9ace2d44b12002d39b04d82bf00103d6b5a1c5b3e8b2ab136bcf487e58b2bac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for esca-0.3.0-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on AnglerfishChess/anglerfish

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

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 files

0.2.1

6 files

0.2.0

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page