gameboy_worlds.emulation.bomberman.trackers

  1from gameboy_worlds.emulation.bomberman.base_metrics import (
  2    BombermanMaxCoreMetrics,
  3    BombermanMaxOCRMetric,
  4    BombermanPocketCoreMetrics,
  5    BombermanPocketOCRMetric,
  6    BombermanQuestCoreMetrics,
  7    BombermanQuestOCRMetric,
  8)
  9from gameboy_worlds.emulation.bomberman.test_metrics import (
 10    BattleActiveTerminateMetric,
 11    BombSelectOpenTerminateMetric,
 12    BombComponentSelectTerminateMetric,
 13    BookReadTerminateMetric,
 14    BombermanMaxGameOverTerminateMetric,
 15    BombermanPocketGameOverTerminateMetric,
 16    BombermanQuestGameOverTerminateMetric,
 17    BombermanQuestPauseMenuOpenTerminateMetric,
 18    CharabomSelectOpenTerminateMetric,
 19    DialogueActiveTerminateMetric,
 20    EnterCampTerminateMetric,
 21    BoxPickedUpTerminateMetric,
 22    CliffBoxPickedUpTerminateMetric,
 23    HardSwitchActivatedTerminateMetric,
 24    EnterCaveTerminateMetric,
 25    EnterRoomTerminateMetric,
 26    EnterRuinsTerminateMetric,
 27    SaveNpcActiveTerminateMetric,
 28    ButtonRegionChangedTerminateMetric,
 29    SwitchActivatedTerminateMetric,
 30    EnterHouseTerminateMetric,
 31    AreaIntroTerminateMetric,
 32    HudBombCountChangedTerminateMetric,
 33    HudBottomRightChangedTerminateMetric,
 34    HudChangedTerminateMetric,
 35    HudPocketEnemyKillTerminateMetric,
 36    HudEnemyCountChangedTerminateMetric,
 37    HudFireChangedTerminateMetric,
 38    HudHeartChangedTerminateMetric,
 39    JumpLevelSelectTerminateMetric,
 40    JumpRankingTerminateMetric,
 41    JumpResultsTerminateMetric,
 42    NpcDialogueTerminateMetric,
 43    PauseActiveTerminateMetric,
 44    PauseMenuOpenTerminateMetric,
 45    PitchAreaTerminateMetric,
 46    ShieldSelectTerminateMetric,
 47    SignDialogueTerminateMetric,
 48    StageBriefingTerminateMetric,
 49    StageSelectTerminateMetric,
 50    WorldClearTerminateMetric,
 51)
 52from gameboy_worlds.emulation.tracker import (
 53    DummySubGoalMetric,
 54    StateTracker,
 55    TestTrackerMixin,
 56)
 57
 58
 59class BombermanTracker(StateTracker):
 60    CORE_METRIC_CLASS = None
 61
 62    def start(self):
 63        super().start()
 64        self.metric_classes.extend([self.CORE_METRIC_CLASS])
 65
 66
 67class BombermanBaseTestTracker(TestTrackerMixin, BombermanTracker):
 68    TERMINATION_TRUNCATION_METRIC = None
 69    SUBGOAL_METRIC = DummySubGoalMetric
 70
 71
 72class BombermanMaxTracker(BombermanTracker):
 73    CORE_METRIC_CLASS = BombermanMaxCoreMetrics
 74
 75
 76class BombermanMaxOCRTracker(BombermanMaxTracker):
 77    def start(self):
 78        super().start()
 79        self.metric_classes.extend([BombermanMaxOCRMetric])
 80
 81
 82class BombermanMaxBaseTestTracker(BombermanBaseTestTracker, BombermanMaxOCRTracker):
 83    pass
 84
 85
 86class BombermanMaxPauseMenuTestTracker(BombermanMaxBaseTestTracker):
 87    TERMINATION_TRUNCATION_METRIC = PauseMenuOpenTerminateMetric
 88
 89
 90class BombermanMaxStageSelectTestTracker(BombermanMaxBaseTestTracker):
 91    TERMINATION_TRUNCATION_METRIC = StageSelectTerminateMetric
 92
 93
 94class BombermanMaxGameOverTestTracker(BombermanMaxBaseTestTracker):
 95    TERMINATION_TRUNCATION_METRIC = BombermanMaxGameOverTerminateMetric
 96
 97
 98class BombermanMaxCharabomSelectTestTracker(BombermanMaxBaseTestTracker):
 99    TERMINATION_TRUNCATION_METRIC = CharabomSelectOpenTerminateMetric
