Skip to content

Commit

Permalink
fix end of game crash
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Oct 5, 2024
1 parent 58b3dd9 commit 5dc1144
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ def get_game_coords(self):

def get_max_steps(self):
return max(
0,
self.max_steps,
self.max_steps
* (len(self.required_events) + len(self.required_items))
Expand Down Expand Up @@ -1602,10 +1603,11 @@ def update_max_op_level(self):
self.read_m(f"wEnemyMon{i+1}Level")
for i in range(self.read_m("wEnemyPartyCount"))
]
+ [0]
)
# - opp_base_level
)
self.max_opponent_level = max(self.max_opponent_level, opponent_level)
self.max_opponent_level = max(0, self.max_opponent_level, opponent_level)
return self.max_opponent_level

def update_health(self):
Expand Down Expand Up @@ -1688,7 +1690,7 @@ def read_hp_fraction(self):

def update_map_progress(self):
map_idx = self.read_m(0xD35E)
self.max_map_progress = max(self.max_map_progress, self.get_map_progress(map_idx))
self.max_map_progress = max(0, self.max_map_progress, self.get_map_progress(map_idx))

def get_map_progress(self, map_idx):
if map_idx in self.essential_map_locations.keys():
Expand All @@ -1707,7 +1709,7 @@ def get_hm_count(self) -> int:
def get_levels_reward(self):
# Level reward
party_levels = self.read_party()
self.max_level_sum = max(self.max_level_sum, sum(party_levels))
self.max_level_sum = max(0, self.max_level_sum, sum(party_levels))
if self.max_level_sum < 30:
level_reward = 1 * self.max_level_sum
else:
Expand Down

0 comments on commit 5dc1144

Please sign in to comment.