Skip to content

Launching Games

Gabriël edited this page Nov 1, 2021 · 2 revisions

This project makes use of the AOC-auto-game repo to configure and launch games automatically. The file game_launcher.py contains all classes and functions you will need to do just that.

Please don't run this file as a script directly. It is meant to be a library.

Use the links below to navigate to the documentation of a certain class.

Classes Overview

If you want individual information on a certain class, click below.

  • Launcher - The main entrypoint of this library
  • Game - A class containing all information on the actual process and the running game itself
  • GameStats - Contains all statistics on the game
  • PlayerStats - Contains statistics on a single player
  • GameSettings - Used to pass around map, civs and other settings
  • GameStatus - A simple enum used when reading out the current status of a game

Barebones Example

If you just want to run a 1v1 between two AIs with standard settings, you can use the following in a script and run it:

# Setup the AI names and civs
ai_names = ['your_ai_name_here', 'your_other_ai_name_here']
ai_civs = ['huns', 'celts']

# Create the game settings
game_settings = GameSettings(ai_names, ai_civs, map_size='tiny')  # The map_size is needed because the default map size is 'medium'

# Create the launcher and launch the games
launcher = Launcher(game_settings)
games = launcher.launch_games()

# Extract the scores, while filtering out the games that have crashed.
scores = [game.scores for game in game if game.status != GameStatus.EXCEPTED]

Simple Example

Let's say we want 4 matches to run simultaneously with 3 AIs in every match, playing random civs on a random map.

# Setup the AI names and civs
ai_names = ['your_ai_name_here', 'your_other_ai_name_here', 'third_ai_name']
ai_civs = ['random'] * 3

# Create the game settings
game_settings = GameSettings(ai_names, ai_civs, map_id='random_map')

# Create the launcher and launch the games
launcher = Launcher(game_settings)
games = launcher.launch_games(instances=4)

# Extract the scores, while filtering out the games that have crashed.
scores = [game.scores for game in game if game.status != GameStatus.EXCEPTED]

Clone this wiki locally