100
101
102class BombermanMaxStageBriefingTestTracker(BombermanMaxBaseTestTracker):
103    TERMINATION_TRUNCATION_METRIC = StageBriefingTerminateMetric
104
105
106class BombermanMaxPickupBombUpTestTracker(BombermanMaxBaseTestTracker):
107    TERMINATION_TRUNCATION_METRIC = HudBombCountChangedTerminateMetric
108
109
110class BombermanMaxDefeatEnemyTestTracker(BombermanMaxBaseTestTracker):
111    TERMINATION_TRUNCATION_METRIC = HudEnemyCountChangedTerminateMetric
112
113
114class BombermanMaxPickupFireUpTestTracker(BombermanMaxBaseTestTracker):
115    TERMINATION_TRUNCATION_METRIC = HudFireChangedTerminateMetric
116
117
118class BombermanMaxPitchAreaTestTracker(BombermanMaxBaseTestTracker):
119    TERMINATION_TRUNCATION_METRIC = PitchAreaTerminateMetric
120
121
122class BombermanPocketTracker(BombermanTracker):
123    CORE_METRIC_CLASS = BombermanPocketCoreMetrics
124
125
126class BombermanPocketOCRTracker(BombermanPocketTracker):
127    def start(self):
128        super().start()
129        self.metric_classes.extend([BombermanPocketOCRMetric])
130
131
132class BombermanPocketBaseTestTracker(BombermanBaseTestTracker, BombermanPocketOCRTracker):
133    pass
134
135
136class BombermanPocketPauseMenuTestTracker(BombermanPocketBaseTestTracker):
137    TERMINATION_TRUNCATION_METRIC = PauseActiveTerminateMetric
138
139
140class BombermanPocketForestAreaIntroTestTracker(BombermanPocketBaseTestTracker):
141    TERMINATION_TRUNCATION_METRIC = AreaIntroTerminateMetric
142
143
144class BombermanPocketOceanAreaIntroTestTracker(BombermanPocketBaseTestTracker):
145    TERMINATION_TRUNCATION_METRIC = AreaIntroTerminateMetric
146
147
148class BombermanPocketWorldClearTestTracker(BombermanPocketBaseTestTracker):
149    TERMINATION_TRUNCATION_METRIC = WorldClearTerminateMetric
150
151
152class BombermanPocketGameOverTestTracker(BombermanPocketBaseTestTracker):
153    TERMINATION_TRUNCATION_METRIC = BombermanPocketGameOverTerminateMetric
154
155
156class BombermanPocketJumpLevelSelectTestTracker(BombermanPocketBaseTestTracker):
157    TERMINATION_TRUNCATION_METRIC = JumpLevelSelectTerminateMetric
158
159
160class BombermanPocketJumpResultsTestTracker(BombermanPocketBaseTestTracker):
161    TERMINATION_TRUNCATION_METRIC = JumpResultsTerminateMetric
162
163
164class BombermanPocketJumpRankingTestTracker(BombermanPocketBaseTestTracker):
165    TERMINATION_TRUNCATION_METRIC = JumpRankingTerminateMetric
166
167
168class BombermanPocketHudChangedTestTracker(BombermanPocketBaseTestTracker):
169    TERMINATION_TRUNCATION_METRIC = HudChangedTerminateMetric
170
171
172class BombermanPocketHudEnemyCountChangedTestTracker(BombermanPocketBaseTestTracker):
173    TERMINATION_TRUNCATION_METRIC = HudPocketEnemyKillTerminateMetric
174
175
176class BombermanPocketHudBottomRightChangedTestTracker(
177    BombermanPocketBaseTestTracker
178):
179    TERMINATION_TRUNCATION_METRIC = HudBottomRightChangedTerminateMetric
180
181
182class BombermanPocketHudHeartChangedTestTracker(BombermanPocketBaseTestTracker):
183    TERMINATION_TRUNCATION_METRIC = HudHeartChangedTerminateMetric
184
185
186class BombermanQuestTracker(BombermanTracker):
187    CORE_METRIC_CLASS = BombermanQuestCoreMetrics
188
189
190class BombermanQuestOCRTracker(BombermanQuestTracker):
191    def start(self):
192        super().start()
193        self.metric_classes.extend([BombermanQuestOCRMetric])
194
195
196class BombermanQuestBaseTestTracker(BombermanBaseTestTracker, BombermanQuestOCRTracker):
197    pass
198
199
200class BombermanQuestPauseMenuTestTracker(BombermanQuestBaseTestTracker):
201    TERMINATION_TRUNCATION_METRIC = BombermanQuestPauseMenuOpenTerminateMetric
202
203
204class BombermanQuestGameOverTestTracker(BombermanQuestBaseTestTracker):
205    TERMINATION_TRUNCATION_METRIC = BombermanQuestGameOverTerminateMetric
206
207
208class BombermanQuestBombSelectTestTracker(BombermanQuestBaseTestTracker):
209    TERMINATION_TRUNCATION_METRIC = BombSelectOpenTerminateMetric
210
211
212class BombermanQuestDialogueTestTracker(BombermanQuestBaseTestTracker):
213    TERMINATION_TRUNCATION_METRIC = DialogueActiveTerminateMetric
214
215
216class BombermanQuestNpcDialogueTestTracker(BombermanQuestBaseTestTracker):
217    TERMINATION_TRUNCATION_METRIC = NpcDialogueTerminateMetric
218
219
220class BombermanQuestSignDialogueTestTracker(BombermanQuestBaseTestTracker):
221    TERMINATION_TRUNCATION_METRIC = SignDialogueTerminateMetric
222
223
224class BombermanQuestBattleTestTracker(BombermanQuestBaseTestTracker):
225    TERMINATION_TRUNCATION_METRIC = BattleActiveTerminateMetric
226
227
228
229class BombermanQuestShieldSelectTestTracker(BombermanQuestBaseTestTracker):
230    TERMINATION_TRUNCATION_METRIC = ShieldSelectTerminateMetric
231
232
233class BombermanQuestBombComponentSelectTestTracker(BombermanQuestBaseTestTracker):
234    TERMINATION_TRUNCATION_METRIC = BombComponentSelectTerminateMetric
235
236
237class BombermanQuestEnterCampTestTracker(BombermanQuestBaseTestTracker):
238    TERMINATION_TRUNCATION_METRIC = EnterCampTerminateMetric
239
240
241class BombermanQuestEnterHouseTestTracker(BombermanQuestBaseTestTracker):
242    TERMINATION_TRUNCATION_METRIC = EnterHouseTerminateMetric
243
244
245class BombermanQuestEnterCaveTestTracker(BombermanQuestBaseTestTracker):
246    TERMINATION_TRUNCATION_METRIC = EnterCaveTerminateMetric
247
248
249class BombermanQuestEnterRoomTestTracker(BombermanQuestBaseTestTracker):
250    TERMINATION_TRUNCATION_METRIC = EnterRoomTerminateMetric
251
252
253class BombermanQuestEnterRuinsTestTracker(BombermanQuestBaseTestTracker):
254    TERMINATION_TRUNCATION_METRIC = EnterRuinsTerminateMetric
255
256
257class BombermanQuestButtonRegionChangedTestTracker(BombermanQuestBaseTestTracker):
258    TERMINATION_TRUNCATION_METRIC = ButtonRegionChangedTerminateMetric
259
260
261class BombermanQuestSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
262    TERMINATION_TRUNCATION_METRIC = SwitchActivatedTerminateMetric
263
264
265class BombermanQuestBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
266    TERMINATION_TRUNCATION_METRIC = BoxPickedUpTerminateMetric
267
268
269class BombermanQuestCliffBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
270    TERMINATION_TRUNCATION_METRIC = CliffBoxPickedUpTerminateMetric
271
272
273class BombermanQuestHardSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
274    TERMINATION_TRUNCATION_METRIC = HardSwitchActivatedTerminateMetric
275
276
277class BombermanQuestSaveNpcTestTracker(BombermanQuestBaseTestTracker):
278    TERMINATION_TRUNCATION_METRIC = SaveNpcActiveTerminateMetric
279
280
281
282class BombermanQuestBookReadTestTracker(BombermanQuestBaseTestTracker):
283    TERMINATION_TRUNCATION_METRIC = BookReadTerminateMetric
class BombermanTracker(gameboy_worlds.emulation.tracker.StateTracker):
60class BombermanTracker(StateTracker):
61    CORE_METRIC_CLASS = None
62
63    def start(self):
64        super().start()
65        self.metric_classes.extend([self.CORE_METRIC_CLASS])

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
CORE_METRIC_CLASS = None
def start(self):
63    def start(self):
64        super().start()
65        self.metric_classes.extend([self.CORE_METRIC_CLASS])

