gameboy_worlds.emulation.bomberman.test_metrics

  1from gameboy_worlds.emulation.bomberman.parsers import (
  2    BombermanMaxParser,
  3    BombermanPocketParser,
  4    BombermanQuestParser,
  5)
  6from gameboy_worlds.emulation.tracker import (
  7    RegionChangedTerminationMetric,
  8    RegionMatchTerminationMetric,
  9    TerminationMetric,
 10)
 11
 12
 13class PauseMenuOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 14    REQUIRED_PARSER = BombermanMaxParser
 15    _TERMINATION_NAMED_REGION = "screen_top"
 16    _TERMINATION_TARGET_NAME = "pause_menu_open"
 17
 18
 19class StageSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 20    REQUIRED_PARSER = BombermanMaxParser
 21    _TERMINATION_NAMED_REGION = "screen_top"
 22    _TERMINATION_TARGET_NAME = "stage_select"
 23
 24
 25class BombermanMaxGameOverTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 26    REQUIRED_PARSER = BombermanMaxParser
 27    _TERMINATION_NAMED_REGION = "screen_top"
 28    _TERMINATION_TARGET_NAME = "game_over"
 29
 30
 31class CharabomSelectOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 32    REQUIRED_PARSER = BombermanMaxParser
 33    _TERMINATION_NAMED_REGION = "screen_top"
 34    _TERMINATION_TARGET_NAME = "charabom_select_open"
 35
 36
 37class StageBriefingTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 38    REQUIRED_PARSER = BombermanMaxParser
 39    _TERMINATION_NAMED_REGION = "stage_briefing_strip"
 40    _TERMINATION_TARGET_NAME = "stage_briefing_active"
 41
 42
 43class PitchAreaTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 44    REQUIRED_PARSER = BombermanMaxParser
 45    _TERMINATION_NAMED_REGION = "screen_top"
 46    _TERMINATION_TARGET_NAME = "pitch_area"
 47
 48
 49class HudBombCountChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
 50    REQUIRED_PARSER = BombermanMaxParser
 51    _CHANGED_NAMED_REGION = "hud_bomb_count"
 52    _CHANGE_MAE_THRESHOLD = 10
 53
 54
 55class HudEnemyCountChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
 56    REQUIRED_PARSER = BombermanMaxParser
 57    _CHANGED_NAMED_REGION = "hud_enemy_count"
 58    _CHANGE_MAE_THRESHOLD = 10
 59
 60
 61class HudFireChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
 62    REQUIRED_PARSER = BombermanMaxParser
 63    _CHANGED_NAMED_REGION = "hud_fire"
 64    _CHANGE_MAE_THRESHOLD = 10
 65
 66
 67class PauseActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 68    REQUIRED_PARSER = BombermanPocketParser
 69    _TERMINATION_NAMED_REGION = "pause_indicator"
 70    _TERMINATION_TARGET_NAME = "pause_active"
 71
 72
 73class AreaIntroTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 74    REQUIRED_PARSER = BombermanPocketParser
 75    _TERMINATION_NAMED_REGION = "area_intro_block"
 76    _TERMINATION_TARGET_NAME = "area_intro_active"
 77
 78
 79class WorldClearTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 80    REQUIRED_PARSER = BombermanPocketParser
 81    _TERMINATION_NAMED_REGION = "area_intro_strip"
 82    _TERMINATION_TARGET_NAME = "world_clear"
 83
 84
 85class BombermanPocketGameOverTerminateMetric(
 86    RegionMatchTerminationMetric, TerminationMetric
 87):
 88    REQUIRED_PARSER = BombermanPocketParser
 89    _TERMINATION_NAMED_REGION = "area_intro_strip"
 90    _TERMINATION_TARGET_NAME = "game_over"
 91
 92
 93class JumpLevelSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
 94    REQUIRED_PARSER = BombermanPocketParser
 95    _TERMINATION_NAMED_REGION = "area_intro_strip"
 96    _TERMINATION_TARGET_NAME = "jump_level_select"
 97
 98
 99class JumpResultsTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
