Skip to main content

Gamelib for Game AI Platform of AI Club Aachen

Project description

Game Library (gamelib)

This directory contains the core game logic and interfaces for the AI Game Competition Platform. It is designed to be modular and extensible, allowing for easy addition of new games.

Structure

  • Base Classes: The root of gamelib contains abstract base classes that define the standard interface for all games.

    • agent_base.py: Base class for AI agents.
    • engine_base.py: Base class for game engines (rules, move validation, state updates).
    • gamestate_base.py: Base class for game state representations.
    • move_base.py: Base class for move representations.
  • Game Implementations: Each game has its own subdirectory (e.g., tictactoe/) containing implementations of the base classes.

    • gamestate.py: Defines the specific game state (board, scores, etc.).
    • move.py: Defines valid moves for the game.
    • engine.py: Implements the game rules.
    • agent.py: Base agent for the specific game (handles game-specific I/O).
  • Tests: tests/ contains unit and integration tests for the games.

Implementing a New Game

To add a new game (e.g., "Chess"), follow these steps:

  1. Create a Directory: Create gamelib/chess/.
  2. Implement State: Create gamelib/chess/gamestate.py inheriting from GameStateBase. Implement initial, clone, from_json, and to_json.
  3. Implement Move: Create gamelib/chess/move.py inheriting from MoveBase. Implement from_json and to_json.
  4. Implement Engine: Create gamelib/chess/engine.py inheriting from EngineBase. Implement validate_move, apply_move, is_game_over, and get_status.
  5. Implement Agent: Create gamelib/chess/agent.py inheriting from AgentBase. Override _read_init and _read_state to parse your specific JSON formats.

Tic-Tac-Toe Example

The tictactoe/ directory provides a complete reference implementation.

  • State: 3x3 board, current turn, and game status.
  • Engine: Standard Tic-Tac-Toe rules.
  • Agent: Includes a SimpleAgent example that plays random valid moves.

Running Tests

Run the tests using pytest:

pytest gamelib/tests

or if multiple Python versions are installed:

py -3.12 -m pytest gamelib/tests

Run linter, formatter and typecheck

After uv sync, you can run either:

uv run python -m scripts.commands lint
uv run python -m scripts.commands format
uv run python -m scripts.commands type-check

or with the venv activated:

python -m scripts.commands lint
python -m scripts.commands format
python -m scripts.commands type-check

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

aica_gamelib-0.1.0.tar.gz (60.8 kB view details)

Uploaded Source

Built Distribution

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

aica_gamelib-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file aica_gamelib-0.1.0.tar.gz.

File metadata

  • Download URL: aica_gamelib-0.1.0.tar.gz
  • Upload date:
  • Size: 60.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for aica_gamelib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58c304d13ac535a378538e7d99b329c0cae2ee4f1a8ad4bced77149bc3f64bc7
MD5 37d227ebc9a140ce84cfb3957ec5f3d5
BLAKE2b-256 f23c7ae4006ea9175cde4e37adfb95a456a438ec4a0b3375869fa8c768dbbd22

See more details on using hashes here.

File details

Details for the file aica_gamelib-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aica_gamelib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d97fac511f407e89410d4a06f2042bfaf3c1bb9f4bd95993bddd3b2d762b7e
MD5 ebedd40d60e963ed658e7fc3da696a6f
BLAKE2b-256 703a2b208feb2645471798c3895b47cf7f41b5b30a80c1f11265f027cb5baf3c

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