From 289f539725424ef1298791055d17d0f5b26b0754 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:23:00 -0400 Subject: [PATCH] Simpler bag items obs --- pokemonred_puffer/environment.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index 77bfd15..4d15864 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -476,13 +476,9 @@ def render(self): def _get_obs(self): # player_x, player_y, map_n = self.get_game_coords() _, wBagItems = self.pyboy.symbol_lookup("wBagItems") - bag = self.pyboy.memory[wBagItems : wBagItems + 40] - try: - end_of_bag = 2 * list(bag[::2]).index(0xFF) - except ValueError: - end_of_bag = len(bag) - bag = np.array(bag, dtype=np.uint8) - bag[end_of_bag:] = 0 + bag = np.array(self.pyboy.memory[wBagItems : wBagItems + 40]) + numBagItems = self.pyboy.symbol_lookup("wNumBagItems") + bag[2 * numBagItems :] = 0 return { **self.render(),