100    REQUIRED_PARSER = BombermanPocketParser
101    _TERMINATION_NAMED_REGION = "area_intro_strip"
102    _TERMINATION_TARGET_NAME = "jump_results"
103
104
105class JumpRankingTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
106    REQUIRED_PARSER = BombermanPocketParser
107    _TERMINATION_NAMED_REGION = "area_intro_strip"
108    _TERMINATION_TARGET_NAME = "jump_ranking"
109
110
111class HudChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
112    REQUIRED_PARSER = BombermanPocketParser
113    _CHANGED_NAMED_REGION = "hud_bomb_count"
114    _CHANGE_MAE_THRESHOLD = 10
115
116
117class HudPocketEnemyKillTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
118    """Enemy count change detector that treats area intro (player died) as immediate failure."""
119    REQUIRED_PARSER = BombermanPocketParser
120    _CHANGED_NAMED_REGION = "hud_enemy_count"
121    _CHANGE_MAE_THRESHOLD = 10
122
123    def determine_terminated(self, current_frame, recent_frames):
124        if self.state_parser.is_in_any_area_intro(current_frame):
125            return False
126        return super().determine_terminated(current_frame, recent_frames)
127
128    def determine_truncated(self, current_frame, recent_frames):
129        return self.state_parser.is_in_any_area_intro(current_frame)
130
131
132class HudBottomRightChangedTerminateMetric(
133    RegionChangedTerminationMetric, TerminationMetric
134):
135    REQUIRED_PARSER = BombermanPocketParser
136    _CHANGED_NAMED_REGION = "hud_bottom_right"
137    _CHANGE_MAE_THRESHOLD = 10
138
139
140class HudHeartChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
141    REQUIRED_PARSER = BombermanPocketParser
142    _CHANGED_NAMED_REGION = "hud_heart"
143    _CHANGE_MAE_THRESHOLD = 10
144
145
146class BombermanQuestPauseMenuOpenTerminateMetric(
147    RegionMatchTerminationMetric, TerminationMetric
148):
149    REQUIRED_PARSER = BombermanQuestParser
150    _TERMINATION_NAMED_REGION = "screen_top"
151    _TERMINATION_TARGET_NAME = "pause_menu_open"
152
153
154class BombermanQuestGameOverTerminateMetric(
155    RegionMatchTerminationMetric, TerminationMetric
156):
157    REQUIRED_PARSER = BombermanQuestParser
158    _TERMINATION_NAMED_REGION = "screen_top"
159    _TERMINATION_TARGET_NAME = "game_over"
160
161
162class BombSelectOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
163    REQUIRED_PARSER = BombermanQuestParser
164    _TERMINATION_NAMED_REGION = "screen_top"
165    _TERMINATION_TARGET_NAME = "bomb_select_open"
166
167
168class DialogueActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
169    REQUIRED_PARSER = BombermanQuestParser
170    _TERMINATION_NAMED_REGION = "dialogue_strip"
171    _TERMINATION_TARGET_NAME = "dialogue_active"
172
173
174class BookReadTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
175    REQUIRED_PARSER = BombermanQuestParser
176    _TERMINATION_NAMED_REGION = "book_bottom"
177    _TERMINATION_TARGET_NAME = "book_read_active"
178
179
180class NpcDialogueTerminateMetric(TerminationMetric):
181    REQUIRED_PARSER = BombermanQuestParser
182
183    def determine_terminated(self, current_frame, recent_frames):
184        return self.state_parser.is_in_npc_dialogue(current_frame)
185
186
187class SignDialogueTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
188    REQUIRED_PARSER = BombermanQuestParser
189    _TERMINATION_NAMED_REGION = "dialogue_icon"
190    _TERMINATION_TARGET_NAME = "sign_dialogue_active"
191
192
193class BattleActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
194    REQUIRED_PARSER = BombermanQuestParser
195    _TERMINATION_NAMED_REGION = "hud_bottom"
196    _TERMINATION_TARGET_NAME = "battle_active"
197
198
199class ShieldSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
200    REQUIRED_PARSER = BombermanQuestParser
201    _TERMINATION_NAMED_REGION = "item_select_panel"
202    _TERMINATION_TARGET_NAME = "shield_select_active"
203
204
205class BombComponentSelectTerminateMetric(
206    RegionMatchTerminationMetric, TerminationMetric
207):
208    REQUIRED_PARSER = BombermanQuestParser
209    _TERMINATION_NAMED_REGION = "item_select_panel"
210    _TERMINATION_TARGET_NAME = "bomb_component_select_active"
211
212
213class EnterCampTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
214    REQUIRED_PARSER = BombermanQuestParser
215    _TERMINATION_NAMED_REGION = "zone_background"
216    _TERMINATION_TARGET_NAME = "in_camp"
217
218
219class EnterHouseTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
220    REQUIRED_PARSER = BombermanQuestParser
221    _TERMINATION_NAMED_REGION = "zone_background"
222    _TERMINATION_TARGET_NAME = "in_house"
223
224
225class SaveNpcActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
226    REQUIRED_PARSER = BombermanQuestParser
227    _TERMINATION_NAMED_REGION = "zone_background"
228    _TERMINATION_TARGET_NAME = "save_npc_active"
229
230
231
232class EnterCaveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
233    REQUIRED_PARSER = BombermanQuestParser
234    _TERMINATION_NAMED_REGION = "zone_background"
235    _TERMINATION_TARGET_NAME = "in_cave"
236
237
238class EnterRoomTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
239    REQUIRED_PARSER = BombermanQuestParser
240    _TERMINATION_NAMED_REGION = "zone_background"
241    _TERMINATION_TARGET_NAME = "in_room"
242
243
244class EnterRuinsTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
245    REQUIRED_PARSER = BombermanQuestParser
246    _TERMINATION_NAMED_REGION = "zone_background"
247    _TERMINATION_TARGET_NAME = "in_ruins"
248
249
250class ButtonRegionChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
251    REQUIRED_PARSER = BombermanQuestParser
252    _CHANGED_NAMED_REGION = "button_region"
253    _CHANGE_MAE_THRESHOLD = 10
254
255
256class BoxPickedUpTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
257    REQUIRED_PARSER = BombermanQuestParser
258    _CHANGED_NAMED_REGION = "box_detector"
259    _CHANGE_MAE_THRESHOLD = 10
260
261
262class CliffBoxPickedUpTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
263    REQUIRED_PARSER = BombermanQuestParser
264    _CHANGED_NAMED_REGION = "cliff_box_detector"
265    _CHANGE_MAE_THRESHOLD = 10
266
267
268class HardSwitchActivatedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
269    REQUIRED_PARSER = BombermanQuestParser
270    _CHANGED_NAMED_REGION = "hard_switch_detector"
271    _CHANGE_MAE_THRESHOLD = 10
272
273
274class SwitchActivatedTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
275    REQUIRED_PARSER = BombermanQuestParser
276    _TERMINATION_NAMED_REGION = "switch_detector"
277    _TERMINATION_TARGET_NAME = "switch_activated"
14class PauseMenuOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
15    REQUIRED_PARSER = BombermanMaxParser
16    _TERMINATION_NAMED_REGION = "screen_top"
17    _TERMINATION_TARGET_NAME = "pause_menu_open"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