Sets up the metrics for the tracker by creating the list self.metric_classes

Child classes must FIRST call super().start() and THEN set up their own metric classes.

class BombermanBaseTestTracker(gameboy_worlds.emulation.tracker.TestTrackerMixin, BombermanTracker):
68class BombermanBaseTestTracker(TestTrackerMixin, BombermanTracker):
69    TERMINATION_TRUNCATION_METRIC = None
70    SUBGOAL_METRIC = DummySubGoalMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

TERMINATION_TRUNCATION_METRIC = None

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

The SubGoalMetric class to use for tracking subgoal progress. If None, no such metric will be tracked.

class BombermanMaxTracker(BombermanTracker):
73class BombermanMaxTracker(BombermanTracker):
74    CORE_METRIC_CLASS = BombermanMaxCoreMetrics

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
class BombermanMaxOCRTracker(BombermanMaxTracker):
77class BombermanMaxOCRTracker(BombermanMaxTracker):
78    def start(self):
79        super().start()
80        self.metric_classes.extend([BombermanMaxOCRMetric])

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
def start(self):
78    def start(self):
79        super().start()
80        self.metric_classes.extend([BombermanMaxOCRMetric])

Sets up the metrics for the tracker by creating the list self.metric_classes

Child classes must FIRST call super().start() and THEN set up their own metric classes.

