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
gamelibcontains 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:
- Create a Directory: Create
gamelib/chess/. - Implement State: Create
gamelib/chess/gamestate.pyinheriting fromGameStateBase. Implementinitial,clone,from_json, andto_json. - Implement Move: Create
gamelib/chess/move.pyinheriting fromMoveBase. Implementfrom_jsonandto_json. - Implement Engine: Create
gamelib/chess/engine.pyinheriting fromEngineBase. Implementvalidate_move,apply_move,is_game_over, andget_status. - Implement Agent: Create
gamelib/chess/agent.pyinheriting fromAgentBase. Override_read_initand_read_stateto 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
SimpleAgentexample 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58c304d13ac535a378538e7d99b329c0cae2ee4f1a8ad4bced77149bc3f64bc7
|
|
| MD5 |
37d227ebc9a140ce84cfb3957ec5f3d5
|
|
| BLAKE2b-256 |
f23c7ae4006ea9175cde4e37adfb95a456a438ec4a0b3375869fa8c768dbbd22
|
File details
Details for the file aica_gamelib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aica_gamelib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4d97fac511f407e89410d4a06f2042bfaf3c1bb9f4bd95993bddd3b2d762b7e
|
|
| MD5 |
ebedd40d60e963ed658e7fc3da696a6f
|
|
| BLAKE2b-256 |
703a2b208feb2645471798c3895b47cf7f41b5b30a80c1f11265f027cb5baf3c
|