20class StageSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
21    REQUIRED_PARSER = BombermanMaxParser
22    _TERMINATION_NAMED_REGION = "screen_top"
23    _TERMINATION_TARGET_NAME = "stage_select"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

26class BombermanMaxGameOverTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
27    REQUIRED_PARSER = BombermanMaxParser
28    _TERMINATION_NAMED_REGION = "screen_top"
29    _TERMINATION_TARGET_NAME = "game_over"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

32class CharabomSelectOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
33    REQUIRED_PARSER = BombermanMaxParser
34    _TERMINATION_NAMED_REGION = "screen_top"
35    _TERMINATION_TARGET_NAME = "charabom_select_open"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

38class StageBriefingTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
39    REQUIRED_PARSER = BombermanMaxParser
40    _TERMINATION_NAMED_REGION = "stage_briefing_strip"
41    _TERMINATION_TARGET_NAME = "stage_briefing_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

44class PitchAreaTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
45    REQUIRED_PARSER = BombermanMaxParser
46    _TERMINATION_NAMED_REGION = "screen_top"
47    _TERMINATION_TARGET_NAME = "pitch_area"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

50class HudBombCountChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
51    REQUIRED_PARSER = BombermanMaxParser
52    _CHANGED_NAMED_REGION = "hud_bomb_count"
53    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