class BombermanMaxBaseTestTracker(BombermanBaseTestTracker, BombermanMaxOCRTracker):
83class BombermanMaxBaseTestTracker(BombermanBaseTestTracker, BombermanMaxOCRTracker):
84    pass

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

class BombermanMaxPauseMenuTestTracker(BombermanMaxBaseTestTracker):
87class BombermanMaxPauseMenuTestTracker(BombermanMaxBaseTestTracker):
88    TERMINATION_TRUNCATION_METRIC = PauseMenuOpenTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxStageSelectTestTracker(BombermanMaxBaseTestTracker):
91class BombermanMaxStageSelectTestTracker(BombermanMaxBaseTestTracker):
92    TERMINATION_TRUNCATION_METRIC = StageSelectTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxGameOverTestTracker(BombermanMaxBaseTestTracker):
95class BombermanMaxGameOverTestTracker(BombermanMaxBaseTestTracker):
96    TERMINATION_TRUNCATION_METRIC = BombermanMaxGameOverTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxCharabomSelectTestTracker(BombermanMaxBaseTestTracker):
 99class BombermanMaxCharabomSelectTestTracker(BombermanMaxBaseTestTracker):
100    TERMINATION_TRUNCATION_METRIC = CharabomSelectOpenTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxStageBriefingTestTracker(BombermanMaxBaseTestTracker):
103class BombermanMaxStageBriefingTestTracker(BombermanMaxBaseTestTracker):
104    TERMINATION_TRUNCATION_METRIC = StageBriefingTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxPickupBombUpTestTracker(BombermanMaxBaseTestTracker):
107class BombermanMaxPickupBombUpTestTracker(BombermanMaxBaseTestTracker):
108    TERMINATION_TRUNCATION_METRIC = HudBombCountChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxDefeatEnemyTestTracker(BombermanMaxBaseTestTracker):
111class BombermanMaxDefeatEnemyTestTracker(BombermanMaxBaseTestTracker):
112    TERMINATION_TRUNCATION_METRIC = HudEnemyCountChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxPickupFireUpTestTracker(BombermanMaxBaseTestTracker):
115class BombermanMaxPickupFireUpTestTracker(BombermanMaxBaseTestTracker):
116    TERMINATION_TRUNCATION_METRIC = HudFireChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanMaxPitchAreaTestTracker(BombermanMaxBaseTestTracker):
119class BombermanMaxPitchAreaTestTracker(BombermanMaxBaseTestTracker):
120    TERMINATION_TRUNCATION_METRIC = PitchAreaTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketTracker(BombermanTracker):
123class BombermanPocketTracker(BombermanTracker):
124    CORE_METRIC_CLASS = BombermanPocketCoreMetrics

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
class BombermanPocketOCRTracker(BombermanPocketTracker):
127class BombermanPocketOCRTracker(BombermanPocketTracker):
128    def start(self):
129        super().start()
130        self.metric_classes.extend([BombermanPocketOCRMetric])

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
def start(self):
128    def start(self):
129        super().start()
130        self.metric_classes.extend([BombermanPocketOCRMetric])

