Skip to main content

valanga

Python 3.14 Tests License: GPL v3

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], and TurnState[RoleT] model states and acting roles. Color remains the natural role type for black/white games, while SoloRole supports single-player sequential games without fake color semantics. 【F:src/valanga/game.py†L1-L189】
  • Evaluations: Value carries a score, certainty level, and optional terminal OverEvent metadata. 【F:src/valanga/evaluations.py†L31-L47】
  • Game termination: OverEvent stores outcome, termination, and optional winner metadata. 【F:src/valanga/over_event.py†L1-L99】
  • State representations: ContentRepresentation defines how to turn a State into evaluator input, and RepresentationFactory builds 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: PlayerProgressMessage is 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)

Source distribution for valanga 0.3.0
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)

Table of built distributions (wheels) for valanga 0.3.0
File Interpreter ABI Platform Actions
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 log

Release 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 log

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

Select from 2 files

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 log

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

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