56class HudEnemyCountChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
57    REQUIRED_PARSER = BombermanMaxParser
58    _CHANGED_NAMED_REGION = "hud_enemy_count"
59    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

62class HudFireChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
63    REQUIRED_PARSER = BombermanMaxParser
64    _CHANGED_NAMED_REGION = "hud_fire"
65    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

68class PauseActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
69    REQUIRED_PARSER = BombermanPocketParser
70    _TERMINATION_NAMED_REGION = "pause_indicator"
71    _TERMINATION_TARGET_NAME = "pause_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

74class AreaIntroTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
75    REQUIRED_PARSER = BombermanPocketParser
76    _TERMINATION_NAMED_REGION = "area_intro_block"
77    _TERMINATION_TARGET_NAME = "area_intro_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

80class WorldClearTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
81    REQUIRED_PARSER = BombermanPocketParser
82    _TERMINATION_NAMED_REGION = "area_intro_strip"
83    _TERMINATION_TARGET_NAME = "world_clear"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

86class BombermanPocketGameOverTerminateMetric(
87    RegionMatchTerminationMetric, TerminationMetric
88):
89    REQUIRED_PARSER = BombermanPocketParser
90    _TERMINATION_NAMED_REGION = "area_intro_strip"
91    _TERMINATION_TARGET_NAME = "game_over"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

94class JumpLevelSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
95    REQUIRED_PARSER = BombermanPocketParser
96    _TERMINATION_NAMED_REGION = "area_intro_strip"
97    _TERMINATION_TARGET_NAME = "jump_level_select"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

100class JumpResultsTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
101    REQUIRED_PARSER = BombermanPocketParser
102    _TERMINATION_NAMED_REGION = "area_intro_strip"
103    _TERMINATION_TARGET_NAME = "jump_results"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

106class JumpRankingTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
107    REQUIRED_PARSER = BombermanPocketParser
108    _TERMINATION_NAMED_REGION = "area_intro_strip"
109    _TERMINATION_TARGET_NAME = "jump_ranking"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

112class HudChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
113    REQUIRED_PARSER = BombermanPocketParser
114    _CHANGED_NAMED_REGION = "hud_bomb_count"
115    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

118class HudPocketEnemyKillTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
119    """Enemy count change detector that treats area intro (player died) as immediate failure."""
120    REQUIRED_PARSER = BombermanPocketParser
121    _CHANGED_NAMED_REGION = "hud_enemy_count"
122    _CHANGE_MAE_THRESHOLD = 10
123
124    def determine_terminated(self, current_frame, recent_frames):
125        if self.state_parser.is_in_any_area_intro(current_frame):
126            return False
127        return super().determine_terminated(current_frame, recent_frames)
128
129    def determine_truncated(self, current_frame, recent_frames):
130        return self.state_parser.is_in_any_area_intro(current_frame)

Enemy count change detector that treats area intro (player died) as immediate failure.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

def determine_terminated(self, current_frame, recent_frames):
124    def determine_terminated(self, current_frame, recent_frames):
125        if self.state_parser.is_in_any_area_intro(current_frame):
126            return False
127        return super().determine_terminated(current_frame, recent_frames)