Sets up the metrics for the tracker by creating the list self.metric_classes

Child classes must FIRST call super().start() and THEN set up their own metric classes.

class BombermanPocketBaseTestTracker(BombermanBaseTestTracker, BombermanPocketOCRTracker):
133class BombermanPocketBaseTestTracker(BombermanBaseTestTracker, BombermanPocketOCRTracker):
134    pass

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

class BombermanPocketPauseMenuTestTracker(BombermanPocketBaseTestTracker):
137class BombermanPocketPauseMenuTestTracker(BombermanPocketBaseTestTracker):
138    TERMINATION_TRUNCATION_METRIC = PauseActiveTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketForestAreaIntroTestTracker(BombermanPocketBaseTestTracker):
141class BombermanPocketForestAreaIntroTestTracker(BombermanPocketBaseTestTracker):
142    TERMINATION_TRUNCATION_METRIC = AreaIntroTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketOceanAreaIntroTestTracker(BombermanPocketBaseTestTracker):
145class BombermanPocketOceanAreaIntroTestTracker(BombermanPocketBaseTestTracker):
146    TERMINATION_TRUNCATION_METRIC = AreaIntroTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketWorldClearTestTracker(BombermanPocketBaseTestTracker):
149class BombermanPocketWorldClearTestTracker(BombermanPocketBaseTestTracker):
150    TERMINATION_TRUNCATION_METRIC = WorldClearTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketGameOverTestTracker(BombermanPocketBaseTestTracker):
153class BombermanPocketGameOverTestTracker(BombermanPocketBaseTestTracker):
154    TERMINATION_TRUNCATION_METRIC = BombermanPocketGameOverTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketJumpLevelSelectTestTracker(BombermanPocketBaseTestTracker):
157class BombermanPocketJumpLevelSelectTestTracker(BombermanPocketBaseTestTracker):
158    TERMINATION_TRUNCATION_METRIC = JumpLevelSelectTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketJumpResultsTestTracker(BombermanPocketBaseTestTracker):
161class BombermanPocketJumpResultsTestTracker(BombermanPocketBaseTestTracker):
162    TERMINATION_TRUNCATION_METRIC = JumpResultsTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketJumpRankingTestTracker(BombermanPocketBaseTestTracker):
165class BombermanPocketJumpRankingTestTracker(BombermanPocketBaseTestTracker):
166    TERMINATION_TRUNCATION_METRIC = JumpRankingTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketHudChangedTestTracker(BombermanPocketBaseTestTracker):
169class BombermanPocketHudChangedTestTracker(BombermanPocketBaseTestTracker):
170    TERMINATION_TRUNCATION_METRIC = HudChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketHudEnemyCountChangedTestTracker(BombermanPocketBaseTestTracker):
173class BombermanPocketHudEnemyCountChangedTestTracker(BombermanPocketBaseTestTracker):
174    TERMINATION_TRUNCATION_METRIC = HudPocketEnemyKillTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketHudBottomRightChangedTestTracker(BombermanPocketBaseTestTracker):
177class BombermanPocketHudBottomRightChangedTestTracker(
178    BombermanPocketBaseTestTracker
179):
180    TERMINATION_TRUNCATION_METRIC = HudBottomRightChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanPocketHudHeartChangedTestTracker(BombermanPocketBaseTestTracker):
183class BombermanPocketHudHeartChangedTestTracker(BombermanPocketBaseTestTracker):
184    TERMINATION_TRUNCATION_METRIC = HudHeartChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestTracker(BombermanTracker):
187class BombermanQuestTracker(BombermanTracker):
188    CORE_METRIC_CLASS = BombermanQuestCoreMetrics

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
class BombermanQuestOCRTracker(BombermanQuestTracker):
191class BombermanQuestOCRTracker(BombermanQuestTracker):
192    def start(self):
193        super().start()
194        self.metric_classes.extend([BombermanQuestOCRMetric])

