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

The project targets Python 3.13 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:

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.2.4.tar.gz (52.0 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.2.4-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for valanga-0.2.4.tar.gz
Algorithm Hash digest
SHA256 60bd52caf1299c62394e76523e26d2e26720ff570c33ac410c242f2e5e54d547
MD5 1a88b149320996ce3e133af8a180bd47
BLAKE2b-256 aacc519cfc3da06d34eba3ea2671b19c963b3528d24b8ed4926588d29eaede04

See more details on using hashes here.

Provenance

The following attestation bundles were made for valanga-0.2.4.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.2.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for valanga-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3bb373a6a948e73b23e15c7ad45160119867baf3e13355c7fc538ac762c590
MD5 e16a6ebe3805d69966ae914ce21737b0
BLAKE2b-256 f1f631603f0adcdbd663949cadc4781f72779b271256f055b649b19980cdcab5

See more details on using hashes here.

Provenance

The following attestation bundles were made for valanga-0.2.4-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