Implementing a new environment type
To create a new environment type, you need to create a new class that inherits from the
GenericEnvironment class.
An environment object has three separate configuration attributes:
settingsis an class attribute. It should be an instance ofEnvSettings. It contains all kinds of attributes that are relevant for every environment instance of this type. For example, it can specify whether higher or lower ratings are better.env_infocontains general information about the environment instance: its identifier and its display name.config_jsoncontains arbitrary (JSON-based) configuration of the environment instance. For example, for a chess environment, it might contain the opponent strength or the color of the player (if it is not chosen randomly).
The environment class must implement the following methods:
new_run()creates a new run. Concretely, it should return the state of the new run (JSON-based). For example, for a chess environment, it might return the initial board state.get_action_request()should return a new action request for a given run. It gets passed aRunDataobject, which contains the history of the run so far, including the state. It should return aActionRequest, which contains the data that should be conveyed to the agent (it might be the state/sensor information/…).act()gets passed the action sent by the agent (arbitrary JSON) and aRunDataobject. It should return aActionResultthat might contain the new state, the outcome, or an error message.view_env()gets passed anEnvDataobject containing some data about the agents and recent runs in the environment instance. It should return an HTML string that is displayed in the environment view. For example, it can contain a leader board. You can get a simple default implementation by also inheriting fromSimpleViewEnv.view_agent()gets passed anAgentDataSummaryobject containing some data about the agent. It should return an HTML string that is displayed when viewing the agent (e.g. its rating and its recent runs). If you do not implement it, viewing an agent is not possible. You can get a simple default implementation by also inheriting fromSimpleViewAgent.view_run()gets passed aRunDataobject containing some data about the run. It should return an HTML string that is displayed when viewing the run. For example, it can contain a visualization of the run (e.g. an animation of the chess game). If you do not implement it, viewing a run is not possible.