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('agent_one.py', 'agent_two.py', output_folder='results')
A scenario is used to run multiple games under the same conditions.
The settings with which these games will be played
GENERATOR= <domination.core.FieldGenerator object>¶
Will generate FIELD before each game if defined
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
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
one_on_one(output_folder, red, blue, rendered=False, verbose=False)¶
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
tournament(output_folder, folder=None, agents=None, rendered=False, verbose=False)¶
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.
MatchInfo(num_games, current, match_id, score_weight)¶
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.