Skip to main content

Python hidden-information chess engine for Kriegspiel variants

Project description

kriegspiel

PyPI version

Python game engine for hidden-information Kriegspiel referee rules.

You can try the rules in a live game at kriegspiel.org.

Current scope:

  • Berkeley Kriegspiel
  • Berkeley + Any
  • Cincinnati
  • CrazyKrieg
  • English
  • RAND
  • 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

pip install kriegspiel

Quick Start

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, CrazyKrieg, English, RAND, and Wild 16 also have their own convenience entrypoints:

from kriegspiel import CincinnatiGame, CrazyKriegGame, EnglishGame, RandGame, Wild16Game

cincinnati = CincinnatiGame()
print(cincinnati.current_turn_has_pawn_capture)

crazykrieg = CrazyKriegGame()
print(crazykrieg.public_reserve_summary)

english = EnglishGame()
print(english.any_rule)

rand = RandGame()
print(rand.current_turn_pawn_try_squares)

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
  • CrazyKriegGame: Crazyhouse Kriegspiel entrypoint with public reserves, hidden drops, and exact reserve-identity capture announcements
  • EnglishGame: English convenience entrypoint with public illegal attempts and one-try ASK_ANY handling
  • RandGame: RAND convenience entrypoint with public rebuffs, pawn-try source-square announcements, typed captures, and promotion notices
  • 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

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

kriegspiel-1.7.2.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

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

kriegspiel-1.7.2-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file kriegspiel-1.7.2.tar.gz.

File metadata

  • Download URL: kriegspiel-1.7.2.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kriegspiel-1.7.2.tar.gz
Algorithm Hash digest
SHA256 979944784c8716a9b3406b9ed5f4d80c219c1e82fe21731a5d4573fd98dff6b7
MD5 1a997527b571157028ad6323b4e35c30
BLAKE2b-256 7b432d6bfcf60d300bea1d98bcdddd2ffd433be3074e139b448da708854bfbf3

See more details on using hashes here.

File details

Details for the file kriegspiel-1.7.2-py3-none-any.whl.

File metadata

  • Download URL: kriegspiel-1.7.2-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kriegspiel-1.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b3eac28d53e368e1ec46675939d99a3ade9ccbf568c96b37f15069c2bada16
MD5 5202d80391d3526c79b2be46f9116449
BLAKE2b-256 1c2f3890197e74d7152ebffb367ecdf49d42912a95a5addbda07f19ffc0e235b

See more details on using hashes here.

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