Using Scenarios

Because most usage of the game will be more or less the same, some stuff has been automated in the form of a Scenario. Scenarios offer a way to define settings and score conditions, and automatically save the results of repeated runs.

For example, we subclass the Scenario module from domination.scenarios:

import domination

class MyScenario(domination.scenarios.Scenario) :
   REPEATS  = 10
   SETTINGS = core.Settings()
   FIELD    = core.FieldGenerator().generate()

   def before_each():
       # Regenerate the field before each game.
       self.FIELD = core.FieldGenerator().generate()

We can now run our scenario and save the results:

MyScenario.one_on_one('', '', output_folder='results')

When a tournament is run, using domination.scenarios.Scenario.tournament() a MatchInfo object is passed to the agent constructor.


class domination.scenarios.Scenario[source]

A scenario is used to run multiple games under the same conditions.

SETTINGS = Settings()

The settings with which these games will be played

GENERATOR = <domination.core.FieldGenerator object>

Will generate FIELD before each game if defined

FIELD = None

Will play on this field if GENERATOR is None


How many times to repeat each game


Repeat each run with blue/red swapped


Function is called once before any games


Function that is run before each game. Use it to regenerate the map, for example.


Function that is run after each game.

Parameters:game – The previous game
classmethod test(red, blue)[source]

Test this scenario, this will run a single game and render it, so you can verify the FIELD and SETTINGS.

  • red – Path to red agent
  • blue – Path to blue agent
classmethod one_on_one(output_folder, red, blue, rendered=False, verbose=False)[source]

Runs the set amount of REPEATS and SWAP_TEAMS if desired, between two given agents.

Parameters:output_folder – Folder in which results will be stored
classmethod tournament(output_folder, folder=None, agents=None, rendered=False, verbose=False)[source]

Runs a full tournament between the agents specified, respecting the REPEATS and SWAP_TEAMS settings.

  • agents – A list of paths to agents
  • folder – A folder that contains all agents, overrides the agents parameter.
  • output_folder – Folder in which results will be stored.
class domination.scenarios.MatchInfo(num_games, current, match_id, score_weight)[source]

An instance of this object is passed to agents to let them know that they are participating in a match consisting of multiple games, and which game they are currently in.

Constructor for MatchInfo

  • num_games – The total number of games in this match
  • current – The current game with 1 being the first game.
  • match_id – A unique id of the opponent the agent is playing against.
  • score_weight – How much weight is assigned to the score of the current match.