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.3.tar.gz (50.6 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.3-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for valanga-0.2.3.tar.gz
Algorithm Hash digest
SHA256 49ea3f77f3d3f09b2f2c62652a3c470a249b501352e13988db29f4d35bb7efbd
MD5 5471ea758aeb6e6d86fdb5238a299e95
BLAKE2b-256 cab483562dc9f25a039336583ee7806414d4214fb6e47ea4c9d68c56cb00ce87

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: valanga-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 36.4 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.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84742834183a1b11de5b1abb5d614ff0ee2c57ba690e7e9365a002d4dd366c78
MD5 d5fc41721caa8d25e7d9d155b5aec3ff
BLAKE2b-256 bfb9251bb887f9c099dde5ccc51f7ee3c6300b608e000fc931bdd1ba12ef61f3

See more details on using hashes here.

Provenance

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