Browse Source

- Fix up some routing issues with GS

- Add in addition goals and locations
rough-outline
Dan 1 year ago
parent
commit
f35cae4e59
  1. 29
      Routes/Gold_Silver_Route.py
  2. 2
      Routes/pokemon_game_desc.py
  3. 12
      convert_to_pddl.py

29
Routes/Gold_Silver_Route.py

@ -47,6 +47,7 @@ MT_SILVER = 'Mt. Silver'
SAFARI_ZONE = 'Safari Zone'
TOHJO_FALLS = 'Tohjo Falls'
POWER_PLANT = 'Power Plant'
LEAGUE_RECEPTION_GATE = 'League Reception Gate'
CUT = 'Cut'
SURF = 'Surf'
@ -90,9 +91,9 @@ RAIL_PASS = 'Rail Pass'
MISTY_FOUND = 'Misty Found'
FLUTE_CHANNEL = 'Flute Channel'
ROUTE_28_UNLOCKED = 'Rotue 28 Unlocked'
POWER_PLANT_VISITED = 'POWER_PLANT_VISITED'
FLY = 'Fly'
FLY_OUT_OF_BATTLE = 'Fly out of battle'
def get_gold_silver_desc() -> PokemonGameDesc:
@ -102,9 +103,12 @@ def get_gold_silver_desc() -> PokemonGameDesc:
desc.towns_and_cities = [NEW_BARK_TOWN, CHERRYGROVE_CITY, VIOLET_CITY, AZALEA_TOWN, GOLDENROD_CITY, ECRUTEAK_CITY, OLIVINE_CITY, CIANWOOD_CITY, MAHOGANY_TOWN, BLACKTHORN_CITY, PALLET_TOWN, VIRIDIAN_CITY, PEWTER_CITY, CERULEAN_CITY, SAFFRON_CITY, CELADON_CITY, VERMILION_CITY, FUCHSIA_CITY, CINNABAR_ISLAND]
desc.badges = [ZEPHYR_BADGE, HIVE_BADGE, PLAIN_BADGE, FOG_BADGE, STORM_BADGE, MINERAL_BADGE, GLACIER_BADGE, RISING_BADGE, BOULDER_BADGE, CASCADE_BADGE, THUNDER_BADGE, RAINBOW_BADGE, MARSH_BADGE, SOUL_BADGE, VOLCANO_BADGE, EARTH_BADGE]
desc.hms = [CUT, SURF, FLASH, STRENGTH, FLY, WATERFALL, WHIRLPOOL]
desc.additional_goals = [WOKE_SNORLAX]
desc.starting_town = NEW_BARK_TOWN
desc.end_goal = INDIGO_PLATEAU
desc.end_goal = MT_SILVER
desc.one_way_routes.append("Route_29 -> Route_46")
return desc
def get_gold_silver_route() -> Graph:
@ -205,14 +209,16 @@ def get_gold_silver_route() -> Graph:
G.add_edge('Route 45', 'Route 46', condition=None)
G.add_edge('Route 46', 'Route 29', condition=None)
G.add_edge('Route 46', DARK_CAVE, condition=[ROCK_SMASH])
G.add_edge('Route 26', NEW_BARK_TOWN, condition=[SURF, WATERFALL, WHIRLPOOL])
G.add_edge('Route 27', NEW_BARK_TOWN, condition=[SURF, WATERFALL, WHIRLPOOL])
G.add_edge('Route 26', 'Route 27', condition=None)
G.add_edge('Route 28', 'Route 27', condition=[ROUTE_28_UNLOCKED])
G.add_edge(LEAGUE_RECEPTION_GATE, 'Route 26', condition=None)
G.add_edge(LEAGUE_RECEPTION_GATE, 'Route 28', condition=[ROUTE_28_UNLOCKED])
G.add_edge(LEAGUE_RECEPTION_GATE, 'Route 22', condition=[WOKE_SNORLAX])
G.add_edge(LEAGUE_RECEPTION_GATE, 'Route 23', condition=None)
G.add_edge('Route 28', MT_SILVER, condition=None)
G.add_edge('Route 23', 'Route 27', condition=None)
G.add_edge('Route 23', VICTORY_ROAD, condition=[ZEPHYR_BADGE, HIVE_BADGE, PLAIN_BADGE, FOG_BADGE, STORM_BADGE, MINERAL_BADGE, GLACIER_BADGE, RISING_BADGE])
G.add_edge(VICTORY_ROAD, INDIGO_PLATEAU, condition=None)
G.add_edge('Route 22', 'Route 27', condition=None)
G.add_edge(SS_AQUA, VERMILION_CITY, condition=None)
G.add_edge(SAFFRON_CITY, GOLDENROD_CITY, condition=[POWER_RESTORED, RAIL_PASS])
@ -254,14 +260,11 @@ def get_gold_silver_route() -> Graph:
G.add_edge('Route 18', FUCHSIA_CITY, condition=None)
G.add_edge(FUCHSIA_CITY,'Route 19', condition=None)
G.add_edge(FUCHSIA_CITY,'Route 15', condition=None)
G.add_edge(FUCHSIA_CITY,'Safari Zone', condition=None)
G.add_edge('Route 19', 'Seafoam Islands', condition=[SURF])
G.add_edge('Seafoam Islands', 'Route 20', condition=[SURF])
G.add_edge('Route 20', CINNABAR_ISLAND, condition=[SURF])
G.add_edge('Route 21', CINNABAR_ISLAND, condition=[SURF])
G.add_edge('Route 22', VIRIDIAN_CITY, condition=None)
G.add_edge('Route 22', 'Route 23', condition=[SURF])
G.add_edge('Route 23', VICTORY_ROAD, condition=None)
G.add_edge(VICTORY_ROAD, INDIGO_PLATEAU, condition=None)
G.add_edge('Route 12', 'Route 13', condition=None)
G.add_edge('Route 13', 'Route 14', condition=None)
@ -302,6 +305,8 @@ def get_gold_silver_route() -> Graph:
G.nodes[CIANWOOD_CITY]['grants_conditions'] = [
{'condition': STORM_BADGE, 'required_conditions': []},
{'condition': MEDICINE, 'required_conditions': []},
{'condition': FLY, 'required_conditions': [STORM_BADGE]},
{'condition': FLY_OUT_OF_BATTLE, 'required_conditions': [STORM_BADGE]},
]
G.nodes[MAHOGANY_TOWN]['grants_conditions'] = [
{'condition': GLACIER_BADGE, 'required_conditions': [ROCKET_DEAFEATED]}
@ -335,10 +340,12 @@ def get_gold_silver_route() -> Graph:
{'condition': EXPN_CARD, 'required_conditions': [POWER_RESTORED]}
]
G.nodes[POWER_PLANT]['grants_conditions'] = [
{'condition': POWER_PLANT_VISITED, 'required_conditions': []},
{'condition': POWER_RESTORED, 'required_conditions': [MACHINE_PART]}
]
G.nodes[CERULEAN_CITY]['grants_conditions'] = [
{'condition': CASCADE_BADGE, 'required_conditions': [MISTY_FOUND]}
{'condition': CASCADE_BADGE, 'required_conditions': [MISTY_FOUND]},
{'condition': MACHINE_PART, 'required_conditions': [POWER_PLANT_VISITED]}
]
G.nodes['Route 25']['grants_conditions'] = [
{'condition': MISTY_FOUND, 'required_conditions': []}

2
Routes/pokemon_game_desc.py

@ -12,6 +12,8 @@ class PokemonGameDesc:
self.end_goal: str
self.flying_badge: str
self.additional_goals: List[str] = []
self.one_way_routes: List[str] = []
self.has_visited: List[str] = []
self.graph: nx.Graph = nx.Graph()
__all__ = ["PokemonGameDesc"]

12
convert_to_pddl.py

@ -106,8 +106,10 @@ def generate_pddl_problem(desc: PokemonGameDesc):
v_formatted = format_name(v)
locations.update([u_formatted, v_formatted])
# Add both directions for bidirectional movement
connections.append((u_formatted, v_formatted))
connections.append((v_formatted, u_formatted)) # Add reverse connection
if f'{u_formatted} -> {v_formatted}' not in desc.one_way_routes:
connections.append((u_formatted, v_formatted))
if f'{v_formatted} -> {u_formatted}' not in desc.one_way_routes:
connections.append((v_formatted, u_formatted)) # Add reverse connection
edge_condition = attrs.get('condition')
if edge_condition:
@ -155,11 +157,17 @@ def generate_pddl_problem(desc: PokemonGameDesc):
# Goal state
badges = desc.badges
additional_conditions = desc.additional_goals
visited = desc.has_visited
problem_pddl += " (:goal\n"
problem_pddl += " (and\n"
problem_pddl += f" (at {format_name(desc.end_goal)})\n"
for badge in badges:
problem_pddl += f" (has {format_name(badge)})\n"
for cond in additional_conditions:
problem_pddl += f" (has {format_name(cond)})\n"
for location in visited:
problem_pddl += f" (visited {format_name(location)})\n"
problem_pddl += " )\n"
problem_pddl += " )\n"
problem_pddl += ")\n"

Loading…
Cancel
Save