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.5.tar.gz (53.8 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.5-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: valanga-0.2.5.tar.gz
  • Upload date:
  • Size: 53.8 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.5.tar.gz
Algorithm Hash digest
SHA256 727e697d81891fd47ed7af4fc62203f292c37847c2aded5494e06d38d0a75ad1
MD5 e15c16de3f6cfa33ac92e71b4ca45891
BLAKE2b-256 3abe51bc3e82730da04602510da5c6f2c4cead5efd9cdba6fa927ef9dbb1848c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: valanga-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 38.4 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6d405eefbd7bb52718be67fee843fd34a99d07564e0fc5a41acb02d712e1bdee
MD5 01c708b232ba9311da8200b956fd5de4
BLAKE2b-256 58a3cc7bca6a9c5435f9cc7e2800ba861306afc7164b2addbd7f5e8a2c8eca86

See more details on using hashes here.

Provenance

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