Skip to main content

Gamelib for Game AI Platform of AI Club Aachen

Project description

AICA Game Library

This package contains the core game logic and interfaces for the Game AI Competition Platform of the AI Club Aachen. It is designed to be easy to use. Simply instantiate the Agent class and begin!

Installation

You can install the package via pip:

pip install aica-gamelib

Creating an Agent

To create a game AI agent, you need to create a class that inherits from gamelib.GAME.agent.Agent. GAME is replaced by the relevant game such as tictactoe. You must implement two methods:

  1. initialize(self, agent_init_data): Setup your agent (e.g., store your player ID).
  2. get_move(self, game_state): Analyze the game state and return a Move object.

Game Concepts

GameState

The GameState object passed to get_move is defined in gamelib.GAME.gamestate.

Move

The Move object returned by get_move is defined in gamelib.GAME.move.

Example in TicTacToe

Here is a simple example of a tictactoe agent that selects the first available cell on the board.

from typing import override

from gamelib.tictactoe import Agent, GameState, Move

class MyTicTacToeAgent(Agent):
    @override
    def initialize(self, agent_init_data: dict) -> None:
        """
        Called once at the start of the game.
        agent_init_data contains 'player_id' (0 or 1).
        """
        self.player_id = agent_init_data["player_id"]

    @override
    def get_move(self, game_state: GameState) -> Move:
        """
        Called every turn. Returns the move you want to make.
        """
        # The board is a flat list of 9 integers
        # -1: Empty, 0: Player 0, 1: Player 1
        for position in range(9):
            if game_state.board[position] == -1:
                return Move(player=self.player_id, position=position)
        
        raise ValueError("No valid moves available.")

if __name__ == "__main__":
    # Instantiate and start the agent (run by the platform)
    agent = MyTicTacToeAgent()
    agent.start()

You can import this example agent right away with:

from gamelib.tictactoe.examples import TicTacToeAgent

Running Your Agent

The agent uses standard input/output (stdin/stdout) to communicate with the game engine, when running on the platform. This is handled automatically as long as your agent is a subclass of gamelib.GAME.agent.Agentand properly started in the __main__ block.

To test locally, you can use the DevRunner provided in the gamelib.GAME.dev_runner module:

from gamelib.tictactoe import DevRunner

runner = DevRunner()
agent1 = TicTacToeAgent()
agent2 = TicTacToeAgent()
runner.add_agent(agent1)
runner.add_agent(agent2)
runner.start()

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.3.tar.gz (65.6 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.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aica_gamelib-0.1.3.tar.gz
  • Upload date:
  • Size: 65.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aica_gamelib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 94d9b98d9329d24754815ff4579cd0de424dcd565f3ef289bdf5ff0042d7022b
MD5 9016bc8daaa1a06cdc8a375655f667dd
BLAKE2b-256 cffaf0050cda3953e18393cc3fb8f2994fd94210cb0d2d08bb90e9a82dd1de46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aica_gamelib-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aica_gamelib-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6e85f696a71b431c7746c85918666b7ba5e620ca5c168c179df7e4f91fb12c3
MD5 77e35f1d94d33b27835f8057ec4c6591
BLAKE2b-256 1b0363cdb3abb351b8818e7d0229b7d4a0bfb94c42ad5adf5f931ea9a7ed6ed1

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