Tracks and provides API access to the game state / metrics over time and across episodes. The most hassle-free way to read from the StateTracker is to use the report() and report_final() methods to get nested dictionaries of all metrics tracked.

Example Usage:

import numpy as np
from gameboy_worlds import get_pokemon_emulator
emulator = get_pokemon_emulator(variant="pokemon_red")

# We can access the StateTracker via the emulator
state_tracker = emulator.state_tracker

# Run a random action on the emulator
emulator.reset()
allowed_actions = list(LowLevelActions)
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action) # also updates the StateTracker internally
# We can access the current episode metrics via the StateTracker
episode_metrics = state_tracker.report() # access all of them as a nested dict
specific_metric = state_tracker.get_episode_metric(("core", "steps")) # access specific metrics

# If we reset the emulator, the StateTracker will reset its inter-episode metrics as well
emulator.reset()
action = np.random.choice(allowed_actions)
_, _ = emulator.step(action)
emulator.close() # StateTracker will finalize its metrics internally
final_metrics = state_tracker.report_final() # access all of them as a nested dict
specific_final_metric = state_tracker.get_final_metric(("core", "average_steps_per_episode")) # access specific final metrics
def start(self):
192    def start(self):
193        super().start()
194        self.metric_classes.extend([BombermanQuestOCRMetric])

Sets up the metrics for the tracker by creating the list self.metric_classes

Child classes must FIRST call super().start() and THEN set up their own metric classes.

class BombermanQuestBaseTestTracker(BombermanBaseTestTracker, BombermanQuestOCRTracker):
197class BombermanQuestBaseTestTracker(BombermanBaseTestTracker, BombermanQuestOCRTracker):
198    pass

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

