Skip to content

Commit

Permalink
dtypes matater
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 16, 2024
1 parent 093dd97 commit 0ddb7df
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,12 @@ def render(self):
def _get_obs(self):
# player_x, player_y, map_n = self.get_game_coords()
_, wBagItems = self.pyboy.symbol_lookup("wBagItems")
bag = np.array(self.pyboy.memory[wBagItems : wBagItems + 40])
bag = np.array(self.pyboy.memory[wBagItems : wBagItems + 40], dtype=np.uint8)
numBagItems = self.read_m("wNumBagItems")
# item ids start at 1 so using 0 as the nothing value is okay
bag[2 * numBagItems :] = 0

return {
**self.render(),
return self.render() | {
"direction": np.array(
self.read_m("wSpritePlayerStateData1FacingDirection") // 4, dtype=np.uint8
),
Expand All @@ -495,8 +494,8 @@ def _get_obs(self):
"map_id": np.array(self.read_m(0xD35E), dtype=np.uint8),
"badges": np.array(self.read_short("wObtainedBadges").bit_count(), dtype=np.uint8),
"wJoyIgnore": np.array(self.read_m("wJoyIgnore"), dtype=np.uint8),
"bag_items": bag[::2],
"bag_quantity": bag[1::2],
"bag_items": bag[::2].copy(),
"bag_quantity": bag[1::2].copy(),
}

def set_perfect_iv_dvs(self):
Expand Down

0 comments on commit 0ddb7df

Please sign in to comment.