Skip to main content

Shared types and utilities for evaluation

Project description

valanga

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

Key concepts

  • Game primitives: Color, BranchKey, State, and related protocols describe whose turn it is, how to enumerate legal branches, and how to copy or advance a state. 【F:src/valanga/game.py†L14-L95】
  • Evaluations: FloatyStateEvaluation captures heuristic scores while ForcedOutcome records a definitive result plus the line of play that forces it. Both are grouped under BoardEvaluation. 【F:src/valanga/evaluations.py†L13-L43】
  • Game termination: OverEvent combines how a game ended with who won, backed by HowOver and Winner enums. Utility helpers like is_over() and get_over_tag() simplify downstream checks. 【F:src/valanga/over_event.py†L8-L115】
  • 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 communicates per-player progress percentages during long-running work. 【F:src/valanga/progress_messsage.py†L9-L18】

Installation

pip install .

The project targets Python 3.13 and has no required runtime dependencies.

Quick start

Below is a minimal example that marks a finished game and obtains an evaluation structure:

from valanga import ForcedOutcome, OverEvent
from valanga.over_event import HowOver, Winner

# A checkmate where white wins.
over_event = OverEvent(how_over=HowOver.WIN, who_is_winner=Winner.WHITE)

# Record the forced outcome and the line of optimal moves that lead to it.
forced = ForcedOutcome(outcome=over_event, line=["e2e4", "e7e5"])
print(forced.outcome.get_over_tag())  # -> OverTags.TAG_WIN_WHITE

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:

pip install -e '.[dev]'
pytest

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

valanga-0.1.14.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

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

valanga-0.1.14-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file valanga-0.1.14.tar.gz.

File metadata

  • Download URL: valanga-0.1.14.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for valanga-0.1.14.tar.gz
Algorithm Hash digest
SHA256 995f7782f320af49af77cf4dd742eb5e3cc90c9fe9fa28a4484042923bd9f194
MD5 dceda2dd38af1c5af9917b70b4b52313
BLAKE2b-256 89b17dc65018e86eb41c8c13bea94a657896e64cf6bbbc2cf8e1e00ff04d305c

See more details on using hashes here.

Provenance

The following attestation bundles were made for valanga-0.1.14.tar.gz:

Publisher: release.yml on victorgabillon/valanga

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

File details

Details for the file valanga-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: valanga-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for valanga-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 99b7d5ad45c713ef17ec03c9509e0a9e309bca91a2a6a91780fce7ee870cdc66
MD5 52b0d0f4d0aa8ad13cfc5b6f0bd02f35
BLAKE2b-256 17f05ec56a51026f070ef39c6cf9f5813fc6851a28f93e3688c39fe8fb29dc5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for valanga-0.1.14-py3-none-any.whl:

Publisher: release.yml on victorgabillon/valanga

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