From d14b08c7437df1ec776fcc45bf656313a1dbfa6e Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:24:48 -0400 Subject: [PATCH] REQUIRED / USEFUL items split --- pokemonred_puffer/data/items.py | 10 ++++++++-- pokemonred_puffer/environment.py | 2 ++ pokemonred_puffer/rewards/baseline.py | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pokemonred_puffer/data/items.py b/pokemonred_puffer/data/items.py index a0619c2..dee8059 100644 --- a/pokemonred_puffer/data/items.py +++ b/pokemonred_puffer/data/items.py @@ -162,8 +162,15 @@ class Items(Enum): TM_50 = 0xFA -REQUIRED_ITEMS = { +USEFUL_ITEMS = { + Items.LEMONADE, + Items.FRESH_WATER, + Items.SODA_POP, Items.BICYCLE, + Items.BIKE_VOUCHER, +} + +REQUIRED_ITEMS = { Items.POKEDEX, Items.BOULDERBADGE, Items.CASCADEBADGE, @@ -175,7 +182,6 @@ class Items(Enum): Items.EARTHBADGE, Items.SECRET_KEY, # Items.ITEM_2C, - Items.BIKE_VOUCHER, Items.CARD_KEY, Items.S_S_TICKET, Items.GOLD_TEETH, diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index 2dcd7d3..4c2a38a 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -29,6 +29,7 @@ KEY_ITEM_IDS, MAX_ITEM_CAPACITY, REQUIRED_ITEMS, + USEFUL_ITEMS, Items, ) from pokemonred_puffer.data.strength_puzzles import STRENGTH_SOLUTIONS @@ -1128,6 +1129,7 @@ def agent_stats(self, action): "events": {event: self.events.get_event(event) for event in REQUIRED_EVENTS} | {"rival3": int(self.read_m(0xD665) == 4)}, "required_items": {item.name: item.value in bag_item_ids for item in REQUIRED_ITEMS}, + "useful_items": {item.name: item.value in bag_item_ids for item in USEFUL_ITEMS}, "reward": self.get_game_state_reward(), "reward/reward_sum": sum(self.get_game_state_reward().values()), "pokemon_exploration_map": explore_map, diff --git a/pokemonred_puffer/rewards/baseline.py b/pokemonred_puffer/rewards/baseline.py index bc979ed..029f9c0 100644 --- a/pokemonred_puffer/rewards/baseline.py +++ b/pokemonred_puffer/rewards/baseline.py @@ -2,7 +2,7 @@ import pufferlib from pokemonred_puffer.data.events import REQUIRED_EVENTS -from pokemonred_puffer.data.items import REQUIRED_ITEMS +from pokemonred_puffer.data.items import REQUIRED_ITEMS, USEFUL_ITEMS from pokemonred_puffer.environment import ( EVENT_FLAGS_START, EVENTS_FLAGS_LENGTH, @@ -267,6 +267,10 @@ def get_game_state_reward(self): item.name: self.reward_config["required_item"] * float(item.value in bag_item_ids) for item in REQUIRED_ITEMS } + | { + item.name: self.reward_config["useful_item"] * float(item.value in bag_item_ids) + for item in USEFUL_ITEMS + } ) def get_levels_reward(self):