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.

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. To test locally, you can instantiate your class in a if __name__ == "__main__": block as shown in the example.

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.agent import Agent
from gamelib.tictactoe.gamestate import GameState
from gamelib.tictactoe.move import 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 the agent to start the game loop
    MyTicTacToeAgent()

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.1.tar.gz (62.1 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.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aica_gamelib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c1b2b17cc1bd884cc6e83d6ed9dda54af1d3d322ac4f3eefc0037a1915261efa
MD5 da66fccdc50f1cacbcfdcf3f942ca51d
BLAKE2b-256 c083dd686cc8569a0c41ee2afced681d012455a2c3f537a9a0c11a69a71f472f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aica_gamelib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09f209149a7c24d464a42de520916ae7ad654fb28801ea9139bbec8f06530627
MD5 8f1c8d138446c9af921e2f3c3b9b0120
BLAKE2b-256 4533ca3aa1fbf8c0d689972cf58f74c0ea110bdc40d3de6ce6f6cd24ebd15355

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