Skip to content

Commit

Permalink
Simpler bag items obs
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 16, 2024
1 parent f414054 commit 289f539
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 289f539

Please sign in to comment.