Determines whether the environment was terminated.

Parameters
  • current_frame: The current frame rendered by the emulator.
  • recent_frames: The stack of frames that were rendered during the last action. Shape is [n_frames, height, width, channels]. Can be None if rendering is disabled.
Returns

True if the environment was terminated, False otherwise.

def determine_truncated(self, current_frame, recent_frames):
129    def determine_truncated(self, current_frame, recent_frames):
130        return self.state_parser.is_in_any_area_intro(current_frame)

Determines whether the environment was truncated.

Parameters
  • current_frame: The current frame rendered by the emulator.
  • recent_frames: The stack of frames that were rendered during the last action. Shape is [n_frames, height, width, channels]. Can be None if rendering is disabled.
Returns

True if the environment was truncated, False otherwise.

133class HudBottomRightChangedTerminateMetric(
134    RegionChangedTerminationMetric, TerminationMetric
135):
136    REQUIRED_PARSER = BombermanPocketParser
137    _CHANGED_NAMED_REGION = "hud_bottom_right"
138    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

141class HudHeartChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
142    REQUIRED_PARSER = BombermanPocketParser
143    _CHANGED_NAMED_REGION = "hud_heart"
144    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

147class BombermanQuestPauseMenuOpenTerminateMetric(
148    RegionMatchTerminationMetric, TerminationMetric
149):
150    REQUIRED_PARSER = BombermanQuestParser
151    _TERMINATION_NAMED_REGION = "screen_top"
152    _TERMINATION_TARGET_NAME = "pause_menu_open"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

155class BombermanQuestGameOverTerminateMetric(
156    RegionMatchTerminationMetric, TerminationMetric
157):
158    REQUIRED_PARSER = BombermanQuestParser
159    _TERMINATION_NAMED_REGION = "screen_top"
160    _TERMINATION_TARGET_NAME = "game_over"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

163class BombSelectOpenTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
164    REQUIRED_PARSER = BombermanQuestParser
165    _TERMINATION_NAMED_REGION = "screen_top"
166    _TERMINATION_TARGET_NAME = "bomb_select_open"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

169class DialogueActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
170    REQUIRED_PARSER = BombermanQuestParser
171    _TERMINATION_NAMED_REGION = "dialogue_strip"
172    _TERMINATION_TARGET_NAME = "dialogue_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

175class BookReadTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
176    REQUIRED_PARSER = BombermanQuestParser
177    _TERMINATION_NAMED_REGION = "book_bottom"
178    _TERMINATION_TARGET_NAME = "book_read_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

class NpcDialogueTerminateMetric(gameboy_worlds.emulation.tracker.TerminationMetric):
181class NpcDialogueTerminateMetric(TerminationMetric):
182    REQUIRED_PARSER = BombermanQuestParser
183
184    def determine_terminated(self, current_frame, recent_frames):
185        return self.state_parser.is_in_npc_dialogue(current_frame)

Tracks whether the environment was terminated or truncated.

Reports:

  • terminated: Whether the environment was terminated.
  • truncated: Whether the environment was truncated.

Final Reports:

  • episode_end_reason: List of reasons for episode endings: "terminated", "truncated", or None (None will occur only if there is a bug that leads to a premature reset).

The StateParser which implements the minimum required functionality for this MetricGroup to work.

def determine_terminated(self, current_frame, recent_frames):
184    def determine_terminated(self, current_frame, recent_frames):
185        return self.state_parser.is_in_npc_dialogue(current_frame)

Determines whether the environment was terminated.

Parameters
  • current_frame: The current frame rendered by the emulator.
  • recent_frames: The stack of frames that were rendered during the last action. Shape is [n_frames, height, width, channels]. Can be None if rendering is disabled.
Returns

True if the environment was terminated, False otherwise.

188class SignDialogueTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
189    REQUIRED_PARSER = BombermanQuestParser
190    _TERMINATION_NAMED_REGION = "dialogue_icon"
191    _TERMINATION_TARGET_NAME = "sign_dialogue_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