class BombermanQuestPauseMenuTestTracker(BombermanQuestBaseTestTracker):
201class BombermanQuestPauseMenuTestTracker(BombermanQuestBaseTestTracker):
202    TERMINATION_TRUNCATION_METRIC = BombermanQuestPauseMenuOpenTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestGameOverTestTracker(BombermanQuestBaseTestTracker):
205class BombermanQuestGameOverTestTracker(BombermanQuestBaseTestTracker):
206    TERMINATION_TRUNCATION_METRIC = BombermanQuestGameOverTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestBombSelectTestTracker(BombermanQuestBaseTestTracker):
209class BombermanQuestBombSelectTestTracker(BombermanQuestBaseTestTracker):
210    TERMINATION_TRUNCATION_METRIC = BombSelectOpenTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestDialogueTestTracker(BombermanQuestBaseTestTracker):
213class BombermanQuestDialogueTestTracker(BombermanQuestBaseTestTracker):
214    TERMINATION_TRUNCATION_METRIC = DialogueActiveTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestNpcDialogueTestTracker(BombermanQuestBaseTestTracker):
217class BombermanQuestNpcDialogueTestTracker(BombermanQuestBaseTestTracker):
218    TERMINATION_TRUNCATION_METRIC = NpcDialogueTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestSignDialogueTestTracker(BombermanQuestBaseTestTracker):
221class BombermanQuestSignDialogueTestTracker(BombermanQuestBaseTestTracker):
222    TERMINATION_TRUNCATION_METRIC = SignDialogueTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestBattleTestTracker(BombermanQuestBaseTestTracker):
225class BombermanQuestBattleTestTracker(BombermanQuestBaseTestTracker):
226    TERMINATION_TRUNCATION_METRIC = BattleActiveTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestShieldSelectTestTracker(BombermanQuestBaseTestTracker):
230class BombermanQuestShieldSelectTestTracker(BombermanQuestBaseTestTracker):
231    TERMINATION_TRUNCATION_METRIC = ShieldSelectTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestBombComponentSelectTestTracker(BombermanQuestBaseTestTracker):
234class BombermanQuestBombComponentSelectTestTracker(BombermanQuestBaseTestTracker):
235    TERMINATION_TRUNCATION_METRIC = BombComponentSelectTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestEnterCampTestTracker(BombermanQuestBaseTestTracker):
238class BombermanQuestEnterCampTestTracker(BombermanQuestBaseTestTracker):
239    TERMINATION_TRUNCATION_METRIC = EnterCampTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestEnterHouseTestTracker(BombermanQuestBaseTestTracker):
242class BombermanQuestEnterHouseTestTracker(BombermanQuestBaseTestTracker):
243    TERMINATION_TRUNCATION_METRIC = EnterHouseTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestEnterCaveTestTracker(BombermanQuestBaseTestTracker):
246class BombermanQuestEnterCaveTestTracker(BombermanQuestBaseTestTracker):
247    TERMINATION_TRUNCATION_METRIC = EnterCaveTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestEnterRoomTestTracker(BombermanQuestBaseTestTracker):
250class BombermanQuestEnterRoomTestTracker(BombermanQuestBaseTestTracker):
251    TERMINATION_TRUNCATION_METRIC = EnterRoomTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestEnterRuinsTestTracker(BombermanQuestBaseTestTracker):
254class BombermanQuestEnterRuinsTestTracker(BombermanQuestBaseTestTracker):
255    TERMINATION_TRUNCATION_METRIC = EnterRuinsTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestButtonRegionChangedTestTracker(BombermanQuestBaseTestTracker):
258class BombermanQuestButtonRegionChangedTestTracker(BombermanQuestBaseTestTracker):
259    TERMINATION_TRUNCATION_METRIC = ButtonRegionChangedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
262class BombermanQuestSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
263    TERMINATION_TRUNCATION_METRIC = SwitchActivatedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
266class BombermanQuestBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
267    TERMINATION_TRUNCATION_METRIC = BoxPickedUpTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestCliffBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
270class BombermanQuestCliffBoxPickedUpTestTracker(BombermanQuestBaseTestTracker):
271    TERMINATION_TRUNCATION_METRIC = CliffBoxPickedUpTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestHardSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
274class BombermanQuestHardSwitchActivatedTestTracker(BombermanQuestBaseTestTracker):
275    TERMINATION_TRUNCATION_METRIC = HardSwitchActivatedTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestSaveNpcTestTracker(BombermanQuestBaseTestTracker):
278class BombermanQuestSaveNpcTestTracker(BombermanQuestBaseTestTracker):
279    TERMINATION_TRUNCATION_METRIC = SaveNpcActiveTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.

class BombermanQuestBookReadTestTracker(BombermanQuestBaseTestTracker):
283class BombermanQuestBookReadTestTracker(BombermanQuestBaseTestTracker):
284    TERMINATION_TRUNCATION_METRIC = BookReadTerminateMetric

Mixin class for testing trackers. Ensures that exactly one of the tracked metrics is a TerminationTruncationMetric.

The TerminationTruncationMetric class to use for tracking termination and truncation. If None, no such metric will be tracked.