Skip to main content

A Pythonic wargame engine for Guy Debord's Le Jeu de la Guerre

Project description

Pykrieg

A Pythonic wargame engine for Guy Debord's Le Jeu de la Guerre (A Game of War).

About

Pykrieg is a Python library that implements the complex rules of Guy Debord's strategic tabletop game, providing a clean, extensible API for developers to build custom interfaces, AI opponents, and analysis tools. The project is inspired by the successful python-chess library and follows similar design principles.

Planned Features

  • Complete Game Engine: Full implementation of Debord's strategic game rules
  • Clean API: Intuitive Pythonic interface modeled after python-chess
  • Extensible Design: Easy to create custom variants, unit types, and victory conditions
  • Format Support: Game record and position formats for saving/sharing games
  • Engine Protocol: UCI-like protocol for communication between engines and frontends
  • Well-Tested: Comprehensive test suite with 85%+ code coverage

Installation

pip install pykrieg

Quick Start

from pykrieg import Board, create_piece

# Create a board
board = Board()

# Add units using the factory function
board.create_and_place_unit(0, 0, 'INFANTRY', 'NORTH')
board.create_and_place_unit(5, 10, 'CAVALRY', 'NORTH')
board.create_and_place_unit(19, 24, 'INFANTRY', 'SOUTH')

# Or create units directly and place them
from pykrieg import Infantry, Cannon
unit = Cannon('NORTH')
board.place_unit(10, 10, unit)

# Query units on the board
print(board.count_units())  # Total number of units
print(board.count_units(unit_type='INFANTRY'))  # Count of infantry
print(board.get_units_by_owner('NORTH'))  # List of coordinates with North's units

# Serialize to FEN
from pykrieg import Fen
fen = Fen.board_to_fen(board)
print(fen)

# Deserialize from FEN
board2 = Fen.fen_to_board(fen)

# Check territory
print(board.get_territory(0, 0))  # 'NORTH'
print(board.get_territory(19, 24))  # 'SOUTH'

# Convert coordinates
print(Board.tuple_to_spreadsheet(0, 0))  # 'A1'
print(Board.spreadsheet_to_tuple('A1'))  # (0, 0)

Documentation

Comprehensive documentation is available at docs/ covering:

  • Basic usage
  • API reference for Board, FEN, and utility functions
  • Coordinate system details
  • FEN format specification
  • Type definitions

Build documentation locally::

cd docs make html

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Donations

If you like the project and want to support future development, consider donating!

Donation Button

License

This project is licensed under the GNU General Public License v3.0 - see LICENSE for details.

The GPL v3 license ensures that:

  • The software remains free for all users
  • Derivative works must be shared under the same license (copyleft)
  • Commercial use is prohibited (requires separate commercial license)
  • Users have the freedom to study, modify, and distribute the software

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

pykrieg-0.1.1.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

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

pykrieg-0.1.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file pykrieg-0.1.1.tar.gz.

File metadata

  • Download URL: pykrieg-0.1.1.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pykrieg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 222413bde40669e5faed71773885ba0708f75ac7a52098021d45ae473efc9010
MD5 0f20fb166bc119498b39c78655f349aa
BLAKE2b-256 e8c912e387e63b28222d65f50a0f792d6699bd44db046d0552104551af007791

See more details on using hashes here.

File details

Details for the file pykrieg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pykrieg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pykrieg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9fd8afc290ed99489d227af048dd5fde35261485cb1d9815182607bfd5a413c
MD5 46c9c0a11f184da2aba55fcb300a5156
BLAKE2b-256 ba02ca6a1111a80b86cf34a148c07b154d6de016edac78e73e661838696f7d75

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