Evaluation Environment
ah2ac2.evaluation.evaluation_environment.EvaluationEnvironment
Manages the interaction with a single game environment.
This class provides methods to connect to a game server, reset the environment, send actions, and receive observations, rewards, and game status.
Attributes:
Name | Type | Description |
---|---|---|
connection |
Optional[ClientConnection]
|
The active connection, if established. |
done |
bool
|
A boolean indicating if the current game episode has finished. |
score |
Optional[float]
|
The final score of the game episode, available when |
Source code in ah2ac2/evaluation/evaluation_environment.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
__init__(connection_url: str)
Initializes the EvaluationEnvironment with a connection URL.
Source code in ah2ac2/evaluation/evaluation_environment.py
info: EnvironmentInfo
property
Provides static information about the environment.
Raises:
Type | Description |
---|---|
RuntimeError
|
If the environment has not been reset yet (i.e., no info received). |
Returns:
Type | Description |
---|---|
EnvironmentInfo
|
An |
EnvironmentInfo
|
controlled agents, debug status, and game ID. |
reset()
async
Establishes a connection with the server and retrieves the initial state.
This method connects to the game server, receives the initial observation, legal moves, and environment information.
Raises:
Type | Description |
---|---|
RuntimeError
|
If the environment is already active (connection exists). It is not possible to have two connections to the server at the same time using the same object. |
RuntimeError
|
If the server returns an error during connection or initial payload. |
Returns:
Type | Description |
---|---|
A tuple |
Source code in ah2ac2/evaluation/evaluation_environment.py
step(actions: dict[str, int])
async
Sends actions to the environment and receives the next state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actions
|
dict[str, int]
|
A dictionary mapping agent IDs (controlled by the candidate) to their chosen actions (integers). |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the game is already done. |
RuntimeError
|
If the environment has not been reset yet (no connection). |
RuntimeError
|
If the server returns an error in response to the actions. |
Returns:
Type | Description |
---|---|
A tuple |
Source code in ah2ac2/evaluation/evaluation_environment.py
ah2ac2.evaluation.evaluation_environment.EnvironmentInfo
Contains static information about the evaluation environment.
Attributes:
Name | Type | Description |
---|---|---|
num_players |
int
|
The total number of players in the game. |
candidate_controlling |
list[str]
|
A list of agents that the candidate/submission controls. |
is_debug |
bool
|
A boolean flag indicating if the environment is in debug mode. |
game_id |
int
|
A unique identifier for the game instance. |