valanga
Shared Python types and lightweight utilities for describing turn-based games and their evaluations. The package exposes protocols for representing states, outcomes, and state representations that other libraries can build on.
Release 0.3.0
This release requires Python 3.14 and includes native generic protocols with explicit state and hashable-key bounds, precise representation defaults, and deferred annotations. Both mypy and Pyright validate the generic contracts; game primitives and evaluation behavior are preserved.
Key concepts
- Game primitives:
State,HasTurn[RoleT], andTurnState[RoleT]model states and acting roles.Colorremains the natural role type for black/white games, whileSoloRolesupports single-player sequential games without fake color semantics. 【F:src/valanga/game.py†L1-L189】 - Evaluations:
Valuecarries a score, certainty level, and optional terminalOverEventmetadata. 【F:src/valanga/evaluations.py†L31-L47】 - Game termination:
OverEventstoresoutcome,termination, and optionalwinnermetadata. 【F:src/valanga/over_event.py†L1-L99】 - State representations:
ContentRepresentationdefines how to turn aStateinto evaluator input, andRepresentationFactorybuilds or updates those representations from states and modifications. 【F:src/valanga/represention_for_evaluation.py†L9-L22】【F:src/valanga/representation_factory.py†L7-L55】 - Progress reporting:
PlayerProgressMessageis a Color-specific helper for per-player progress reporting. It is not part of the core generic role model. 【F:src/valanga/progress_messsage.py†L1-L13】
Installation
pip install valanga==0.3.0
The project targets Python 3.14 and has no required runtime dependencies.
Quick start
Below is a minimal example that records both a two-player terminal result and a single-player terminal result:
from enum import Enum, auto
from valanga import Color, Outcome, OverEvent
class ChessTermination(Enum):
CHECKMATE = auto()
class PuzzleTermination(Enum):
GOAL_REACHED = auto()
# Two-player result: white wins by checkmate.
checkmate = OverEvent(
outcome=Outcome.WIN,
termination=ChessTermination.CHECKMATE,
winner=Color.WHITE,
)
# Single-player result: the puzzle objective was reached.
puzzle_clear = OverEvent(
outcome=Outcome.WIN,
termination=PuzzleTermination.GOAL_REACHED,
)
print(checkmate.is_win_for(Color.WHITE)) # -> True
print(puzzle_clear.is_success()) # -> True
To wire in a custom state representation, supply callables to RepresentationFactory that know how to build representations from a State and its modifications.
Development
Install the development dependencies and run the test suite:
uv venv --python 3.14
uv pip install -e '.[test,dev]'
source .venv/bin/activate
tox
Python 3.14 uses deferred annotations by default. Runtime consumers should use
typing.get_type_hints for resolved types and annotationlib.get_annotations
with Format.STRING when annotation text is needed. Generic protocols use native
type parameters; acting roles and branch keys retain their hashable bounds.
Generic type contracts are checked by both mypy and Pyright in tox -e typecheck.
The fixtures verify key/role covariance, selector/input contravariance, output
covariance, state/transition relationships and undo-token identity. Both checkers
must also reject the marked invalid examples in tests/typing/invalid.py.
Dynamics and ReversibleDynamics require a State; tag resolvers require
hashable tags. ContentRepresentation defaults to State and EvaluatorInput.
These bounds and defaults are declared on the native type parameters themselves.
Metadata
Release files for valanga 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| valanga-0.3.0.tar.gz | 31.4 kB | With provenance | Details for valanga-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| valanga-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for valanga-0.3.0-py3-none-any.whl |
Total release size: 57.5 kB
Release files / valanga-0.3.0.tar.gz
| Download URL | valanga-0.3.0.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e713dcf20b6735d8d6dd30cf3172aded4753be09681d5eeb9451c132b189547
|
|
BLAKE2b-256 checksum How to use checksums |
aa778cd7e957c3239efd4b3abcd1032357f0b0e2c279b487d77381543483fedb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / valanga-0.3.0-py3-none-any.whl
| Download URL | valanga-0.3.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94b4b9e2b5b45890378416d936d956afda38f7402b726d14b264dc714e475e93
|
|
BLAKE2b-256 checksum How to use checksums |
3eba8d37d6cbf6c57c2e9ed39a9789ca6dcbe93a3c0604da58dedfe89b2f4967
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logSecurity for valanga 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for valanga-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.