Skip to content

Commit

Permalink
no cutmon check
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 6, 2024
1 parent b5b0d09 commit 8898c63
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ def step(self, action):
# self.caught_pokemon[6] == 1 # squirtle
)

# cut mon check
if not self.party_has_cut_capable_mon():
reset = True
self.first = True
new_reward = -self.progress_reward

return obs, new_reward, reset, False, info

def run_action_on_emulator(self, action):
Expand All @@ -636,6 +642,18 @@ def run_action_on_emulator(self, action):
self.teach_cut()
self.cut_if_next()

def party_has_cut_capable_mon(self):
# find bulba and replace tackle (first skill) with cut
party_size = self.read_m("wPartyCount")
for i in range(party_size):
# PRET 1-indexes
_, species_addr = self.pyboy.symbol_lookup(f"wPartyMon{i+1}Species")
poke = self.pyboy.memory[species_addr]
# https://github.com/pret/pokered/blob/d38cf5281a902b4bd167a46a7c9fd9db436484a7/constants/pokemon_constants.asm
if poke in CUT_SPECIES_IDS:
return True
return False

def teach_cut(self):
# find bulba and replace tackle (first skill) with cut
party_size = self.read_m("wPartyCount")
Expand Down

0 comments on commit 8898c63

Please sign in to comment.