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.run:
import domination
class MyScenario(domination.run.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:
ms.one_on_one('agent_one.py', 'agent_two.py', output_folder='results')
Reference¶
-
class
domination.run.
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
-
REPEATS
= 2¶ How many times to repeat each game
-
SWAP_TEAMS
= True¶ Repeat each run with blue/red swapped
-
before_each
()[source]¶ Function that is run before each game. Use it to regenerate the map, for example.
-
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.
Parameters: - red – Path to red agent
- blue – Path to blue agent
-
classmethod
one_on_one
(red, blue, output_folder=None)[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
(folder=None, agents=None, output_folder=None)[source]¶ Runs a full tournament between the agents specified, respecting the REPEATS and SWAP_TEAMS settings.
Parameters: - 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.
-