Metadata-Version: 2.4
Name: kriegspiel
Version: 1.4.2
Summary: Python hidden-information chess engine for Berkeley-family Kriegspiel variants
Author-email: Fil <alexander@kriegspiel.org>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Kriegspiel/ks-game/
Project-URL: Bug Tracker, https://github.com/Kriegspiel/ks-game/issues
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Games/Entertainment
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-chess
Provides-Extra: test
Requires-Dist: hypothesis>=6; extra == "test"
Requires-Dist: pytest>=9; extra == "test"
Requires-Dist: pytest-cov>=7; extra == "test"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: hypothesis>=6; extra == "dev"
Requires-Dist: pytest>=9; extra == "dev"
Requires-Dist: pytest-cov>=7; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# kriegspiel

[![PyPI version](https://badge.fury.io/py/kriegspiel.svg)](https://pypi.org/project/kriegspiel/)

Python game engine for hidden-information Kriegspiel referee rules.

Current scope:
- Berkeley Kriegspiel
- Berkeley + Any
- Cincinnati
- Wild 16

The package models the referee, not a UI. You interact with it by asking questions as `KriegspielMove` objects and reading `KriegspielAnswer` results.

## Install

```bash
pip install kriegspiel
```

## Quick Start

```python
import chess

from kriegspiel import KriegspielGame, KriegspielMove, QuestionAnnouncement

game = KriegspielGame()

question = KriegspielMove(
    QuestionAnnouncement.COMMON,
    chess.Move.from_uci("e2e4"),
)
answer = game.ask_for(question)

print(answer.main_announcement)
print(answer.special_announcement)

game.save_game("game.json")
loaded = KriegspielGame.load_game("game.json")
```

`KriegspielGame()` defaults to Berkeley + Any for backward compatibility. You can
still use `BerkeleyGame` explicitly as a compatibility wrapper, or pick a ruleset
with `ruleset=...`.

Cincinnati and Wild 16 also have their own convenience entrypoints:

```python
from kriegspiel import CincinnatiGame, Wild16Game

cincinnati = CincinnatiGame()
print(cincinnati.current_turn_has_pawn_capture)

wild16 = Wild16Game()
print(wild16.current_turn_pawn_tries)
```

## Main Concepts

- `KriegspielGame`: the neutral public entrypoint for the shared hidden-board engine
- `BerkeleyGame`: backward-compatible Berkeley-named wrapper over `KriegspielGame`
- `CincinnatiGame`: Cincinnati convenience entrypoint with public `NONSENSE` and binary pawn-capture announcements
- `Wild16Game`: Wild 16 convenience entrypoint over the shared hidden-board engine
- `KriegspielMove`: a player question, either a normal move or `ASK_ANY`
- `KriegspielAnswer`: the referee response, including move outcome, captures, special announcements, and variant-specific public metadata

## Links

- PyPI: [kriegspiel](https://pypi.org/project/kriegspiel/)
- Issues: [github.com/Kriegspiel/ks-game/issues](https://github.com/Kriegspiel/ks-game/issues)