194class BattleActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
195    REQUIRED_PARSER = BombermanQuestParser
196    _TERMINATION_NAMED_REGION = "hud_bottom"
197    _TERMINATION_TARGET_NAME = "battle_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

200class ShieldSelectTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
201    REQUIRED_PARSER = BombermanQuestParser
202    _TERMINATION_NAMED_REGION = "item_select_panel"
203    _TERMINATION_TARGET_NAME = "shield_select_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

206class BombComponentSelectTerminateMetric(
207    RegionMatchTerminationMetric, TerminationMetric
208):
209    REQUIRED_PARSER = BombermanQuestParser
210    _TERMINATION_NAMED_REGION = "item_select_panel"
211    _TERMINATION_TARGET_NAME = "bomb_component_select_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

214class EnterCampTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
215    REQUIRED_PARSER = BombermanQuestParser
216    _TERMINATION_NAMED_REGION = "zone_background"
217    _TERMINATION_TARGET_NAME = "in_camp"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

220class EnterHouseTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
221    REQUIRED_PARSER = BombermanQuestParser
222    _TERMINATION_NAMED_REGION = "zone_background"
223    _TERMINATION_TARGET_NAME = "in_house"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

226class SaveNpcActiveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
227    REQUIRED_PARSER = BombermanQuestParser
228    _TERMINATION_NAMED_REGION = "zone_background"
229    _TERMINATION_TARGET_NAME = "save_npc_active"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

233class EnterCaveTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
234    REQUIRED_PARSER = BombermanQuestParser
235    _TERMINATION_NAMED_REGION = "zone_background"
236    _TERMINATION_TARGET_NAME = "in_cave"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

239class EnterRoomTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
240    REQUIRED_PARSER = BombermanQuestParser
241    _TERMINATION_NAMED_REGION = "zone_background"
242    _TERMINATION_TARGET_NAME = "in_room"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

245class EnterRuinsTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
246    REQUIRED_PARSER = BombermanQuestParser
247    _TERMINATION_NAMED_REGION = "zone_background"
248    _TERMINATION_TARGET_NAME = "in_ruins"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.

251class ButtonRegionChangedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
252    REQUIRED_PARSER = BombermanQuestParser
253    _CHANGED_NAMED_REGION = "button_region"
254    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

257class BoxPickedUpTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
258    REQUIRED_PARSER = BombermanQuestParser
259    _CHANGED_NAMED_REGION = "box_detector"
260    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

263class CliffBoxPickedUpTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
264    REQUIRED_PARSER = BombermanQuestParser
265    _CHANGED_NAMED_REGION = "cliff_box_detector"
266    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

269class HardSwitchActivatedTerminateMetric(RegionChangedTerminationMetric, TerminationMetric):
270    REQUIRED_PARSER = BombermanQuestParser
271    _CHANGED_NAMED_REGION = "hard_switch_detector"
272    _CHANGE_MAE_THRESHOLD = 10

Terminates the episode if a specific named region changes significantly from its appearance at the start of the episode (on reset).

Useful for detecting pickups, stat changes, or any event that alters a HUD region without having a fixed reference capture.

Subclass and set:

_CHANGED_NAMED_REGION: name of the NamedScreenRegion to monitor _CHANGE_MAE_THRESHOLD: MAE threshold above which the region is considered changed (default 10)

The StateParser which implements the minimum required functionality for this MetricGroup to work.

275class SwitchActivatedTerminateMetric(RegionMatchTerminationMetric, TerminationMetric):
276    REQUIRED_PARSER = BombermanQuestParser
277    _TERMINATION_NAMED_REGION = "switch_detector"
278    _TERMINATION_TARGET_NAME = "switch_activated"

Terminates the episode if a specific region matches a target. Can be used to terminate episodes when specific dialogue boxes appear, etc.

The StateParser which implements the minimum required functionality for this MetricGroup to work.