Skip to main content

Training-oriented chess encoders, action spaces, and dataset utilities.

Project description

RookForge ML

rookforge-ml is a Python toolkit for building chess bot training pipelines. It provides training-friendly board encoders, an AlphaZero-style policy action space, PGN/FEN data helpers, and optional PyTorch integration without making PyTorch a required dependency.

The package is intentionally small in v1: it uses python-chess for rules correctness and focuses on reliable tensor interfaces that can feed neural networks and RL experiments.

Install

pip install rookforge-ml

For local development:

pip install -e ".[dev]"

For PyTorch helpers:

pip install -e ".[torch]"

Quick Start

import chess

from chess_tools.actions import legal_mask, move_to_index
from chess_tools.encoding import encode_board

board = chess.Board()
planes = encode_board(board)
mask = legal_mask(board)
policy_index = move_to_index(chess.Move.from_uci("e2e4"), board)

print(planes.shape)  # (106, 8, 8) by default
print(mask.shape)    # (4672,)
print(policy_index)

Core APIs

  • chess_tools.encoding: AlphaZero-style board and history encoders.
  • chess_tools.actions: 64 * 73 policy action encoding, legal masks, and UCI helpers.
  • chess_tools.data: PGN/FEN readers and streaming supervised samples.
  • chess_tools.torch: optional PyTorch dataset/collation utilities.

Development

python -m pip install -e ".[dev,benchmark]"
python -m ruff check .
python -m pytest
python -m pytest tests/test_benchmarks.py --benchmark-only --benchmark-min-rounds=5
python -m build
python -m twine check dist/*

The GitHub Actions workflow runs lint, tests, package build, metadata checks, and a benchmark smoke job.

Release

Revoke any token that was pasted into a terminal log or chat, then create a fresh PyPI API token. For token authentication, Twine must use __token__ as the username. The release script sets that for child Twine uploads when TWINE_PASSWORD starts with pypi-.

$env:TWINE_PASSWORD = "pypi-YOUR_NEW_API_TOKEN"

.\scripts\release.ps1 -Part patch -Upload

Useful variants:

.\scripts\release.ps1 -DryRun
.\scripts\release.ps1 -Version 0.2.0 -Upload
.\scripts\release.ps1 -Part patch -Upload -Repository testpypi
.\scripts\release.ps1 -Part patch -Upload -RunBenchmarks

If PyPI returns 400 Bad Request, the script runs Twine with --verbose so the server response should include the actual reason. Common causes are a version that was already uploaded, a package name that PyPI considers too similar to an existing project, or invalid metadata that Twine did not catch locally.

The PyPI distribution name is rookforge-ml; the Python import package remains chess_tools.

Design Notes

  • Board planes are encoded from the side-to-move perspective.
  • Current position planes come first, then older history planes.
  • The policy action space uses 56 queen-like moves, 8 knight moves, and 9 underpromotion moves per origin square.
  • python-chess remains the source of truth for legal move generation and game rules.

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

rookforge_ml-0.1.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

rookforge_ml-0.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file rookforge_ml-0.1.1.tar.gz.

File metadata

  • Download URL: rookforge_ml-0.1.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for rookforge_ml-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1533878d10bca25a5ea1e59ba5cd5639612c2c3e471295a8905054e4e7c1668b
MD5 b4ba887cb7c03f33eb6d0d56398df665
BLAKE2b-256 046f3810ec6dc0cc755383e28d23310b5da2e85530627f14a56a55e1b88b7bc5

See more details on using hashes here.

File details

Details for the file rookforge_ml-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rookforge_ml-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for rookforge_ml-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16844b5c908c9deb922dbfef4e40b8bdff3e1d63d8679e2912ba1ecfb1a3f7f3
MD5 cd7331db293aaed5c4b5087c725ae116
BLAKE2b-256 517271636a1869867d8ceff1284392f08b72073f4d04efcad0dcfdc896d4cf0d

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