Skip to content

Commit

Permalink
REQUIRED / USEFUL items split
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 24, 2024
1 parent 5673afa commit d14b08c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pokemonred_puffer/data/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
KEY_ITEM_IDS,
MAX_ITEM_CAPACITY,
REQUIRED_ITEMS,
USEFUL_ITEMS,
Items,
)
from pokemonred_puffer.data.strength_puzzles import STRENGTH_SOLUTIONS
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion pokemonred_puffer/rewards/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d14b08c

Please sign in to comment.