Skip to content

Commit

Permalink
Fix readbit
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Mar 22, 2024
1 parent cb7c675 commit 6513fdd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ debug:
env:
headless: False
stream_wrapper: False
init_state: cut
train:
device: cpu
compile: False
Expand Down
3 changes: 1 addition & 2 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,7 @@ def read_short(self, addr: str | int) -> int:

def read_bit(self, addr: str | int, bit: int) -> bool:
# add padding so zero will read '0b100000000' instead of '0b0'
# return bin(256 + self.read_m(addr))[-bit - 1] == "1"
return bool(int(self.read_m(addr)) & (1 << (7 - bit)))
return bool(int(self.read_m(addr)) & (1 << bit))

def read_event_bits(self):
_, addr = self.pyboy.symbol_lookup("wEventFlags")
Expand Down

0 comments on commit 6513fdd

Please sign in to comment.