diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index 1dc36f98a4..d8d3655679 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -109,7 +109,7 @@ jobs: - name: Prepare approved FRLG map resources id: map-resources - uses: dayfine/PokemonSimulation/integrations/arduino-source/verify-map-packs@d3eea1b5c04180f8b60eb98b0d65f70aca6b1abb + uses: dayfine/PokemonSimulation/integrations/arduino-source/verify-map-packs@1cacf81b2377ec1413317d905ad5415f6fe8dad5 with: layout: resources operation: prepare diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index ce0ec36aed..ce339c0433 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -230,6 +230,8 @@ add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES}) include(cmake/EmbedTextFiles.cmake) pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/TestMaps Pokemon/Navigation/Pokemon_NavigationTestMaps.h PokemonAutomation::Pokemon navigation_test_map_json) +pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/GateTestMaps + Pokemon/Navigation/Pokemon_NavigationGateTestMaps.h PokemonAutomation::Pokemon navigation_gate_test_map_json) include(cmake/PokesimMapResources.cmake) pa_frlg_map_resources(FRLG_MAP_RESOURCES) pa_embed_text_files(SerialProgramsLib "${FRLG_MAP_RESOURCES}" @@ -240,8 +242,6 @@ pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/Aut VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_checkpoint_json) pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/AutoStory/ReplayData VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay.h PokemonAutomation::NintendoSwitch::PokemonFRLG story_replay_fixture_json) -pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/GateTestMaps - Pokemon/Navigation/Pokemon_NavigationGateTestMaps.h PokemonAutomation::Pokemon navigation_gate_test_map_json) # Create binary target diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.cpp index dcb18049cb..3c0c574010 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.cpp @@ -62,6 +62,11 @@ Event story_event(const StoryStep& step, StoryStepExecutor& executor){ } return outcome; }; + if (step.gates_after){ + event.when_skipped = [&step](RunState& state){ + apply_gate_change(state.gates, *step.gates_after); + }; + } if (step.pose_after){ event.pose_learned = pose_of(*step.pose_after); } diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp index a14b5b766d..6002f95900 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp @@ -344,6 +344,33 @@ UnitTestResult test_gate_state_carried(){ return true; } +UnitTestResult test_skipped_step_gates_applied(){ + // A step that skip_if skips has its effect already: the door it opens + // is open for the steps after it, and a later step that needs it runs + // with it open. + StoryStep open_door = make(StoryStepKind::TALK, "open_door"); + open_door.skip_if = {"door_done"}; + open_door.gates_after = GateChange{.opened = {"SilphCo_5F/door_2"}}; + const StoryCheckpoint data{ + .id = "16.02", + .title = "Silph", + .steps = {open_door, make(StoryStepKind::TALK, "after")}, + }; + FakeExecutor executor; + executor.conditions = {"door_done"}; + const Run result = run(data, executor); + if (!result.report.completed || result.report.events_skipped != 1){ + return std::format("Expected the door step skipped:{}", joined(result.lines)); + } + if (executor.gates_seen.size() != 1 || !executor.gates_seen[0].second.opened.contains("SilphCo_5F/door_2")){ + return "Expected the step after a skipped door step to see the door open."; + } + if (!result.state.gates.opened.contains("SilphCo_5F/door_2")){ + return "Expected the door open at the end of the checkpoint."; + } + return true; +} + UnitTestResult test_failure_names_the_step(){ const StoryCheckpoint data = lab_checkpoint(); FakeExecutor executor; @@ -826,6 +853,10 @@ const StoryStepTestCase STORY_STEP_CASES[] = { .input = {.name = "gate state and run flags carried from the save through the steps", .test = test_gate_state_carried}, .expectation = {.description = "applies start_gates, start_flags, gates_after and flags_after in order"}, }, + { + .input = {.name = "a skipped step's gates_after is applied", .test = test_skipped_step_gates_applied}, + .expectation = {.description = "the gates a skipped step opened are open for the steps after it"}, + }, { .input = {.name = "unsupported kinds and lost battles", .test = test_unsupported_and_lost_battles}, .expectation = {.description = "flags unsupported step types and handles battle defeat"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.cpp new file mode 100644 index 0000000000..baf68ee50f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.cpp @@ -0,0 +1,547 @@ +/* Overworld Gate Maps Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The real maps, pinned PokemonSimulation resources: SilphCo_5F (card-key + * doors) and PokemonMansion_1F and _3F (statue switch, barriers, holes). + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/Navigation/Pokemon_GatedPlanner.h" +#include "PokemonFRLG_OverworldGateMaps_Tests.h" +#include "PokemonFRLG_OverworldMaps.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace Pokemon; + +namespace{ + + +// Silph 5F, Mansion 1F and 3F, in that order. +const std::vector& maps(){ + static const std::vector loaded{ + load_map("SilphCo_5F"), + load_map("PokemonMansion_1F"), + load_map("PokemonMansion_3F"), + }; + return loaded; +} +constexpr size_t SILPH = 0; +constexpr size_t MANSION_1F = 1; +constexpr size_t MANSION_3F = 2; + +const ConnectedMaps& world(){ + static const ConnectedMaps connected(maps()); + return connected; +} + + +// Walks the maps with the gates as the state says; a step onto a step-on +// warp takes it. Walk-into warps are not modeled: they are not the topic. +class GateGame{ +public: + using State = MapPlace; + using StateHash = std::hash; + + std::optional> press(const State& state, Direction direction, const GateState& gates) const{ + const MapData& map = world().map(state.map); + const TilePos next = state.tile.next(direction); + if (!map.tiles.contains(next) || !walkable(resolved_tile(map, next, gates))){ + return std::nullopt; + } + Step step; + step.next = {state.map, next}; + step.facing = direction; + for (const MapWarp& warp : map.warps){ + if (warp.enter != WarpEntry::STEP_ON || warp.x != next.x || warp.y != next.y){ + continue; + } + const std::optional arrival = warp.to ? world().warp_arrival(warp) : std::nullopt; + if (!arrival){ + return std::nullopt; + } + step.next = *arrival; + step.warped = true; + step.ends_leg = true; + } + return step; + } + bool held_at(const State& state, Direction direction, const GateState& gates) const{ + const MapData& map = world().map(state.map); + const TilePos next = state.tile.next(direction); + return !map.tiles.contains(next) || !walkable(resolved_tile(map, next, gates)); + } + MapPlace place_of(const State& state) const{ + return state; + } + +private: + static bool walkable(TileKind tile){ + return tile == TileKind::OPEN || tile == TileKind::TALL_GRASS || tile == TileKind::FALL_HOLE; + } +}; + +using GatedLegs = std::vector>>; + +std::optional plan( + const MapPlace& from, const MapPlace& to, const GateState& gates, bool card_key_held +){ + GateRules rules; + rules.card_key_held = card_key_held; + return plan_gated_legs( + GateGame(), world(), rules, GatedStart{from, gates}, + GatedGoal{std::function([to](const MapPlace& place){ return place == to; })} + ); +} + +int count_actions(const GatedLegs& legs, int action){ + int count = 0; + for (const auto& leg : legs){ + if (leg.kind == LegKind::ACTION && leg.action == action){ + count++; + } + } + return count; +} + + +// Reader + +UnitTestResult test_reads_card_key_doors(){ + const MapData& silph = maps()[SILPH]; + if (silph.gates.size() != 3 || !silph.switches.empty()){ + return std::format("Expected 3 gates and no switches, got {} and {}.", silph.gates.size(), silph.switches.size()); + } + const auto found = silph.gates.find("door_1"); + if (found == silph.gates.end()){ + return "No door_1."; + } + const MapGate& door = found->second; + if (door.kind != GateKind::CARD_KEY || door.flag != "FLAG_SILPH_5F_DOOR_1" || door.open_at_new_game || + door.open_tile != TileKind::OPEN || door.tiles.size() != 4 + ){ + return "door_1 is not a closed card-key door of 4 tiles opening to floor with its flag."; + } + if (silph.tiles.at(TilePos{7, 9}) != TileKind::GATE){ + return "Tile (7, 9) is not a gate."; + } + return true; +} + +UnitTestResult test_reads_switches(){ + const MapData& first = maps()[MANSION_1F]; + if (first.gates.size() != 4 || first.switches.size() != 1){ + return std::format("Expected 4 gates and 1 switch, got {} and {}.", first.gates.size(), first.switches.size()); + } + const MapGate& open_first = first.gates.at("barrier_2"); + if (open_first.kind != GateKind::SWITCH || open_first.switch_id != "mansion" || open_first.open_when_on || !open_first.open_at_new_game){ + return "1F barrier_2 should open when the switch is off."; + } + if (!first.gates.at("barrier_1").open_when_on){ + return "1F barrier_1 should open when the switch is on."; + } + const MapSwitch& pressing = first.switches.at("mansion"); + if (!pressing.toggle || pressing.floors.size() != 4 || pressing.flag != "FLAG_POKEMON_MANSION_SWITCH_STATE"){ + return "The switch is a toggle on 4 floors with its flag."; + } + if (pressing.statues.size() != 1 || pressing.statues[0].tile != TilePos{5, 5} || + pressing.statues[0].face_from != TilePos{5, 6} || pressing.statues[0].facing != Direction::NORTH + ){ + return "1F statue should be (5, 5), pressed from (5, 6) facing north."; + } + return true; +} + +UnitTestResult test_reads_one_way_warps(){ + int drops = 0; + for (const MapWarp& warp : maps()[MANSION_3F].warps){ + drops += warp.one_way ? 1 : 0; + } + if (drops != 5){ + return std::format("Expected 5 one-way warps on 3F, got {}.", drops); + } + for (const MapWarp& warp : maps()[MANSION_1F].warps){ + if (warp.one_way){ + return "A 1F warp is one-way."; + } + } + return true; +} + +// A 3x3 map with `gates` and `switches` (JSON object text) on tiles "G..". +std::string parse_error(const std::string& rows, const std::string& gates, const std::string& switches){ + const std::string text = std::format(R"({{ + "format": "pokesim-runtime-map/2", "name": "T", + "source": {{"decomp_file": "x", "revision": "y", "date": "z"}}, + "tiles": [{}], "points": {{}}, "warps": [], "connections": [], + "gates": {}, "switches": {} + }})", rows, gates, switches); + try{ + Pokemon::parse_map(parse_json(text), "T.json"); + }catch (ParseException& e){ + return e.message(); + } + return ""; +} + +UnitTestResult test_gate_errors(){ + const std::string rows = R"("G..", "...", "...")"; + const std::string door = R"({"d": {"tiles": [[0, 0]], "open_glyph": ".", "new_game": "closed", "opens_by": "card_key_face_a", "flag": "F"}})"; + if (!parse_error(rows, door, "{}").empty()){ + return "A valid gate failed to parse."; + } + if (parse_error(rows, "{}", "{}").empty()){ + return "A G tile in no gate was accepted."; + } + if (parse_error(R"("...", "...", "...")", door, "{}").empty()){ + return "A gate on a tile that is not G was accepted."; + } + const std::string unknown_switch = R"({"d": {"tiles": [[0, 0]], "open_glyph": ".", "new_game": "closed", "switch": "nope", "open_when": "on"}})"; + if (parse_error(rows, unknown_switch, "{}").empty()){ + return "A gate on an unlisted switch was accepted."; + } + const std::string far_statue = R"({"s": {"flag": "F", "toggle": true, "floors": ["T"], "statues": [{"coord": [9, 9], "face_from": [1, 1], "facing": "north"}]}})"; + if (parse_error(rows, door, far_statue).empty()){ + return "A statue outside the map was accepted."; + } + return true; +} + + +// Victory Road: each floor's boulder-fed floor switch opens its barrier, a +// top and a bottom tile. The switch has no statue to press, only its flag, +// which the game sets for good, and its button, the tile a boulder turns it +// on from. Each floor's switch is its own: on, it opens no other floor's. +UnitTestResult test_victory_road_barriers(){ + struct Floor{ + std::string_view name; + size_t gates; + size_t switches; + std::string_view switch_id; + std::string_view barrier; + std::string_view flag; + TilePos top; + TilePos button; + }; + const Floor floors[] = { + {"VictoryRoad_1F", 2, 1, "floor_switch_1", "barrier_1_top", "VAR_MAP_SCENE_VICTORY_ROAD_1F", {12, 14}, {20, 16}}, + {"VictoryRoad_2F", 4, 2, "floor_switch_2", "barrier_2_top", "VAR_MAP_SCENE_VICTORY_ROAD_2F_BOULDER2", {33, 16}, {14, 19}}, + {"VictoryRoad_3F", 2, 1, "floor_switch_1", "barrier_1_top", "VAR_MAP_SCENE_VICTORY_ROAD_3F", {12, 12}, {7, 7}}, + }; + for (const Floor& floor : floors){ + const MapData map = load_map(std::string(floor.name)); + if (map.gates.size() != floor.gates || map.switches.size() != floor.switches){ + return std::format("{}: expected {} gates and {} switches, got {} and {}.", + floor.name, floor.gates, floor.switches, map.gates.size(), map.switches.size()); + } + const auto found = map.switches.find(std::string(floor.switch_id)); + if (found == map.switches.end() || found->second.toggle || found->second.flag != floor.flag || !found->second.statues.empty()){ + return std::format("{}: {} should be a one-way flag switch with no statue.", floor.name, floor.switch_id); + } + const MapGate& top = map.gates.at(std::string(floor.barrier)); + if (top.kind != GateKind::SWITCH || top.switch_id != floor.switch_id || !top.open_when_on || top.open_at_new_game){ + return std::format("{}: the barrier should be closed at new game and open with {}.", floor.name, floor.switch_id); + } + const MapSwitch* pressed = switch_with_button(map, floor.button); + if (pressed == nullptr || pressed->id != floor.switch_id){ + return std::format("{}: no {} button at ({}, {}).", floor.name, floor.switch_id, floor.button.x, floor.button.y); + } + GateState off; + GateState on; + on.switches_on.insert(switch_key(*pressed)); + // Another floor's switch of the same id leaves this barrier shut. + GateState elsewhere; + elsewhere.switches_on.insert(std::format("VictoryRoad_XF/{}", floor.switch_id)); + if (resolved_tile(map, floor.top, elsewhere) != TileKind::WALL){ + return std::format("{}: another floor's {} opened the barrier.", floor.name, floor.switch_id); + } + if (resolved_tile(map, floor.top, off) != TileKind::WALL || resolved_tile(map, floor.top, on) == TileKind::WALL){ + return std::format("{}: the barrier at ({}, {}) should be a wall until {} is on.", floor.name, floor.top.x, floor.top.y, floor.switch_id); + } + } + return true; +} + +// State and tiles + +UnitTestResult test_tiles_follow_state(){ + const MapData& silph = maps()[SILPH]; + GateState state; + if (resolved_tile(silph, TilePos{7, 9}, state) != TileKind::WALL){ + return "A closed door is not a wall."; + } + state.opened.insert(gate_key("SilphCo_5F", "door_1")); + if (resolved_tile(silph, TilePos{7, 9}, state) != TileKind::OPEN || resolved_tile(silph, TilePos{7, 18}, state) != TileKind::WALL){ + return "Only door_1 should be open."; + } + if (resolve_tiles(silph, state).at(TilePos{8, 10}) != TileKind::OPEN){ + return "resolve_tiles disagrees."; + } + + // The Mansion's gates follow the one switch on every floor. + const MapData& first = maps()[MANSION_1F]; + const MapData& third = maps()[MANSION_3F]; + GateState off; + GateState on; + on.switches_on.insert("mansion"); + if (resolved_tile(first, TilePos{22, 10}, off) != TileKind::WALL || resolved_tile(first, TilePos{22, 10}, on) != TileKind::TALL_GRASS){ + return "1F barrier_1 should open with the switch on."; + } + if (resolved_tile(third, TilePos{21, 6}, off) != TileKind::TALL_GRASS || resolved_tile(third, TilePos{21, 6}, on) != TileKind::WALL){ + return "3F barrier_1 should close with the switch on."; + } + return true; +} + +UnitTestResult test_gate_change(){ + GateState state; + GateChange change; + change.opened.insert("SilphCo_5F/door_1"); + change.switches["mansion"] = true; + apply_gate_change(state, change); + if (!state.opened.contains("SilphCo_5F/door_1") || !state.switch_on("mansion")){ + return "The change was not applied."; + } + GateChange off; + off.switches["mansion"] = false; + GateState after = state; + apply_gate_change(after, off); + if (after.switch_on("mansion") || !after.opened.contains("SilphCo_5F/door_1")){ + return "Turning the switch off changed more, or nothing."; + } + GateState rebuilt; + apply_gate_change(rebuilt, gate_change_between(GateState(), state)); + if (!(rebuilt == state)){ + return "gate_change_between from nothing does not rebuild the state."; + } + apply_gate_change(rebuilt, gate_change_between(state, after)); + if (!(rebuilt == after)){ + return "gate_change_between does not carry state to state."; + } + const GateState copy = after; + if (std::hash()(copy) != std::hash()(rebuilt)){ + return "Equal states hash differently."; + } + return true; +} + + +// Planner + +UnitTestResult test_silph_door_needs_key(){ + const MapPlace from{SILPH, {10, 9}}; + const MapPlace to{SILPH, {5, 9}}; + if (plan(from, to, GateState(), false)){ + return "Planned into the room without the Card Key."; + } + const auto legs = plan(from, to, GateState(), true); + if (!legs){ + return "No route with the Card Key."; + } + if (count_actions(*legs, ACTION_OPEN_GATE) != 1){ + return std::format("Expected one open-gate leg, got {}.", count_actions(*legs, ACTION_OPEN_GATE)); + } + GateChange expected; + expected.opened.insert("SilphCo_5F/door_1"); + for (const auto& leg : *legs){ + if (leg.kind == LegKind::ACTION){ + if (!(gate_change_of(leg) == expected)){ + return "The open-gate leg did not open door_1 alone."; + } + if (leg.direction != Direction::WEST || !(leg.start.inner == MapPlace{SILPH, {9, 9}})){ + return "Expected to open it facing west from (9, 9)."; + } + } + } + if (!gates_after(GateState(), *legs).opened.contains("SilphCo_5F/door_1")){ + return "The state after the plan does not have door_1 open."; + } + return true; +} + +UnitTestResult test_silph_open_door_needs_no_key(){ + GateState opened; + opened.opened.insert(gate_key("SilphCo_5F", "door_1")); + const auto legs = plan({SILPH, {10, 9}}, {SILPH, {5, 9}}, opened, false); + if (!legs){ + return "No route through an open door."; + } + if (count_actions(*legs, ACTION_OPEN_GATE) != 0){ + return "Opened a door that was open."; + } + return true; +} + +UnitTestResult test_mansion_press_opens_barrier(){ + // (19, 13) lies behind barrier_1 and barrier_2 of 1F, which open with the switch on. + const MapPlace from{MANSION_1F, {5, 8}}; + const MapPlace to{MANSION_1F, {19, 13}}; + const auto legs = plan(from, to, GateState(), false); + if (!legs){ + return "No route."; + } + if (count_actions(*legs, ACTION_PRESS_SWITCH) != 1){ + return std::format("Expected one statue press, got {}.", count_actions(*legs, ACTION_PRESS_SWITCH)); + } + if (!gates_after(GateState(), *legs).switch_on("mansion")){ + return "The switch is not on after the plan."; + } + for (const auto& leg : *legs){ + if (leg.kind == LegKind::ACTION && (leg.direction != Direction::NORTH || !(leg.start.inner == MapPlace{MANSION_1F, {5, 6}}))){ + return "Expected to press the statue from (5, 6) facing north."; + } + } + return true; +} + +UnitTestResult test_mansion_press_again(){ + // Switch already on; (25, 21) is reachable only with it off. + GateState on; + on.switches_on.insert("mansion"); + const auto legs = plan({MANSION_1F, {5, 6}}, {MANSION_1F, {25, 21}}, on, false); + if (!legs){ + return "No route."; + } + if (count_actions(*legs, ACTION_PRESS_SWITCH) != 1 || gates_after(on, *legs).switch_on("mansion")){ + return "Expected one press, ending with the switch off."; + } + return true; +} + +UnitTestResult test_mansion_no_press_needed(){ + // Reachable with the switch as it is: no press. + const auto legs = plan({MANSION_1F, {5, 6}}, {MANSION_1F, {5, 8}}, GateState(), false); + if (!legs || count_actions(*legs, ACTION_PRESS_SWITCH) != 0){ + return "Pressed a statue that was not needed."; + } + return true; +} + +UnitTestResult test_hole_one_way(){ + // The 3F hole at (18, 18) drops to 1F's (19, 22); nothing leads back up. + const auto down = plan({MANSION_3F, {18, 17}}, {MANSION_1F, {19, 22}}, GateState(), false); + if (!down){ + return "No route down the hole."; + } + bool warped = false; + for (const auto& leg : *down){ + warped = warped || leg.warps; + } + if (!warped){ + return "The route does not take the warp."; + } + if (plan({MANSION_1F, {19, 22}}, {MANSION_3F, {18, 17}}, GateState(), false)){ + return "Planned back up a hole."; + } + return true; +} + + +struct GatesTestCase{ + struct Input{ + std::string name; + UnitTestResult (*test)(); + }; + + struct Expectation{ + std::string_view description; + }; + + Input input; + Expectation expectation; +}; + +class Test_Gates : public UnitTest{ +public: + explicit Test_Gates(GatesTestCase scenario) + : UnitTest(std::format("PokemonFRLG::OverworldGateMaps - {}", scenario.input.name)) + , m_scenario(std::move(scenario)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + return m_scenario.input.test(); + } + +private: + GatesTestCase m_scenario; +}; + +const GatesTestCase GATES_CASES[] = { + { + .input = {.name = "reads card-key doors", .test = test_reads_card_key_doors}, + .expectation = {.description = "Silph 5F doors parse with tiles, flag, open glyph"}, + }, + { + .input = {.name = "reads switches and statues", .test = test_reads_switches}, + .expectation = {.description = "Mansion gates follow the switch; statue tile and press spot"}, + }, + { + .input = {.name = "reads one-way warps", .test = test_reads_one_way_warps}, + .expectation = {.description = "3F holes are one-way"}, + }, + { + .input = {.name = "gate errors", .test = test_gate_errors}, + .expectation = {.description = "bad gates fail to parse"}, + }, + { + .input = {.name = "tiles follow the state", .test = test_tiles_follow_state}, + .expectation = {.description = "closed gate is a wall, open is its glyph, Mansion follows the switch"}, + }, + { + .input = {.name = "gate change", .test = test_gate_change}, + .expectation = {.description = "apply and between agree"}, + }, + { + .input = {.name = "a card-key door needs the key", .test = test_silph_door_needs_key}, + .expectation = {.description = "open-gate leg only with the Card Key held"}, + }, + { + .input = {.name = "an open door needs no key", .test = test_silph_open_door_needs_no_key}, + .expectation = {.description = "no open-gate leg when the state has it open"}, + }, + { + .input = {.name = "a statue press opens a barrier", .test = test_mansion_press_opens_barrier}, + .expectation = {.description = "one press-switch leg; switch on afterwards"}, + }, + { + .input = {.name = "a press again closes it", .test = test_mansion_press_again}, + .expectation = {.description = "switch is part of the search state"}, + }, + { + .input = {.name = "no press when not needed", .test = test_mansion_no_press_needed}, + .expectation = {.description = "does not toggle without reason"}, + }, + { + .input = {.name = "a hole is one-way", .test = test_hole_one_way}, + .expectation = {.description = "down yes, back up no"}, + }, + { + .input = {.name = "Victory Road barriers", .test = test_victory_road_barriers}, + .expectation = {.description = "floor switches open the barriers; boulders are not modelled"}, + }, +}; + +} // namespace + + +void add_tests_OverworldGateMaps(UnitTestDatabase& database){ + for (const auto& scenario : GATES_CASES){ + database.add(scenario); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.h new file mode 100644 index 0000000000..8d5d15317b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.h @@ -0,0 +1,26 @@ +/* Overworld Gate Maps Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldGateMaps_Tests_H +#define PokemonAutomation_PokemonFRLG_OverworldGateMaps_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Registers the gate tests on the real Silph Co. and Mansion maps: the map reader's gates, switches and one-way +// warps, the gate state, and the gated planner. +void add_tests_OverworldGateMaps(UnitTestDatabase& database); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGates_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGates_Tests.cpp index 2d0770d661..21d8aec2df 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGates_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGates_Tests.cpp @@ -159,13 +159,49 @@ UnitTestResult test_route_presses_statue(){ if (count_steps(*route, RouteAction::PRESS_SWITCH) != 1 || !(route->back().end == STATUE_GOAL)){ return "Expected one press-switch step and the goal reached:" + describe(*route); } - if (!gates_after_route(GateState(), *route).switch_on("mansion")){ + if (!gates_after_route(GateState(), *route).switch_on("GateStatue/mansion")){ return "gates_after_route() does not have the switch on."; } return true; } +// A room with a sign on its north wall, above the third column, and a +// card-key door, open, in a corner out of the way. +const std::vector& sign_maps(){ + static const std::vector MAPS{parse_map(R"({ + "format": "pokesim-runtime-map/2", "name": "GateSign", "points": {}, "warps": [], "connections": [], "source": {"decomp_file": "", "revision": "test", "date": "2026-11-12"}, + "tiles": ["##S####", "#.....#", "#.....#", "#...G.#", "#######"], + "gates": {"door_1": {"tiles": [[4, 3]], "open_glyph": ".", "new_game": "closed", "opens_by": "card_key_face_a", "flag": "FLAG_TEST"}} + })", "GateSign")}; + return MAPS; +} + +// A route over gated maps weighs a stop under a sign as one over maps +// without gates does: with the sign's overshoot dear, the walk to the tile +// under it comes from the side, not north from below. +UnitTestResult test_gated_plan_keeps_stop_risk(){ + RouteCosts costs = default_route_costs(); + costs[RouteCost::SIGN_OVERSHOOT] = 1000; + GateState open; + open.opened.insert(Pokemon::gate_key("GateSign", "door_1")); + const MapPosition start{"GateSign", {2, 3}}; + const RouteGoal goal{{"GateSign", {2, 1}}, std::nullopt}; + + const auto plain = plan_overworld_route(resolve_maps(sign_maps(), open), start, goal, costs); + const auto gated = plan_overworld_route_gated(sign_maps(), start, goal, open, GateRules(), costs); + if (!plain || !gated){ + return "No route to the tile under the sign."; + } + if (plain->back().direction == Direction::NORTH){ + return "The plain plan ends going north under the sign, so the test shows nothing:" + describe(*plain); + } + if (describe(*gated) != describe(*plain)){ + return "The gated plan differs from the plain one, which weighs the stop under the sign:" + describe(*gated) + "\n against" + describe(*plain); + } + return true; +} + // Walks `route` in the sim from `start`, with the Card Key as `card_key`. struct SimRun{ std::string failure; @@ -221,7 +257,7 @@ UnitTestResult test_sim_presses_statue(){ return "No route."; } const SimRun run = walk_in_sim(statue_maps(), STATUE_START, *route, false); - if (!run.failure.empty() || !(run.position == STATUE_GOAL) || !run.gates.switch_on("mansion")){ + if (!run.failure.empty() || !(run.position == STATUE_GOAL) || !run.gates.switch_on("GateStatue/mansion")){ return std::format("Expected the switch on and the goal reached, ended at {}: \"{}\"", to_string(run.position), run.failure) + describe(*route) + joined(run.log); } @@ -250,6 +286,7 @@ const std::vector GATES_CASES{ {.input = {.name = "no route through a card-key gate without the Card Key", .body = test_route_needs_card_key}, .expectation = {}}, {.input = {.name = "an open gate is walked through", .body = test_route_through_open_gate}, .expectation = {}}, {.input = {.name = "the route presses a statue for a switch's barrier", .body = test_route_presses_statue}, .expectation = {}}, + {.input = {.name = "a gated plan keeps the stop-risk costs", .body = test_gated_plan_keeps_stop_risk}, .expectation = {}}, {.input = {.name = "sim: face the door, A, walk through", .body = test_sim_opens_gate}, .expectation = {}}, {.input = {.name = "sim: face the statue, A, YES, walk through", .body = test_sim_presses_statue}, .expectation = {}}, {.input = {.name = "sim: the door stays shut without the Card Key", .body = test_sim_door_stays_shut_without_card_key}, .expectation = {}}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index bb0f438d3f..8b1ba24d7b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -295,7 +295,11 @@ class RouteRun{ return m_resolved ? &*m_resolved : m_planning->maps; } + // A route run without maps (a replay's) keeps none through its gates. void read_gates(){ + if (m_planning == nullptr || m_planning->maps == nullptr){ + return; + } m_resolved = has_gates(*m_planning->maps) ? std::optional(resolve_maps(*m_planning->maps, m_gates)) : std::nullopt; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index 06e4227675..f53a33d5c5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -396,6 +396,9 @@ class GatedStepModel{ bool held_at(const State& state, Direction direction, const Pokemon::GateState& gates) const{ return StepModel(m_maps.at(gates), m_costs).held_at(state, direction); } + int open_stop_risk(const State& state, Direction direction, const Pokemon::GateState& gates) const{ + return StepModel(m_maps.at(gates), m_costs).open_stop_risk(state, direction); + } Pokemon::MapPlace place_of(const State& state) const{ return Pokemon::MapPlace{(size_t)state.map, state.state.position}; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index 0b872f1210..7c32079720 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -148,6 +148,7 @@ OverworldSim::OverworldSim(std::vector maps, MapPosition start, Directi } add_coded_field(); m_state.gates = m_script.gates; + m_state.card_key_held = m_script.card_key_held; read_gates(); m_player = PlayerState{start.point, elevation_at(map(), start.point), false}; m_state.facing = facing; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h index 67c2b03df7..e3b5dce530 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h @@ -176,6 +176,9 @@ class OverworldSim{ bool push_poster_switch(); // SimField::PUSH_BOULDER. (PokemonFRLG_OverworldSimField.cpp) bool push_boulder(); + // A boulder fell through `hole`: the boulder the game hid on the floor + // below (a pushable_boulder with a hide_flag) is shown. + void land_fallen_boulder(const MapPosition& hole); bool start_surf(); // A on the gate or the statue the player faces; false, as a violation, // if there is none or the Card Key is missing. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp index cc3b4a836d..5da96d0c67 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimField.cpp @@ -14,6 +14,7 @@ #include "PokemonFRLG_CodedRooms.h" #include "PokemonFRLG_FlyMap.h" #include "PokemonFRLG_OverworldGatedRoute.h" +#include "PokemonFRLG_OverworldMaps.h" #include "PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_OverworldSimField.h" #include "PokemonFRLG_OverworldWalk.h" @@ -119,6 +120,40 @@ bool OverworldSim::cut_tree(){ return false; } +namespace{ + +// The map named `name` in `maps`, or nullptr. +template +auto* map_named_in(Maps& maps, const std::string& name){ + const auto found = std::find_if(maps.begin(), maps.end(), [&](const MapData& map){ return map.name == name; }); + return found == maps.end() ? nullptr : &*found; +} + +} // namespace + +void OverworldSim::land_fallen_boulder(const MapPosition& hole){ + const MapData* from = map_named_in(m_maps, hole.map); + const MapWarp* warp = from == nullptr ? nullptr : warp_at(*from, hole.point); + if (warp == nullptr || !warp->to){ + return; + } + static const std::vector ALL = overworld_maps(); + const MapData* below = map_named_in(ALL, warp->to->map); + MapData* shown = map_named_in(m_maps, warp->to->map); + if (below == nullptr || shown == nullptr){ + return; + } + for (const MapObject& object : below->objects){ + const bool hidden = object.name == "pushable_boulder" && object.hide_flag && std::none_of( + shown->objects.begin(), shown->objects.end(), [&](const MapObject& item){ return item.x == object.x && item.y == object.y; } + ); + if (hidden){ + shown->objects.push_back(object); + note("the boulder lands on " + to_string(MapPosition{shown->name, TilePos{object.x, object.y}}) + "."); + } + } +} + bool OverworldSim::push_boulder(){ std::vector& objects = m_maps[m_map].objects; const TilePos ahead = m_player.position.next(m_state.facing); @@ -129,6 +164,18 @@ bool OverworldSim::push_boulder(){ violation("no boulder " + std::string(direction_name(m_state.facing)) + " of " + to_string(m_state.position) + "."); return false; } + // A boulder pushed onto a hole falls through it to the floor below, + // where the game shows the boulder it hid until then (Victory Road + // 3F's (34, 18): 2F's (33, 19), FLAG_HIDE_VICTORY_ROAD_2F_BOULDER). + const TilePos into = ahead.next(m_state.facing); + if (map().tiles.contains(into) && map().tiles.at(into) == TileKind::FALL_HOLE){ + const MapPosition hole{map().name, into}; + objects.erase(boulder); + advance_to(m_now + PUSH_TIME); + note("pushed the boulder into the hole at " + to_string(hole) + "."); + land_fallen_boulder(hole); + return true; + } // The boulder moves where a player on its tile could step. const PlayerState on_boulder{ahead, elevation_at(map(), ahead), false}; if (classify_step(map(), on_boulder, m_state.facing) != StepKind::WALK){ @@ -140,6 +187,16 @@ bool OverworldSim::push_boulder(){ boulder->y = beyond.y; advance_to(m_now + PUSH_TIME); note("pushed the boulder to " + to_string(MapPosition{map().name, beyond}) + "."); + // A boulder on a floor switch's button turns it on for good (Victory + // Road's floors: the switch's flag, then the barrier redrawn). + const Pokemon::MapSwitch* pressed = m_state.gate_maps.empty() + ? nullptr + : Pokemon::switch_with_button(m_state.gate_maps[m_map], beyond); + if (pressed != nullptr){ + m_state.gates.switches_on.insert(Pokemon::switch_key(*pressed)); + read_gates(); + note(std::format("switch {} is on.", Pokemon::switch_key(*pressed))); + } return true; } @@ -175,22 +232,22 @@ bool OverworldSim::start_surf(){ void OverworldSim::read_gates(){ // Only the tiles: the objects the sim has changed stay as they are. // Maps without a gate were not copied. - if (m_source_maps.empty() && has_gates(m_maps)){ - m_source_maps = m_maps; + if (m_state.gate_maps.empty() && has_gates(m_maps)){ + m_state.gate_maps = m_maps; } - for (size_t c = 0; c < m_source_maps.size(); c++){ - if (!m_source_maps[c].gates.empty()){ - m_maps[c].tiles = Pokemon::resolve_tiles(m_source_maps[c], m_state.gates); + for (size_t c = 0; c < m_state.gate_maps.size(); c++){ + if (!m_state.gate_maps[c].gates.empty()){ + m_maps[c].tiles = Pokemon::resolve_tiles(m_state.gate_maps[c], m_state.gates); } } } bool OverworldSim::open_gate(){ - if (m_source_maps.empty()){ + if (m_state.gate_maps.empty()){ violation("no gates on the maps."); return false; } - const MapData& source = m_source_maps[m_map]; + const MapData& source = m_state.gate_maps[m_map]; const Pokemon::MapGate* gate = Pokemon::closed_card_key_gate_faced(source, m_player.position, m_state.facing, m_state.gates); if (gate == nullptr || !m_script.card_key_held || m_state.screen != SimScreen::OVERWORLD || m_frozen){ violation(std::format( @@ -208,20 +265,21 @@ bool OverworldSim::open_gate(){ } bool OverworldSim::press_switch(){ - const Pokemon::MapSwitch* pressed = m_source_maps.empty() + const Pokemon::MapSwitch* pressed = m_state.gate_maps.empty() ? nullptr - : Pokemon::switch_pressed(m_source_maps[m_map], m_player.position, m_state.facing); + : Pokemon::switch_pressed(m_state.gate_maps[m_map], m_player.position, m_state.facing); if (pressed == nullptr || m_state.screen != SimScreen::OVERWORLD || m_frozen){ violation(std::format("no statue to press {} of {}.", direction_name(m_state.facing), to_string(m_state.position))); return false; } // The prompt, YES, and the text after it. advance_to(m_now + m_script.timing.message); - const bool now_on = pressed->toggle ? !m_state.gates.switch_on(pressed->id) : true; + const std::string key = Pokemon::switch_key(*pressed); + const bool now_on = pressed->toggle ? !m_state.gates.switch_on(key) : true; if (now_on){ - m_state.gates.switches_on.insert(pressed->id); + m_state.gates.switches_on.insert(key); }else{ - m_state.gates.switches_on.erase(pressed->id); + m_state.gates.switches_on.erase(key); } read_gates(); note(std::format("switch {} is {}.", pressed->id, now_on ? "on" : "off")); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h index 765d00794c..4192bdff38 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSimState.h @@ -139,6 +139,11 @@ struct SimState{ // The gates open and the switches on (SimScript::gates, then what the // player opened and pressed). Pokemon::GateState gates; + // The maps as loaded, with each gate closed or open as the map says, to + // plan through the gates (resolve_maps()); empty if no map has a gate. + std::vector gate_maps; + // Whether the player holds the Card Key (SimScript::card_key_held). + bool card_key_held = false; Direction facing = Direction::SOUTH; SimScreen screen = SimScreen::OVERWORLD; // Whether black shows below the map: the player stands near the bottom diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 21fd494009..d0bb5f07a5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -58,6 +58,8 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows12_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows14_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows15_Tests.h" +#include "Overworld/PokemonFRLG_OverworldGateMaps_Tests.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows13_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows16_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h" @@ -123,6 +125,8 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryViridian(database); add_tests_AutoStoryVictoryRoad(database); add_tests_AutoStoryBoulders(database); + add_tests_AutoStoryGates(database); + add_tests_OverworldGateMaps(database); } void add_tests(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp new file mode 100644 index 0000000000..da8b987a4b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp @@ -0,0 +1,45 @@ +/* AutoStory Boulders + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Pokemon/AutoStory/Pokemon_StoryActions.h" +#include "Pokemon/Navigation/Pokemon_GateTiles.h" +#include "PokemonFRLG_AutoStoryBoulders.h" +#include "PokemonFRLG_AutoStoryPoses.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +Pokemon::Outcome boulder_pushed(Pokemon::RunState& state, const StoryStep& step, const std::vector& maps){ + const std::optional here = story_pose(state.pose); + if (!here){ + return Pokemon::outcome_failed("no_pose", Pokemon::to_string(state.pose)); + } + const Direction direction = Pokemon::story_arg(step.args, "direction"); + const int64_t tiles = Pokemon::story_arg(step.args, "tiles"); + StoryPose at{here->map, here->tile, direction}; + for (int64_t c = 0; c < tiles; c++){ + at.tile = at.tile.next(direction); + } + // The boulder stands a tile ahead; on a floor switch's button, the + // switch is on for good and its barrier open. + const auto map = std::find_if(maps.begin(), maps.end(), [&](const MapData& item){ + return item.name == at.map; + }); + const Pokemon::MapSwitch* pressed = map == maps.end() ? nullptr : Pokemon::switch_with_button(*map, at.tile.next(direction)); + if (pressed != nullptr){ + state.gates.switches_on.insert(Pokemon::switch_key(*pressed)); + } + return Pokemon::outcome_ok(to_pose(at)); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h new file mode 100644 index 0000000000..b38ae15080 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h @@ -0,0 +1,34 @@ +/* AutoStory Boulders + * + * From: https://github.com/PokemonAutomation/ + * + * What a Strength boulder push does to the story's state, for the + * console's push_boulder step and the map-level sim alike. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryBoulders_H +#define PokemonAutomation_PokemonFRLG_AutoStoryBoulders_H + +#include +#include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" +#include "Pokemon/AutoStory/Pokemon_StoryPose.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" +#include "PokemonFRLG_AutoStoryCheckpoints.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Where a PUSH_BOULDER_VARIANT step leaves the player: `tiles` tiles on in +// its direction, behind the boulder. A boulder that ends on a floor +// switch's button turns that switch on in `state.gates`. +Pokemon::Outcome boulder_pushed(Pokemon::RunState& state, const StoryStep& step, const std::vector& maps); + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp index f19ebd507f..f4145e34ee 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp @@ -6,12 +6,9 @@ * (Pokemon_BoulderSolver below), and the sim's PUSH_BOULDER, which the * search's answer is replayed on. * - * TODO(map edit, needs the user's OK): the Victory Road maps have the - * boulders (objects named "pushable_boulder") but not the switches' - * barriers or which tiles the switches press, so the planner walks - * through the barriers. The data below is from the decompilation - * (pokefirered data/maps/VictoryRoad_*), kept here until the maps carry - * it as `gates` and `switches`; then this search reads them from the map. + * The maps carry each floor's barriers as `gates` and its switch's + * button (PokemonSimulation 1cacf81); the puzzle below repeats 1F's for + * the search. Rows 19.04b to 19.04d play the search's answers. * */ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 0e9dfabf3c..fea4d35119 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -27,6 +27,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryBattlePolicy.h" +#include "PokemonFRLG_AutoStoryBoulders.h" #include "PokemonFRLG_AutoStoryGameArgs.h" #include "PokemonFRLG_AutoStoryHealingSteps.h" #include "PokemonFRLG_AutoStoryHideout.h" @@ -365,6 +366,7 @@ std::string save_card_place(const std::string& map){ {"Route25", "route-25"}, {"Route22", "route-22"}, {"Route23", "route-23"}, + {"VictoryRoad", "victory-road"}, {"VermilionCity", "vermilion-city"}, {"Route10", "route-10"}, {"LavenderTown", "lavender-town"}, @@ -632,12 +634,10 @@ Outcome push_boulder(StoryEnv& env, RunState& state, const StoryStep& step){ answer_yes_no(env.console, env.context, true, BUTTON_B, YES_NO_TIMEOUT); mash_until_overworld(env.console, env.context, SCENE_TIMEOUT); } - StoryPose at = *here; for (int64_t c = 0; c < tiles; c++){ step_once(env.console, env.context, direction, direction, env.player_gender); - at = StoryPose{at.map, at.tile.next(direction), direction}; } - return Pokemon::outcome_ok(to_pose(at)); + return boulder_pushed(state, step, story_maps()); } // Vermilion Gym's trash cans on the console: a walk to each can's stand diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp index 91f276348a..54ab37176b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -199,8 +199,9 @@ bool sim_plays(const StoryStep& step){ case StoryStepKind::GAME: // A Fly lands on its town's landing tile, as the sim plays it; a // lift's warp lets out on its floor's tile (sweep_maps()' lift - // rooms, with_lifts()). - return step.action == CUT_TREE_VARIANT || is_field_move_step(step) || parse_lift_floor_step(step).has_value(); + // rooms, with_lifts()). A boulder's push leaves the player behind + // it, as the sim plays it. + return step.action == CUT_TREE_VARIANT || step.action == PUSH_BOULDER_VARIANT || is_field_move_step(step) || parse_lift_floor_step(step).has_value(); default: return false; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.cpp new file mode 100644 index 0000000000..faf10ba2a6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.cpp @@ -0,0 +1,439 @@ +/* AutoStory Gates Tests + * + * From: https://github.com/PokemonAutomation/ + * + * A ROUTE step on the row sims with gates: StoryMapsSim (the whole story + * on maps) and OverworldStepSim (a row's steps on the OverworldSim) stop at + * a closed Silph Co. card-key door, open it for a player with the Card Key + * and keep the gate state, and press a Pokemon Mansion statue for the + * barrier its switch opens. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_StoryPose.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryGates_Tests.h" +#include "PokemonFRLG_AutoStoryPoses.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_StoryReplay.h" +#include "PokemonFRLG_StoryReplay_IO.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +namespace{ + +struct GatesInput{ + std::string name; + std::function body; +}; +struct GatesExpectation{ +}; +struct GatesCase{ + GatesInput input; + GatesExpectation expectation; +}; + +class Test_AutoStoryGates : public UnitTest{ +public: + explicit Test_AutoStoryGates(GatesCase test_case) + : UnitTest("PokemonFRLG::AutoStoryGates - " + test_case.input.name) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + return m_case.input.body(); + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } + +private: + GatesCase m_case; +}; + +// A walk across a gate on the real maps: Silph Co. 5F's card-key door, and +// the Pokemon Mansion 1F's barrier behind its statue's switch. +struct Scene{ + std::string_view map; + TilePos start; + TilePos goal; +}; +constexpr Scene DOOR{"SilphCo_5F", {10, 9}, {5, 9}}; +constexpr Scene STATUE{"PokemonMansion_1F", {5, 8}, {19, 13}}; + +const std::vector& scene_maps(){ + static const std::vector MAPS = overworld_maps(); + return MAPS; +} + +StoryStep route_step(const std::string& map, TilePos goal){ + StoryStep step; + step.kind = StoryStepKind::ROUTE; + step.name = "cross"; + step.args["target"] = Pokemon::GridPose{map, {goal}, std::nullopt}; + return step; +} + +Pokemon::RunState run_state(const Scene& scene, bool card_key){ + Pokemon::RunState state; + state.pose = to_pose(StoryPose{std::string(scene.map), scene.start, Direction::EAST}); + if (card_key){ + state.flags.insert("card_key_held"); + } + return state; +} + +// The step on StoryMapsSim over `maps`, from the start of the corridor. +Pokemon::Outcome on_maps(const Scene& scene, bool card_key, Pokemon::RunState& state){ + StorySimKnobs knobs; + knobs.maps = &scene_maps(); + StoryMapsSim sim(knobs); + state = run_state(scene, card_key); + return sim.run(route_step(std::string(scene.map), scene.goal), state); +} + + +// A closed door stops a player without the Card Key: the story's sim does +// not walk through gates the run has not opened. +UnitTestResult test_maps_sim_door_blocks(){ + Pokemon::RunState state; + const Pokemon::Outcome outcome = on_maps(DOOR, false, state); + if (outcome.succeeded()){ + return "The row sim walked through a closed card-key door without the Card Key."; + } + return true; +} + +UnitTestResult test_maps_sim_door_opens(){ + Pokemon::RunState state; + const Pokemon::Outcome outcome = on_maps(DOOR, true, state); + if (!outcome.succeeded()){ + return "The row sim did not open the door for a player with the Card Key: " + Pokemon::to_string(outcome); + } + if (!state.gates.opened.contains("SilphCo_5F/door_1")){ + return "The run's gates do not have the door open after the step."; + } + return true; +} + +UnitTestResult test_maps_sim_statue_switch(){ + Pokemon::RunState state; + const Pokemon::Outcome outcome = on_maps(STATUE, false, state); + if (!outcome.succeeded()){ + return "The row sim did not press the statue for the barrier: " + Pokemon::to_string(outcome); + } + if (!state.gates.switch_on("mansion")){ + return "The run's gates do not have the switch on after the step."; + } + return true; +} + +struct GateStateOut{ + Pokemon::GateState gates; + MapPosition position; +}; + +// The step on OverworldStepSim and its OverworldSim, with the Card Key as `card_key`. +std::string on_overworld_sim(const Scene& scene, bool card_key, GateStateOut& out){ + SimScript script; + script.card_key_held = card_key; + OverworldSim sim(scene_maps(), MapPosition{std::string(scene.map), scene.start}, Direction::EAST, script); + StoryPose at{std::string(scene.map), scene.start, Direction::EAST}; + const std::string failure = row_step_on_sim(sim, at, route_step(std::string(scene.map), scene.goal), "test"); + out.gates = sim.state().gates; + out.position = sim.state().position; + return failure; +} + +UnitTestResult test_step_sim_door_blocks(){ + GateStateOut out; + if (on_overworld_sim(DOOR, false, out).empty()){ + return "The step walked through a closed card-key door without the Card Key."; + } + return true; +} + +UnitTestResult test_step_sim_door_opens(){ + GateStateOut out; + const std::string failure = on_overworld_sim(DOOR, true, out); + if (!failure.empty()){ + return "The step did not open the door for a player with the Card Key: " + failure; + } + if (!out.gates.opened.contains("SilphCo_5F/door_1") || !(out.position == MapPosition{std::string(DOOR.map), DOOR.goal})){ + return "Expected the door open and the player at the goal, ended at " + to_string(out.position); + } + return true; +} + +UnitTestResult test_step_sim_statue_switch(){ + GateStateOut out; + const std::string failure = on_overworld_sim(STATUE, false, out); + if (!failure.empty()){ + return "The step did not press the statue: " + failure; + } + if (!out.gates.switch_on("mansion") || !(out.position == MapPosition{std::string(STATUE.map), STATUE.goal})){ + return "Expected the switch on and the player at the goal, ended at " + to_string(out.position); + } + return true; +} + +// A recorded route replayed on the real maps: the native planner's route +// through the gate as the replay's supplied commands (what a recording of +// the walk holds), replayed by the story engine on the pinned maps with the +// run's flags (the Card Key) and the gates the route's commands change. +constexpr std::string_view REVISION = "0123456789abcdef0123456789abcdef01234567"; +constexpr std::string_view CHECKPOINT_ID = "99.01"; + +const MapData& scene_map(const Scene& scene){ + for (const MapData& map : scene_maps()){ + if (map.name == scene.map){ + return map; + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Unknown scene map."); +} + +JsonObject tile_json(const Scene& scene, TilePos tile, std::string_view facing){ + JsonArray pair; + pair.push_back(tile.x); + pair.push_back(tile.y); + JsonArray tiles; + tiles.push_back(std::move(pair)); + JsonObject where; + where["kind"] = "tiles"; + where["tiles"] = std::move(tiles); + where["facing"] = std::string(facing); + JsonObject pose; + pose["certainty"] = "tile"; + pose["map"] = std::string(scene.map); + pose["where"] = std::move(where); + return pose; +} + +// The planned route as supplied commands: walks, turns, and the gate's A press. +JsonArray recorded_commands(const Scene& scene, const std::vector& route){ + JsonArray commands; + for (const RouteStep& step : route){ + JsonObject command; + command["event"] = "cross"; + command["map"] = std::string(scene.map); + command["direction"] = std::string(direction_name(step.direction)); + switch (step.action){ + case RouteAction::WALK: + command["kind"] = "walk"; + command["tiles"] = step.tiles; + break; + case RouteAction::FACE: + command["kind"] = "turn"; + break; + case RouteAction::OPEN_GATE: + command["kind"] = "open_gate"; + break; + case RouteAction::PRESS_SWITCH: + command["kind"] = "press_switch"; + break; + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "The scene's route has a step the replay does not take."); + } + commands.push_back(std::move(command)); + } + return commands; +} + +// The capture of the scene's checkpoint: one route across it, to `facing_after`. +std::string capture_text(const Scene& scene, Direction facing_after){ + JsonObject target = tile_json(scene, scene.goal, direction_name(facing_after)); + JsonObject event; + event["id"] = "cross"; + event["kind"] = "route"; + event["target"] = std::move(target); + event["why"] = "across the gate"; + JsonArray events; + events.push_back(std::move(event)); + JsonObject checkpoint; + checkpoint["id"] = std::string(CHECKPOINT_ID); + checkpoint["title"] = "Gate replay"; + checkpoint["start"] = tile_json(scene, scene.start, "east"); + checkpoint["events"] = std::move(events); + JsonObject capture; + capture["format"] = "pokesim-native-checkpoint-export/1"; + capture["game"] = "frlg"; + capture["checkpoint"] = std::move(checkpoint); + capture["source_revision"] = std::string(REVISION); + capture["unbound"] = JsonArray(); + return capture.dump(-1); +} + +// The binding of that capture to the scene's map, as the replay pins it. +std::string binding_text(const Scene& scene, const std::string& capture){ + std::string map_hash; + for (const auto& [name, text] : overworld_map_json()){ + if (name == scene.map){ + map_hash = StoryReplayInternal::digest(text); + } + } + JsonObject capture_pin; + capture_pin["file"] = "gate-replay.json"; + capture_pin["sha256"] = StoryReplayInternal::digest(capture); + capture_pin["source_revision"] = std::string(REVISION); + JsonObject maps; + maps[std::string(scene.map)] = map_hash; + JsonObject capability; + capability["capability"] = "frlg-runtime-route/1"; + capability["parameters"] = JsonObject(); + JsonObject capabilities; + capabilities["cross"] = std::move(capability); + JsonObject costs; + costs["tile"] = 1; + costs["turn"] = 2; + costs["grass"] = 5; + costs["warp"] = 1; + JsonObject policy; + policy["basis"] = "synthetic-offline-policy"; + policy["entry"] = "scripted-observation"; + policy["attempts"] = 1; + policy["failure"] = "stop"; + policy["save"] = "never"; + JsonObject binding; + binding["format"] = "pokesim-story-replay-binding/1"; + binding["capture"] = std::move(capture_pin); + binding["map_revision"] = std::string(REVISION); + binding["maps"] = std::move(maps); + binding["capabilities"] = std::move(capabilities); + binding["costs"] = std::move(costs); + binding["max_route_moves"] = 256; + binding["policy"] = std::move(policy); + return binding.dump(-1); +} + +// The scenario: the player on the scene's start, with the Card Key if `card_key`. +JsonValue scenario_json(const Scene& scene, bool card_key){ + JsonObject entry_pose; + entry_pose["map"] = std::string(scene.map); + JsonArray tile; + tile.push_back(scene.start.x); + tile.push_back(scene.start.y); + entry_pose["tile"] = std::move(tile); + entry_pose["facing"] = "east"; + entry_pose["elevation"] = elevation_at(scene_map(scene), scene.start); + JsonObject entry; + entry["basis"] = "scripted"; + entry["screen"] = "overworld"; + entry["pose"] = std::move(entry_pose); + JsonObject scenario; + scenario["entry"] = std::move(entry); + scenario["signals"] = JsonObject(); + JsonArray flags; + if (card_key){ + flags.push_back("card_key_held"); + } + scenario["start_flags"] = std::move(flags); + return scenario; +} + +// The scene's checkpoint replayed with the route recorded for a player who has the +// Card Key, for a run that has it if `card_key`. Throws what the replay rejects. +JsonValue replay_scene(const Scene& scene, bool card_key){ + const std::optional> route = plan_overworld_route_gated( + scene_maps(), MapPosition{std::string(scene.map), scene.start}, RouteGoal{MapPosition{std::string(scene.map), scene.goal}, std::nullopt}, + Pokemon::GateState(), Pokemon::GateRules{.card_key_held = true}, default_route_costs(), Direction::EAST + ); + if (!route){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "No route across the scene to record."); + } + const std::string capture = capture_text(scene, route->back().direction); + const std::string binding = binding_text(scene, capture); + JsonObject routes; + routes["cross"] = recorded_commands(scene, *route); + JsonObject candidate; + candidate["format"] = "pokesim-route-candidate/1"; + candidate["binding_sha256"] = StoryReplayInternal::digest(binding); + candidate["checkpoint"] = std::string(CHECKPOINT_ID); + candidate["routes"] = std::move(routes); + return replay_story_checkpoint(capture, binding, candidate.dump(-1), scenario_json(scene, card_key)); +} + +// The replay completed the checkpoint and its actions have `kind` (the gate's command). +std::string completed_with(const JsonValue& report, std::string_view kind){ + const JsonObject& root = report.to_object_throw(); + if (root.get_string_throw("status") != "model_complete"){ + return std::format("The replay stopped: {}", report.dump(-1)); + } + for (const JsonValue& action : root.get_array_throw("actions")){ + if (action.to_object_throw().get_string_throw("kind") == kind){ + return ""; + } + } + return std::format("The replay's actions have no {}.", kind); +} + +UnitTestResult test_replay_door_with_card_key(){ + const std::string failure = completed_with(replay_scene(DOOR, true), "open_gate"); + if (!failure.empty()){ + return failure; + } + return true; +} + +// The recording was made with the Card Key; the run's scenario has none. +UnitTestResult test_replay_door_without_card_key(){ + try{ + const std::string failure = completed_with(replay_scene(DOOR, false), "open_gate"); + if (failure.empty()){ + return "The replay opened a card-key door for a run without the Card Key."; + } + }catch (const ParseException& e){ + if (e.message().find("card-key") == std::string::npos){ + return std::format("Unexpected rejection: {}", e.message()); + } + } + return true; +} + +UnitTestResult test_replay_statue_switch(){ + const std::string failure = completed_with(replay_scene(STATUE, false), "press_switch"); + if (!failure.empty()){ + return failure; + } + return true; +} + +const std::vector GATES_CASES{ + {.input = {.name = "story maps: a closed door blocks without the Card Key", .body = test_maps_sim_door_blocks}, .expectation = {}}, + {.input = {.name = "story maps: the door opens with the Card Key and stays open", .body = test_maps_sim_door_opens}, .expectation = {}}, + {.input = {.name = "story maps: the statue's switch opens its barrier", .body = test_maps_sim_statue_switch}, .expectation = {}}, + {.input = {.name = "overworld sim: a closed door blocks without the Card Key", .body = test_step_sim_door_blocks}, .expectation = {}}, + {.input = {.name = "overworld sim: the door opens with the Card Key", .body = test_step_sim_door_opens}, .expectation = {}}, + {.input = {.name = "overworld sim: the statue's switch opens its barrier", .body = test_step_sim_statue_switch}, .expectation = {}}, + {.input = {.name = "replay: a recorded route opens Silph Co.'s card-key door", .body = test_replay_door_with_card_key}, .expectation = {}}, + {.input = {.name = "replay: the recorded door stays shut without the Card Key", .body = test_replay_door_without_card_key}, .expectation = {}}, + {.input = {.name = "replay: a recorded route presses the Mansion's statue", .body = test_replay_statue_switch}, .expectation = {}}, +}; + +} // namespace + + +void add_tests_AutoStoryGates(UnitTestDatabase& database){ + for (const GatesCase& item : GATES_CASES){ + database.add(item); + } +} + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h new file mode 100644 index 0000000000..e329fe4ede --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h @@ -0,0 +1,27 @@ +/* AutoStory Gates Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the tests of the story's sims with gates: a Silph Co. + * card-key door and a Pokemon Mansion statue switch on the row sim. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryGates_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryGates_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// StoryMapsSim and OverworldStepSim honoring gates (PokemonFRLG_AutoStoryGates_Tests.cpp). +void add_tests_AutoStoryGates(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp index 01aeb65a89..8679139cba 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp @@ -4,8 +4,9 @@ * * Rows 13.01 to 13.04 (StoryData/frlg-13.0N.plan.json) on the overworld * sim: Cinnabar's Center to the Pokemon Mansion's statue switches, the - * SECRET KEY and the Escape Rope out. The sim has the map's switch state - * (flag clear), so a step through a barrier the switches open is declared. + * SECRET KEY and the Escape Rope out. The sim reads the real maps through + * the switch's state, from the checkpoint's start_gates, and the routes + * press the statues themselves. * */ @@ -90,72 +91,27 @@ struct MansionRow{ std::vector floors; }; -// A step over a tile the switches open: the pack's maps are the clear -// state, where it is a wall, so the sim cannot walk it and the step's -// declared pose stands. `wall` is whether the tile it lands on is such a -// barrier on the map; the step after it, onto floor, is declared too. -struct SwitchStep{ - std::string_view row; - std::string_view step; - bool wall; -}; - -const SwitchStep SWITCH_STEPS[] = { - {"13.02", "into_opening_1", true}, - {"13.02", "into_opening_2", true}, - {"13.02", "through_opening", false}, - {"13.03", "into_room_2", true}, - {"13.03", "into_room_3", true}, - {"13.04", "into_opening", true}, - {"13.04", "through_opening", false}, -}; - -const SwitchStep* switch_step(std::string_view row, std::string_view step){ - for (const SwitchStep& item : SWITCH_STEPS){ - if (item.row == row && item.step == step){ - return &item; - } - } - return nullptr; -} - -bool map_wall(const MapPosition& at){ - for (const MapData& map : story_maps()){ - if (map.name == at.map){ - return map.tiles.at(at.point) == TileKind::WALL; - } - } - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No map {}.", at.map)); -} - -// A row on the sim from its start: every step lands (a switch step on its -// declared pose, on a barrier that is a wall on the map), the row ends on -// its postcondition's tile after the floors it should cross, and nobody but Lewis is met and no rule is broken on the way (checked -// after each step). +// A row on the sim from its start, through the gates it has on a save +// (start_gates): every step lands (a route presses the statues it needs), +// the row ends on its postcondition's tile after the floors it should +// cross, the switch is as its last step says, and nobody but Lewis is met +// and no rule is broken on the way (checked after each step). UnitTestResult test_row(const MansionRow& expected){ const StoryCheckpoint& row = checkpoint(expected.id); StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); + SimScript script; + script.gates = row.start_gates.value_or(Pokemon::GateState()); std::optional sim; - sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing, script); std::vector floors; for (const StoryStep& step : row.steps){ - if (const SwitchStep* barrier = switch_step(row.id, step.name)){ - at = *story_pose(Pokemon::pose_of(*step.pose_after)); - if (map_wall(MapPosition{at.map, at.tile}) != barrier->wall){ - return std::format("{}/{}: expected {} on {}.", row.id, step.name, barrier->wall ? "a barrier" : "floor", to_string(MapPosition{at.map, at.tile})); - } - sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing); - }else if (step.name == "escape_rope"){ + if (step.name == "escape_rope"){ // The rope's script has no map: the player stands where it says. at = *story_pose(Pokemon::pose_of(*step.pose_after)); - sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing, script); }else if (const std::string failure = row_step_on_sim(*sim, at, step, row.id); !failure.empty()){ return std::format("{}: ended on {}; {}", row.id, to_string(sim->state().position), failure); } - if (step.name == "down_the_hole"){ - // The hole's fade: a declared step does not wait it out, a walk does. - sim->watch({}, OverworldWalkSteps::AFTER_WARP); - } if (!sim->state().violations.empty()){ return std::format("{}/{}: broke a rule on the way, on {}: {}.", row.id, step.name, to_string(sim->state().position), sim->state().violations.front()); } @@ -167,6 +123,9 @@ UnitTestResult test_row(const MansionRow& expected){ if (floors.empty() || floors.back() != at.map){ floors.push_back(at.map); } + if (step.name != "escape_rope"){ + script.gates = sim->state().gates; + } } if (!(MapPosition{at.map, at.tile} == expected.end)){ return std::format("{}: ended on {}, not {}.", row.id, to_string(MapPosition{at.map, at.tile}), to_string(expected.end)); @@ -181,31 +140,31 @@ UnitTestResult test_row(const MansionRow& expected){ return true; } -const MansionRow ROW_13_01{"13.01", {"PokemonMansion_3F", {12, 6}}, +const MansionRow ROW_13_01{"13.01", {"PokemonMansion_3F", {19, 13}}, {"PokemonMansion_3F"}}; const MansionRow ROW_13_02{"13.02", {"PokemonMansion_B1F", {34, 29}}, - {"PokemonMansion_3F", "PokemonMansion_1F", "PokemonMansion_B1F"}}; -const MansionRow ROW_13_03{"13.03", {"PokemonMansion_B1F", {27, 6}}, + {"PokemonMansion_1F", "PokemonMansion_B1F"}}; +const MansionRow ROW_13_03{"13.03", {"PokemonMansion_B1F", {23, 5}}, {"PokemonMansion_B1F"}}; const MansionRow ROW_13_04{"13.04", {"CinnabarIsland", {8, 4}}, {"PokemonMansion_B1F", "CinnabarIsland"}}; const AutoStoryMansionCase AUTO_STORY_MANSION_CASES[] = { { - .input = {.name = "13.01 Cinnabar to the Mansion's 3F statue", .body = []{ return test_row(ROW_13_01); }}, - .expectation = {.description = "through 1F and 2F to 3F's (12, 6), nobody met"}, + .input = {.name = "13.01 Cinnabar to the Mansion's 3F room of holes", .body = []{ return test_row(ROW_13_01); }}, + .expectation = {.description = "through 1F and 2F to 3F's (19, 13) by a statue press, nobody met"}, }, { - .input = {.name = "13.02 3F's opening, the hole, 1F's stairs", .body = []{ return test_row(ROW_13_02); }}, - .expectation = {.description = "through the declared opening and the hole to B1F's (34, 29)"}, + .input = {.name = "13.02 3F's hole, 1F's stairs", .body = []{ return test_row(ROW_13_02); }}, + .expectation = {.description = "through the hole and the stairs to B1F's (34, 29)"}, }, { - .input = {.name = "13.03 B1F's two statues, the Elixir and TM14", .body = []{ return test_row(ROW_13_03); }}, - .expectation = {.description = "through the declared opening to (27, 6), nobody but Lewis met"}, + .input = {.name = "13.03 B1F's Elixir and TM14", .body = []{ return test_row(ROW_13_03); }}, + .expectation = {.description = "by a statue press to the Elixir and TM14, nobody but Lewis met"}, }, { .input = {.name = "13.04 the SECRET KEY and the Escape Rope", .body = []{ return test_row(ROW_13_04); }}, - .expectation = {.description = "through the declared opening to the key, out by the rope to (8, 4)"}, + .expectation = {.description = "by a statue press to the key, out by the rope to (8, 4)"}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden13.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden13.h index 8f249b0c04..57e3a4717b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden13.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden13.h @@ -18,7 +18,7 @@ namespace PokemonFRLG{ // The stored plan lines of segment 13, after FRLG_PLAN_GOLDEN_16's. inline constexpr std::string_view FRLG_PLAN_GOLDEN_13[] = { - "13.01 mansion_3f from CinnabarIsland_PokemonCenter_1F (7, 4) facing north to PokemonMansion_3F (8, 3) facing east", + "13.01 mansion_holes from CinnabarIsland_PokemonCenter_1F (7, 4) facing north to PokemonMansion_3F (19, 13) facing south", "13.01 walk south 5 (warp) -> CinnabarIsland (14, 12) [walk only]", "13.01 walk east 7 -> CinnabarIsland (21, 12)", "13.01 walk north 7 (to wall) -> CinnabarIsland (21, 5)", @@ -32,8 +32,65 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_13[] = { "13.01 walk west 8 -> PokemonMansion_2F (9, 6) [wild]", "13.01 walk north 3 (to wall) -> PokemonMansion_2F (9, 3) [wild]", "13.01 walk east 1 (warp) -> PokemonMansion_3F (8, 3)", - "13.02 down_to_b1f from PokemonMansion_1F (26, 27) facing north to PokemonMansion_B1F (34, 29) facing west", - "13.02 walk west 2 (warp) -> PokemonMansion_B1F (34, 29)", + "13.01 walk south 3 -> PokemonMansion_3F (8, 6) [wild]", + "13.01 walk east 4 -> PokemonMansion_3F (12, 6) [wild]", + "13.01 press switch north -> PokemonMansion_3F (12, 6)", + "13.01 walk east 8 (to wall) -> PokemonMansion_3F (20, 6) [wild]", + "13.01 walk north 3 (to wall) -> PokemonMansion_3F (20, 3) [wild]", + "13.01 walk west 1 (to wall) -> PokemonMansion_3F (19, 3) [wild]", + "13.01 walk south 10 -> PokemonMansion_3F (19, 13) [wild]", + "13.02 to_ted_room from PokemonMansion_3F (19, 13) facing south to PokemonMansion_1F (17, 23) facing south", + "13.02 walk south 5 (warp) -> PokemonMansion_1F (20, 22) [wild]", + "13.02 walk west 3 (to wall) -> PokemonMansion_1F (17, 22) [wild]", + "13.02 walk south 1 -> PokemonMansion_1F (17, 23) [wild]", + "13.02 past_ted from PokemonMansion_1F (17, 23) facing south to PokemonMansion_1F (17, 25) facing south", + "13.02 walk south 2 -> PokemonMansion_1F (17, 25) [wild]", + "13.02 down_to_b1f from PokemonMansion_1F (17, 25) facing south to PokemonMansion_B1F (34, 29) facing west", + "13.02 walk south 8 (to wall) -> PokemonMansion_1F (17, 33) [wild]", + "13.02 walk east 13 (to wall) -> PokemonMansion_1F (30, 33) [wild]", + "13.02 walk north 6 (to wall) -> PokemonMansion_1F (30, 27) [wild]", + "13.02 walk west 6 (warp) -> PokemonMansion_B1F (34, 29) [wild]", + "13.03 to_elixir from PokemonMansion_B1F (34, 29) facing west to PokemonMansion_B1F (34, 5) facing east", + "13.03 walk west 7 (to wall) -> PokemonMansion_B1F (27, 29) [wild]", + "13.03 walk north 12 (to wall) -> PokemonMansion_B1F (27, 17) [wild]", + "13.03 walk west 5 -> PokemonMansion_B1F (22, 17) [wild]", + "13.03 walk south 9 (to wall) -> PokemonMansion_B1F (22, 26) [wild]", + "13.03 walk east 3 (to wall) -> PokemonMansion_B1F (25, 26) [wild]", + "13.03 walk south 5 (to wall) -> PokemonMansion_B1F (25, 31) [wild]", + "13.03 walk west 1 -> PokemonMansion_B1F (24, 31) [wild]", + "13.03 walk north 1 (to wall) -> PokemonMansion_B1F (24, 30) [wild]", + "13.03 press switch north -> PokemonMansion_B1F (24, 30)", + "13.03 walk west 9 -> PokemonMansion_B1F (15, 30) [wild]", + "13.03 walk north 13 (to wall) -> PokemonMansion_B1F (15, 17) [wild]", + "13.03 walk east 14 (to wall) -> PokemonMansion_B1F (29, 17) [wild]", + "13.03 walk south 5 -> PokemonMansion_B1F (29, 22) [wild]", + "13.03 walk east 4 -> PokemonMansion_B1F (33, 22) [wild]", + "13.03 walk north 17 -> PokemonMansion_B1F (33, 5) [wild]", + "13.03 walk east 1 -> PokemonMansion_B1F (34, 5) [wild]", + "13.03 to_tm14 from PokemonMansion_B1F (34, 5) facing east to PokemonMansion_B1F (23, 5) facing north", + "13.03 walk west 4 -> PokemonMansion_B1F (30, 5) [wild]", + "13.03 walk south 8 (to wall) -> PokemonMansion_B1F (30, 13) [wild]", + "13.03 walk west 11 -> PokemonMansion_B1F (19, 13) [wild]", + "13.03 walk north 10 (to wall) -> PokemonMansion_B1F (19, 3) [wild]", + "13.03 walk east 5 (to wall) -> PokemonMansion_B1F (24, 3) [wild]", + "13.03 walk south 2 (to wall) -> PokemonMansion_B1F (24, 5) [wild]", + "13.03 walk west 1 -> PokemonMansion_B1F (23, 5) [wild]", + "13.03 face north -> PokemonMansion_B1F (23, 5)", + "13.04 to_key from PokemonMansion_B1F (23, 5) facing north to PokemonMansion_B1F (5, 6) facing south", + "13.04 walk west 4 -> PokemonMansion_B1F (19, 5) [wild]", + "13.04 walk south 8 (to wall) -> PokemonMansion_B1F (19, 13) [wild]", + "13.04 walk east 11 -> PokemonMansion_B1F (30, 13) [wild]", + "13.04 walk north 10 (to wall) -> PokemonMansion_B1F (30, 3) [wild]", + "13.04 walk west 4 (to wall) -> PokemonMansion_B1F (26, 3) [wild]", + "13.04 walk south 3 (to wall) -> PokemonMansion_B1F (26, 6) [wild]", + "13.04 walk east 1 -> PokemonMansion_B1F (27, 6) [wild]", + "13.04 press switch north -> PokemonMansion_B1F (27, 6)", + "13.04 walk east 3 -> PokemonMansion_B1F (30, 6) [wild]", + "13.04 walk south 4 -> PokemonMansion_B1F (30, 10) [wild]", + "13.04 walk west 29 (to wall) -> PokemonMansion_B1F (1, 10) [wild]", + "13.04 walk north 4 -> PokemonMansion_B1F (1, 6) [wild]", + "13.04 walk east 4 -> PokemonMansion_B1F (5, 6) [wild]", + "13.04 face south -> PokemonMansion_B1F (5, 6)", }; } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h index 872c365fae..0dd3939443 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden19.h @@ -97,10 +97,186 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_19[] = { "19.03 walk north 6 -> Route23 (5, 36)", "19.03 victory_road_mouth from Route23 (5, 35) facing north to Route23 (5, 29) facing north", "19.03 walk north 6 -> Route23 (5, 29)", - "19.05 indigo_door from Route23 (18, 28) facing south to IndigoPlateau_Exterior (11, 7) facing north", - "19.05 walk south 4 (to wall) -> Route23 (18, 32)", - "19.05 walk east 3 (to wall) -> Route23 (21, 32)", - "19.05 walk north 14 -> Route23 (21, 18)", + "19.04b behind_boulder_1 from VictoryRoad_1F (11, 20) facing north to VictoryRoad_1F (7, 17)", + "19.04b walk west 3 (to wall) -> VictoryRoad_1F (8, 20) [wild]", + "19.04b walk north 1 (to wall) -> VictoryRoad_1F (8, 19) [wild]", + "19.04b walk west 2 -> VictoryRoad_1F (6, 19) [wild]", + "19.04b walk north 2 (to wall) -> VictoryRoad_1F (6, 17) [wild]", + "19.04b walk east 1 (to wall) -> VictoryRoad_1F (7, 17) [wild]", + "19.04b by_boulder_2_corner from VictoryRoad_1F (7, 18) facing south to VictoryRoad_1F (6, 18)", + "19.04b walk west 1 -> VictoryRoad_1F (6, 18) [wild]", + "19.04b behind_boulder_2 from VictoryRoad_1F (6, 18) facing west to VictoryRoad_1F (6, 19)", + "19.04b walk south 1 (to wall) -> VictoryRoad_1F (6, 19) [wild]", + "19.04b by_boulder_3_corner from VictoryRoad_1F (11, 19) facing east to VictoryRoad_1F (10, 20)", + "19.04b walk south 1 -> VictoryRoad_1F (11, 20)", + "19.04b walk west 1 -> VictoryRoad_1F (10, 20) [wild]", + "19.04b behind_boulder_3 from VictoryRoad_1F (10, 20) facing west to VictoryRoad_1F (12, 20)", + "19.04b walk east 2 (to wall) -> VictoryRoad_1F (12, 20) [wild]", + "19.04b by_boulder_4_corner from VictoryRoad_1F (12, 18) facing north to VictoryRoad_1F (11, 18)", + "19.04b walk west 1 -> VictoryRoad_1F (11, 18) [wild]", + "19.04b behind_boulder_4 from VictoryRoad_1F (11, 18) facing west to VictoryRoad_1F (11, 17)", + "19.04b walk north 1 (to wall) -> VictoryRoad_1F (11, 17) [wild]", + "19.04b by_boulder_5_corner from VictoryRoad_1F (18, 17) facing east to VictoryRoad_1F (18, 18)", + "19.04b walk south 1 (to wall) -> VictoryRoad_1F (18, 18) [wild]", + "19.04b behind_boulder_5 from VictoryRoad_1F (18, 18) facing south to VictoryRoad_1F (19, 18)", + "19.04b walk east 1 (to wall) -> VictoryRoad_1F (19, 18) [wild]", + "19.04b by_boulder_6_corner from VictoryRoad_1F (19, 16) facing north to VictoryRoad_1F (20, 14)", + "19.04b walk east 1 (to wall) -> VictoryRoad_1F (20, 16)", + "19.04b walk north 2 (to wall) -> VictoryRoad_1F (20, 14) [wild]", + "19.04b by_boulder_6_top from VictoryRoad_1F (20, 14) facing north to VictoryRoad_1F (18, 14)", + "19.04b walk west 2 (to wall) -> VictoryRoad_1F (18, 14) [wild]", + "19.04b behind_boulder_6 from VictoryRoad_1F (18, 14) facing west to VictoryRoad_1F (18, 15)", + "19.04b walk south 1 (to wall) -> VictoryRoad_1F (18, 15) [wild]", + "19.04b by_boulder_7_corner from VictoryRoad_1F (19, 15) facing east to VictoryRoad_1F (19, 14)", + "19.04b walk north 1 (to wall) -> VictoryRoad_1F (19, 14) [wild]", + "19.04b behind_boulder_7 from VictoryRoad_1F (19, 14) facing north to VictoryRoad_1F (20, 14)", + "19.04b walk east 1 (to wall) -> VictoryRoad_1F (20, 14) [wild]", + "19.04b below_ladder from VictoryRoad_1F (20, 15) facing south to VictoryRoad_1F (4, 7) facing north", + "19.04b walk south 1 (to wall) -> VictoryRoad_1F (20, 16)", + "19.04b walk west 1 (to wall) -> VictoryRoad_1F (19, 16) [wild]", + "19.04b walk south 2 (to wall) -> VictoryRoad_1F (19, 18) [wild]", + "19.04b walk west 4 (to wall) -> VictoryRoad_1F (15, 18) [wild]", + "19.04b walk north 1 (to wall) -> VictoryRoad_1F (15, 17) [wild]", + "19.04b walk west 4 (to wall) -> VictoryRoad_1F (11, 17) [wild]", + "19.04b walk south 4 (warp) -> Route23 (5, 29) [wild]", + "19.04b walk north 1 (warp) -> VictoryRoad_1F (11, 20)", + "19.04b walk west 3 (to wall) -> VictoryRoad_1F (8, 20) [wild]", + "19.04b walk north 1 (to wall) -> VictoryRoad_1F (8, 19) [wild]", + "19.04b walk west 2 -> VictoryRoad_1F (6, 19) [wild]", + "19.04b walk north 2 (to wall) -> VictoryRoad_1F (6, 17) [wild]", + "19.04b walk east 1 (to wall) -> VictoryRoad_1F (7, 17) [wild]", + "19.04b walk north 6 (to wall) -> VictoryRoad_1F (7, 11) [wild]", + "19.04b walk east 3 (to wall) -> VictoryRoad_1F (10, 11) [wild]", + "19.04b walk south 4 (to wall) -> VictoryRoad_1F (10, 15) [wild]", + "19.04b walk east 5 (to wall) -> VictoryRoad_1F (15, 15) [wild]", + "19.04b walk north 10 (to wall) -> VictoryRoad_1F (15, 5) [wild]", + "19.04b walk west 5 -> VictoryRoad_1F (10, 5) [wild]", + "19.04b walk south 5 (to wall) -> VictoryRoad_1F (10, 10) [wild]", + "19.04b walk west 5 (to wall) -> VictoryRoad_1F (5, 10) [wild]", + "19.04b walk north 3 -> VictoryRoad_1F (5, 7) [wild]", + "19.04b walk west 1 -> VictoryRoad_1F (4, 7) [wild]", + "19.04b face north -> VictoryRoad_1F (4, 7)", + "19.04b ladder_2f from VictoryRoad_1F (4, 7) facing north to VictoryRoad_2F (1, 9)", + "19.04b walk north 5 (to wall) -> VictoryRoad_1F (4, 2) [wild]", + "19.04b walk west 1 (warp) -> VictoryRoad_2F (1, 9)", + "19.04c behind_boulder_1 from VictoryRoad_2F (1, 9) facing west to VictoryRoad_2F (7, 17)", + "19.04c walk south 1 (to wall) -> VictoryRoad_2F (1, 10) [wild]", + "19.04c walk east 5 (to wall) -> VictoryRoad_2F (6, 10) [wild]", + "19.04c walk south 6 -> VictoryRoad_2F (6, 16) [wild]", + "19.04c walk east 6 (to wall) -> VictoryRoad_2F (12, 16) [wild]", + "19.04c walk south 1 (to wall) -> VictoryRoad_2F (12, 17) [wild]", + "19.04c walk west 5 -> VictoryRoad_2F (7, 17) [wild]", + "19.04c by_boulder_2_corner from VictoryRoad_2F (5, 17) facing west to VictoryRoad_2F (5, 16)", + "19.04c walk north 1 -> VictoryRoad_2F (5, 16) [wild]", + "19.04c behind_boulder_2 from VictoryRoad_2F (5, 16) facing north to VictoryRoad_2F (4, 16)", + "19.04c walk west 1 -> VictoryRoad_2F (4, 16) [wild]", + "19.04c by_boulder_3_corner from VictoryRoad_2F (4, 18) facing south to VictoryRoad_2F (5, 18)", + "19.04c walk east 1 -> VictoryRoad_2F (5, 18) [wild]", + "19.04c behind_boulder_3 from VictoryRoad_2F (5, 18) facing east to VictoryRoad_2F (5, 19)", + "19.04c walk south 1 (to wall) -> VictoryRoad_2F (5, 19) [wild]", + "19.04c ladder_3f from VictoryRoad_2F (3, 19) facing west to VictoryRoad_3F (5, 2)", + "19.04c walk east 2 (to wall) -> VictoryRoad_2F (5, 19) [wild]", + "19.04c walk north 6 -> VictoryRoad_2F (5, 13) [wild]", + "19.04c walk east 4 -> VictoryRoad_2F (9, 13) [wild]", + "19.04c walk north 3 (to wall) -> VictoryRoad_2F (9, 10) [wild]", + "19.04c walk east 13 (to wall) -> VictoryRoad_2F (22, 10) [wild]", + "19.04c walk south 7 (to wall) -> VictoryRoad_2F (22, 17) [wild]", + "19.04c walk east 9 -> VictoryRoad_2F (31, 17) [wild]", + "19.04c walk south 3 (to wall) -> VictoryRoad_2F (31, 20) [wild]", + "19.04c walk east 11 (to wall) -> VictoryRoad_2F (42, 20) [wild]", + "19.04c walk north 4 (to wall) -> VictoryRoad_2F (42, 16) [wild]", + "19.04c walk west 2 (to wall) -> VictoryRoad_2F (40, 16) [wild]", + "19.04c walk north 2 (to wall) -> VictoryRoad_2F (40, 14) [wild]", + "19.04c walk west 6 -> VictoryRoad_2F (34, 14) [wild]", + "19.04c walk north 5 (warp) -> VictoryRoad_3F (34, 9) [wild]", + "19.04c walk north 7 (to wall) -> VictoryRoad_3F (34, 2) [wild]", + "19.04c walk west 24 (to wall) -> VictoryRoad_3F (10, 2) [wild]", + "19.04c walk south 2 -> VictoryRoad_3F (10, 4) [wild]", + "19.04c walk west 5 (to wall) -> VictoryRoad_3F (5, 4) [wild]", + "19.04c walk north 2 (warp) -> VictoryRoad_2F (3, 3) [wild]", + "19.04c walk south 2 (to wall) -> VictoryRoad_2F (3, 5) [wild]", + "19.04c walk north 2 (warp) -> VictoryRoad_3F (5, 2) [wild]", + "19.04c behind_boulder_4 from VictoryRoad_3F (5, 2) facing north to VictoryRoad_3F (32, 6)", + "19.04c walk east 1 (to wall) -> VictoryRoad_3F (6, 2) [wild]", + "19.04c walk south 5 (to wall) -> VictoryRoad_3F (6, 7) [wild]", + "19.04c walk east 1 (to wall) -> VictoryRoad_3F (7, 7)", + "19.04c walk north 1 (to wall) -> VictoryRoad_3F (7, 6) [wild]", + "19.04c walk east 1 (to wall) -> VictoryRoad_3F (8, 6) [wild]", + "19.04c walk north 2 (to wall) -> VictoryRoad_3F (8, 4) [wild]", + "19.04c walk east 4 (to wall) -> VictoryRoad_3F (12, 4) [wild]", + "19.04c walk north 2 (to wall) -> VictoryRoad_3F (12, 2) [wild]", + "19.04c walk east 19 -> VictoryRoad_3F (31, 2) [wild]", + "19.04c walk south 4 -> VictoryRoad_3F (31, 6) [wild]", + "19.04c walk east 1 -> VictoryRoad_3F (32, 6) [wild]", + "19.04c by_boulder_5_corner from VictoryRoad_3F (32, 4) facing north to VictoryRoad_3F (33, 4)", + "19.04c walk east 1 -> VictoryRoad_3F (33, 4) [wild]", + "19.04c behind_boulder_5 from VictoryRoad_3F (33, 4) facing east to VictoryRoad_3F (33, 3)", + "19.04c walk north 1 -> VictoryRoad_3F (33, 3) [wild]", + "19.04c by_boulder_6_corner from VictoryRoad_3F (12, 3) facing west to VictoryRoad_3F (12, 2)", + "19.04c walk north 1 (to wall) -> VictoryRoad_3F (12, 2) [wild]", + "19.04c behind_boulder_6 from VictoryRoad_3F (12, 2) facing north to VictoryRoad_3F (11, 2)", + "19.04c walk west 1 -> VictoryRoad_3F (11, 2) [wild]", + "19.04c by_boulder_7_corner from VictoryRoad_3F (11, 3) facing south to VictoryRoad_3F (12, 3)", + "19.04c walk east 1 -> VictoryRoad_3F (12, 3) [wild]", + "19.04c behind_boulder_7 from VictoryRoad_3F (12, 3) facing east to VictoryRoad_3F (12, 4)", + "19.04c walk south 1 -> VictoryRoad_3F (12, 4) [wild]", + "19.04c by_boulder_8_corner from VictoryRoad_3F (7, 4) facing west to VictoryRoad_3F (7, 3)", + "19.04c walk north 1 (to wall) -> VictoryRoad_3F (7, 3) [wild]", + "19.04c behind_boulder_8 from VictoryRoad_3F (7, 3) facing north to VictoryRoad_3F (6, 3)", + "19.04c walk west 1 -> VictoryRoad_3F (6, 3) [wild]", + "19.04c by_boulder_9_corner from VictoryRoad_3F (6, 6) facing south to VictoryRoad_3F (5, 6)", + "19.04c walk west 1 -> VictoryRoad_3F (5, 6) [wild]", + "19.04c behind_boulder_9 from VictoryRoad_3F (5, 6) facing west to VictoryRoad_3F (5, 7)", + "19.04c walk south 1 -> VictoryRoad_3F (5, 7) [wild]", + "19.04d hole_way_1 from VictoryRoad_3F (6, 7) facing east to VictoryRoad_3F (6, 6)", + "19.04d walk north 1 -> VictoryRoad_3F (6, 6) [wild]", + "19.04d hole_way_2 from VictoryRoad_3F (6, 6) facing north to VictoryRoad_3F (25, 8)", + "19.04d walk east 2 (to wall) -> VictoryRoad_3F (8, 6) [wild]", + "19.04d walk north 2 (to wall) -> VictoryRoad_3F (8, 4) [wild]", + "19.04d walk east 4 (to wall) -> VictoryRoad_3F (12, 4) [wild]", + "19.04d walk north 2 (to wall) -> VictoryRoad_3F (12, 2) [wild]", + "19.04d walk east 17 -> VictoryRoad_3F (29, 2) [wild]", + "19.04d walk south 6 -> VictoryRoad_3F (29, 8) [wild]", + "19.04d walk west 4 -> VictoryRoad_3F (25, 8) [wild]", + "19.04d hole_way_3 from VictoryRoad_3F (25, 8) facing west to VictoryRoad_3F (25, 6)", + "19.04d walk north 2 -> VictoryRoad_3F (25, 6) [wild]", + "19.04d hole_way_4 from VictoryRoad_3F (25, 6) facing north to VictoryRoad_3F (16, 6)", + "19.04d walk west 9 -> VictoryRoad_3F (16, 6) [wild]", + "19.04d hole_way_5 from VictoryRoad_3F (16, 6) facing west to VictoryRoad_3F (16, 13)", + "19.04d walk south 7 (to wall) -> VictoryRoad_3F (16, 13) [wild]", + "19.04d hole_way_6 from VictoryRoad_3F (16, 13) facing south to VictoryRoad_3F (11, 13)", + "19.04d walk west 5 -> VictoryRoad_3F (11, 13) [wild]", + "19.04d hole_way_7 from VictoryRoad_3F (11, 13) facing west to VictoryRoad_3F (4, 14)", + "19.04d walk west 2 (to wall) -> VictoryRoad_3F (9, 13) [wild]", + "19.04d walk north 4 (to wall) -> VictoryRoad_3F (9, 9) [wild]", + "19.04d walk west 5 -> VictoryRoad_3F (4, 9) [wild]", + "19.04d walk south 5 -> VictoryRoad_3F (4, 14) [wild]", + "19.04d hole_way_8 from VictoryRoad_3F (4, 14) facing south to VictoryRoad_3F (17, 15)", + "19.04d walk south 1 -> VictoryRoad_3F (4, 15) [wild]", + "19.04d walk east 13 (to wall) -> VictoryRoad_3F (17, 15) [wild]", + "19.04d hole_way_9 from VictoryRoad_3F (17, 15) facing east to VictoryRoad_3F (17, 19)", + "19.04d walk south 4 (to wall) -> VictoryRoad_3F (17, 19) [wild]", + "19.04d behind_hole_boulder from VictoryRoad_3F (17, 19) facing south to VictoryRoad_3F (32, 18)", + "19.04d walk east 15 -> VictoryRoad_3F (32, 19) [wild]", + "19.04d walk north 1 -> VictoryRoad_3F (32, 18) [wild]", + "19.04d drop_to_2f from VictoryRoad_3F (33, 18) facing east to VictoryRoad_2F (34, 19)", + "19.04d walk east 1 (warp) -> VictoryRoad_2F (34, 19) [wild]", + "19.04d exit_way_1 from VictoryRoad_2F (15, 19) facing west to VictoryRoad_2F (31, 19)", + "19.04d walk east 16 -> VictoryRoad_2F (31, 19) [wild]", + "19.04d exit_way_2 from VictoryRoad_2F (31, 19) facing east to VictoryRoad_2F (35, 17)", + "19.04d walk north 2 -> VictoryRoad_2F (31, 17) [wild]", + "19.04d walk east 4 -> VictoryRoad_2F (35, 17) [wild]", + "19.04d above_exit from VictoryRoad_2F (35, 17) facing east to VictoryRoad_2F (48, 11) facing south", + "19.04d walk east 1 (warp) -> VictoryRoad_3F (39, 17)", + "19.04d walk east 1 (to wall) -> VictoryRoad_3F (40, 17) [wild]", + "19.04d walk north 7 -> VictoryRoad_3F (40, 10) [wild]", + "19.04d walk west 3 (warp) -> VictoryRoad_2F (38, 9) [wild]", + "19.04d walk south 2 -> VictoryRoad_2F (38, 11) [wild]", + "19.04d walk east 10 (to wall) -> VictoryRoad_2F (48, 11) [wild]", + "19.04d face south -> VictoryRoad_2F (48, 11)", + "19.05 indigo_door from Route23 (18, 29) facing south to IndigoPlateau_Exterior (11, 7) facing north", + "19.05 walk east 3 (to wall) -> Route23 (21, 29)", + "19.05 walk north 11 -> Route23 (21, 18)", "19.05 walk west 7 -> Route23 (14, 18)", "19.05 walk north 13 (to wall) -> Route23 (14, 5)", "19.05 walk east 1 (to wall) -> Route23 (15, 5)", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp index e48263ba7a..2f1e03573b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp @@ -12,11 +12,14 @@ #include #include #include "Common/Cpp/Exceptions.h" +#include "Pokemon/AutoStory/Pokemon_StoryPose.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" +#include "PokemonFRLG_AutoStoryBoulders.h" #include "PokemonFRLG_AutoStoryLegs.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryBattleDecisions.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryFieldMoves.h" @@ -71,8 +74,8 @@ std::string stub_report(const std::vector& rows){ namespace{ -const MapData* map_named(const std::string& name){ - for (const MapData& map : story_maps()){ +const MapData* map_named(const std::string& name, const std::vector& maps = story_maps()){ + for (const MapData& map : maps){ if (map.name == name){ return ↦ } @@ -83,8 +86,8 @@ const MapData* map_named(const std::string& name){ // Whether the player, at the end of a WALK `step`, stops there holding on: // the map's edge, a wall, or water to Surf onto, but no warp of any kind, // even one to a map that isn't loaded. -bool stops_past_end(const RouteStep& step){ - const MapData& map = *map_named(step.end.map); +bool stops_past_end(const RouteStep& step, const std::vector& maps){ + const MapData& map = *map_named(step.end.map, maps); const TilePos here = step.end.point; const TilePos ahead = here.next(step.direction); if (!in_bounds(map, ahead)){ @@ -102,9 +105,9 @@ bool stops_past_end(const RouteStep& step){ // The first leg of `route` to a wall that holding on would carry past its // end, or nothing (console B, 2026-11-02: one rode Route 4's Pokemon // Center escalator). -std::optional overrun_wall_leg(const std::vector& route){ +std::optional overrun_wall_leg(const std::vector& route, const std::vector& maps){ for (const RouteStep& step : route){ - if (step.to_wall && !stops_past_end(step)){ + if (step.to_wall && !stops_past_end(step, maps)){ return to_string(step); } } @@ -117,14 +120,14 @@ struct Standing{ Direction facing = Direction::NORTH; std::string error; }; -Standing standing(const Pokemon::Pose& pose){ +Standing standing(const Pokemon::Pose& pose, const std::vector& maps){ const std::optional at = story_pose(pose); if (!at){ return {{}, Direction::NORTH, "no one-tile pose: " + Pokemon::to_string(pose)}; } std::optional facing = at->facing; if (!facing){ - const MapData* map = map_named(at->map); + const MapData* map = map_named(at->map, maps); facing = map ? wall_beside(*map, at->tile) : std::nullopt; } if (!facing){ @@ -209,7 +212,7 @@ StepInterruptActions StoryMapsSim::sim_interrupt_actions(){ Pokemon::StoryAction StoryMapsSim::action(StoryActionId id){ switch (id){ case StoryActionId::ROUTE: - return played([this](const StoryStep& step, RunState& state){ return walk_to(state.pose, step); }); + return played([this](const StoryStep& step, RunState& state){ return walk_to(state, step); }); case StoryActionId::LEGS: return played([this](const StoryStep& step, RunState& state){ return legs(state.pose, step); }); case StoryActionId::STEP: @@ -217,16 +220,20 @@ Pokemon::StoryAction StoryMapsSim::action(StoryActionId id){ // The nurse's way must plan too, but the run goes on from where it stands. case StoryActionId::READY: return played([this](const StoryStep& step, RunState& state){ - const Outcome to_nurse = walk_to(state.pose, step); + // The way to the nurse is walked in a copy: the run goes on from here. + RunState visit = state; + const Outcome to_nurse = walk_to(visit, step); return to_nurse.succeeded() ? Pokemon::outcome_ok() : to_nurse; }); case StoryActionId::SHOP: return played([this](const StoryStep& step, RunState&){ return shop(step); }); + // A push leaves the player behind the boulder, a switch on if it lands on one. + case StoryActionId::PUSH_BOULDER: + return played([this](const StoryStep& step, RunState& state){ return boulder_pushed(state, step, maps()); }); // Pacing leaves the player on either of its tiles, as on the console. case StoryActionId::CLOSE_TRAINER_CARD: case StoryActionId::LEAVE_GIFT_SUMMARY: case StoryActionId::CUT_TREE: - case StoryActionId::PUSH_BOULDER: case StoryActionId::TRASH_CANS: case StoryActionId::GAME: return m_stubs.stub([](const StoryStep& step, RunState& state){ @@ -245,11 +252,11 @@ Pokemon::StoryAction StoryMapsSim::action(StoryActionId id){ } Outcome StoryMapsSim::legs(const Pokemon::Pose& pose, const StoryStep& step) const{ - const Standing at = standing(pose); + const Standing at = standing(pose, maps()); if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } - const std::optional> route = fixed_route(story_maps(), at.position, Pokemon::story_arg>(step.args, "legs")); + const std::optional> route = fixed_route(maps(), at.position, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(at.position)); } @@ -310,37 +317,45 @@ Outcome StoryMapsSim::shop(const StoryStep& step){ return Pokemon::outcome_ok(); } -Outcome StoryMapsSim::walk_to(const Pokemon::Pose& pose, const StoryStep& step) const{ +const std::vector& StoryMapsSim::maps() const{ + return m_knobs.maps != nullptr ? *m_knobs.maps : story_maps(); +} + +Outcome StoryMapsSim::walk_to(Pokemon::RunState& state, const StoryStep& step) const{ + const Pokemon::Pose& pose = state.pose; + const Pokemon::GateRules rules = Pokemon::gate_rules_of(state); if (Pokemon::tiles_of(pose).size() > 1){ // From the tiles a pacing step leaves: the route must plan, and // test_routes_after_pacing() walks it on the sim from each. const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; - const std::optional> route = plan_story_route(story_maps(), pose, std::nullopt, goal); + const std::optional> route = plan_story_route(maps(), pose, std::nullopt, goal, state.gates, rules); if (!route || route->empty()){ return Pokemon::outcome_failed("no_route", Pokemon::to_string(pose) + " to " + to_string(goal.position)); } + state.gates = gates_after_route(state.gates, *route); return Pokemon::outcome_ok(to_pose(StoryPose{target->map, target->tile, route->back().facing_after})); } - const Standing at = standing(pose); + const Standing at = standing(pose, maps()); if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; - const std::optional> route = plan_overworld_route( - story_maps(), at.position, goal, story_route_costs(), at.facing + const std::optional> route = plan_overworld_route_gated( + maps(), at.position, goal, state.gates, rules, story_route_costs(), at.facing ); if (!route){ return Pokemon::outcome_failed("no_route", to_string(at.position) + " to " + to_string(goal.position)); } - const MapPosition end = follow_overworld_route(story_maps(), at.position, *route); + const MapPosition end = follow_overworld_route(maps(), at.position, *route, state.gates); if (!(end == goal.position)){ return Pokemon::outcome_failed("wrong_end", to_string(end)); } - if (const std::optional leg = overrun_wall_leg(*route)){ + if (const std::optional leg = overrun_wall_leg(*route, maps())){ return Pokemon::outcome_failed("wall_overrun", *leg); } + state.gates = gates_after_route(state.gates, *route); const Direction facing = route->empty() ? at.facing : route->back().facing_after; return Pokemon::outcome_ok(to_pose(StoryPose{target->map, target->tile, facing})); } @@ -348,14 +363,17 @@ Outcome StoryMapsSim::walk_to(const Pokemon::Pose& pose, const StoryStep& step) // The route the program walks for `step`, a ROUTE or LEGS, from `at`: // planned, or the legs laid out. -std::optional> walked_route(const StoryPose& at, const StoryStep& step){ +std::optional> walked_route( + const StoryPose& at, const StoryStep& step, + const std::vector& maps, const Pokemon::GateState& gates, const Pokemon::GateRules& rules +){ const MapPosition start{at.map, at.tile}; if (step.kind == StoryStepKind::LEGS){ - return fixed_route(story_maps(), start, Pokemon::story_arg>(step.args, "legs")); + return fixed_route(maps, start, Pokemon::story_arg>(step.args, "legs")); } const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; - return plan_overworld_route(story_maps(), start, goal, story_route_costs(), at.facing); + return plan_overworld_route_gated(maps, start, goal, gates, rules, story_route_costs(), at.facing); } @@ -475,12 +493,17 @@ void sim_wait_out_battle_exit(OverworldSim& sim){ // A ROUTE or LEGS by the sim's walker, fighting a trainer who sees the // player on the way. std::string OverworldStepSim::walk(const StoryStep& step){ - const std::optional> route = walked_route(m_at, step); + // The story's maps, as the planner and the program have them (the grunt the sim has + // hidden stands on them, and the stairs a switch opens are open); the gates are the sim's, + // which the walker's steps open. + const std::vector& maps = story_maps(); + const Pokemon::GateState& gates = m_sim.state().gates; + const std::optional> route = walked_route(m_at, step, maps, gates, Pokemon::GateRules{.card_key_held = m_sim.state().card_key_held}); if (route && route->empty()){ // Already there. return ""; } - const RoutePlanning planning{.maps = &story_maps(), .costs = story_route_costs(), .start = MapPosition{m_at.map, m_at.tile}, .label = step.name}; + const RoutePlanning planning{.maps = &maps, .gates = gates, .costs = story_route_costs(), .start = MapPosition{m_at.map, m_at.tile}, .label = step.name}; SimWalkerRules rules; rules.trainer_battle_end = battle_end_on_sim; // A BIKE_VARIANT rides, as on the console, when the sim has the diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h index 4c06878b63..bd83963451 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h @@ -19,6 +19,8 @@ #include #include #include "Pokemon/AutoStory/Pokemon_StoryActions.h" +#include "Pokemon/Navigation/Pokemon_GatedTypes.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -40,6 +42,9 @@ struct StorySimKnobs{ // Whether the executor clears what came up between steps // (step_interrupts()), as the console does; off, as before it did. bool clear_interrupts = true; + // The maps the story is planned and walked on, with the gates of the + // run state; the story's (story_maps()) if null. + const std::vector* maps = nullptr; }; // The whole story on the story maps, without a walker: each ROUTE planned @@ -84,7 +89,9 @@ class StoryMapsSim : public Pokemon::TableExecutor{ private: Pokemon::StoryAction action(StoryActionId id); - Pokemon::Outcome walk_to(const Pokemon::Pose& pose, const StoryStep& step) const; + const std::vector& maps() const; + // Plans the route and moves the run's pose and gates to its end. + Pokemon::Outcome walk_to(Pokemon::RunState& state, const StoryStep& step) const; Pokemon::Outcome legs(const Pokemon::Pose& pose, const StoryStep& step) const; Pokemon::Outcome step_ahead(const Pokemon::Pose& pose, const StoryStep& step) const; Pokemon::Outcome shop(const StoryStep& step); @@ -108,8 +115,14 @@ class StoryMapsSim : public Pokemon::TableExecutor{ // The route the program walks for `step`, a ROUTE or LEGS, from `at`: -// planned, or the legs laid out. -std::optional> walked_route(const StoryPose& at, const StoryStep& step); +// planned, or the legs laid out. A route is planned over `maps` through +// `gates`, and may open a card-key gate if `rules` say the player holds +// the Card Key. +std::optional> walked_route( + const StoryPose& at, const StoryStep& step, + const std::vector& maps = story_maps(), + const Pokemon::GateState& gates = Pokemon::GateState(), const Pokemon::GateRules& rules = Pokemon::GateRules() +); // A row's steps on the OverworldSim as the program does them: routes and // legs by the sim's walker from where the table says the player stands, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp index 1bdf311e59..69656167e6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -145,7 +145,7 @@ class Test_RunPlan : public UnitTest{ const RunPlanScenario m_scenario; }; -const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.05"; +const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05"; const RunPlanScenario RUN_PLAN_CASES[] = { { @@ -236,11 +236,11 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Gift RNG off: 04.03 is passed over", .first = "04.01"}, - .expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.05"}, + .expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05"}, }, { .input = {.name = "Gift RNG off: 04.03 runs when started at", .first = "04.03"}, - .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.05"}, + .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05"}, }, { .input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman", @@ -279,7 +279,7 @@ const RunPlanScenario RUN_PLAN_CASES[] = { }, { .input = {.name = "Starter RNG alone: 04.03 runs when started at", .first = "04.03", .handoffs = {.starter_rng = true}}, - .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.05"}, + .expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05"}, }, { .input = { .name = "Starter RNG first, with both on", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 31559b05e1..ebf6f1e31d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -237,7 +237,7 @@ constexpr std::string_view STORY_ORDER[] = { "12.01", "12.02", "12.02b", "12.03", "13.01", "13.02", "13.03", "13.04", "14.01", "14.02", "14.02b", "14.03", "14.04", "14.04b", "15.01", "16.01", - "17.02", "17.03", "17.04", "17.04b", "19.01a", "19.01", "19.02", "19.03", "19.04", "19.05", + "17.02", "17.03", "17.04", "17.04b", "19.01a", "19.01", "19.02", "19.03", "19.04", "19.04b", "19.04c", "19.04d", "19.05", }; // `checkpoints` in STORY_ORDER's order. Throws ParseException for a diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h index 5e4f1ef1fa..3ba3dbe560 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h @@ -21,12 +21,11 @@ namespace PokemonFRLG{ // the story's order (STORY_ORDER in PokemonFRLG_AutoStoryTable.cpp) ends. // 17.02 starts at Saffron's Center nurse, where no row before it in the // order ends (Silph Co.'s 16.01 ends on a pad on 5F; the rest of Silph Co. -// and Sabrina are not authored). 19.05 starts at Victory Road's second-floor exit, after the -// cave's floors, whose boulder puzzles are not authored (19.04). 14.01 starts outside the Pokemon Mansion, +// and Sabrina are not authored). 14.01 starts outside the Pokemon Mansion, // after its Escape Rope (13.04), which is not authored. An id leaves this // list once the rows before it are in. inline bool starts_after_unauthored_rows(std::string_view id){ - return id == "17.02" || id == "14.01" || id == "19.05"; + return id == "17.02" || id == "14.01"; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp index ac2fa55d56..df0be63067 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp @@ -17,6 +17,7 @@ #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_StoryPostconditionCheck.h" #include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" @@ -270,6 +271,67 @@ UnitTestResult test_strength_teach_and_cave_mouth(){ return true; } +// A Victory Road floor's row on the sim from its start_gates, its boulder +// pushes included: it starts where `previous` ends, turns on the switch +// `switch_key`, meets no trainer, breaks no rule and ends on `end`. +UnitTestResult cave_floor(std::string_view previous, std::string_view id, std::string_view switch_key, const MapPosition& end){ + const StoryCheckpoint& before = checkpoint(previous); + const StoryCheckpoint& row = checkpoint(id); + const StoryPose at_start = *story_pose(Pokemon::pose_of(*row.start)); + const std::optional before_pose = Pokemon::checkpoint_end_pose(before); + const std::optional before_end = before_pose ? story_pose(Pokemon::pose_of(*before_pose)) : std::nullopt; + if (!before_end || before_end->map != at_start.map || !(before_end->tile == at_start.tile)){ + return std::format("{} doesn't start where {} ends.", id, previous); + } + StoryPose at = at_start; + SimScript script; + script.gates = row.start_gates.value_or(Pokemon::GateState()); + OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, at.facing.value_or(Direction::NORTH), script); + for (const StoryStep& step : row.steps){ + const bool push = step.kind == StoryStepKind::GAME && step.action == PUSH_BOULDER_VARIANT; + if (!push && step.kind != StoryStepKind::ROUTE && step.kind != StoryStepKind::LEGS && step.kind != StoryStepKind::STEP){ + continue; + } + if (const std::string failure = row_step_on_sim(sim, at, step, row.id); !failure.empty()){ + return std::format("{} {}: ended on {}; {}", id, step.name, to_string(sim.state().position), failure); + } + if (!sim.state().violations.empty()){ + return std::format("{} {}: broke a rule on {}: {}", id, step.name, to_string(sim.state().position), sim.state().violations.front()); + } + if (!sim.state().trainers_beaten.empty()){ + return std::format("{} {}: met a trainer: {}", id, step.name, sim.state().trainers_beaten.front()); + } + } + if (!sim.state().gates.switch_on(std::string(switch_key))){ + return std::format("{}: the switch {} is not on.", id, switch_key); + } + if (!(sim.state().position == end)){ + return std::format("{}: ended on {}, not {}.", id, to_string(sim.state().position), to_string(end)); + } + if (!sim.state().trainers_beaten.empty() || !sim.state().violations.empty()){ + return std::format("{}: met a trainer or broke a rule on the way.", id); + } + return true; +} + +// 19.04b: 1F's boulder from (7, 18) onto the switch (20, 16), the barrier +// open, up the ladder to 2F. +UnitTestResult test_victory_road_1f(){ + return cave_floor("19.04", "19.04b", "VictoryRoad_1F/floor_switch_1", MapPosition{"VictoryRoad_2F", {1, 9}}); +} + +// 19.04c: 2F's west boulder onto the switch (2, 19), then up to 3F and its +// north boulder onto the switch (7, 7). +UnitTestResult test_victory_road_2f_3f(){ + return cave_floor("19.04b", "19.04c", "VictoryRoad_3F/floor_switch_1", MapPosition{"VictoryRoad_3F", {6, 7}}); +} + +// 19.04d: 3F's boulder down the hole, after it to 2F, onto 2F's second +// switch (14, 19), then the exit to Route 23, a tile below its mouth (18, 29), where 19.05 starts. +UnitTestResult test_victory_road_hole_and_exit(){ + return cave_floor("19.04c", "19.04d", "VictoryRoad_2F/floor_switch_2", MapPosition{"Route23", {18, 29}}); +} + // 19.05: from Victory Road's exit on Route 23 to the nurse's counter. UnitTestResult test_indigo_center_walk(){ const StoryCheckpoint& row = checkpoint("19.05"); @@ -306,6 +368,18 @@ const AutoStoryVictoryRoadCase AUTO_STORY_VICTORY_ROAD_CASES[] = { .input = {.name = "19.04 Strength over Water Pulse, into the cave", .body = test_strength_teach_and_cave_mouth}, .expectation = {.description = "keep surf, bite, blizzard; Victory Road 1F (11, 20)"}, }, + { + .input = {.name = "19.04b Victory Road 1F's boulder switch, up to 2F", .body = test_victory_road_1f}, + .expectation = {.description = "1F's switch on, 2F (1, 9), no trainer met"}, + }, + { + .input = {.name = "19.04c Victory Road 2F's and 3F's boulder switches", .body = test_victory_road_2f_3f}, + .expectation = {.description = "3F's switch on, 3F (6, 7), no trainer met"}, + }, + { + .input = {.name = "19.04d Victory Road 3F's hole, 2F's second switch, out to Route 23", .body = test_victory_road_hole_and_exit}, + .expectation = {.description = "2F's east switch on, Route 23 (18, 29), no trainer met"}, + }, { .input = {.name = "19.05 Indigo Plateau's Center", .body = test_indigo_center_walk}, .expectation = {.description = "Indigo Plateau Center (13, 12)"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index b503efea43..0e6dd7dd70 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -22,6 +22,7 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "CommonFramework/ImageTypes/ImageRGB32.h" #include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_OptionMenuReader.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" @@ -97,6 +98,61 @@ const MapData* find_map_named(const std::string& name){ return nullptr; } +// The gates the walk the test is following has opened and the switches it +// has pressed, and whether it holds the Card Key: what the story's steps +// carry through a checkpoint (start_gates, gates_after, flags_after). Each +// test runs on one thread, from begin_walk() on. +struct WalkGates{ + Pokemon::GateState gates; + bool card_key_held = false; +}; +WalkGates& walk_state(){ + thread_local WalkGates walk; + return walk; +} + +// Starts a walk at `checkpoint`'s start: its start_gates and start_flags. +void begin_walk(const StoryCheckpoint& checkpoint){ + walk_state() = WalkGates{}; + if (checkpoint.start_gates){ + walk_state().gates = *checkpoint.start_gates; + } + walk_state().card_key_held = std::ranges::find(checkpoint.start_flags, "card_key_held") != checkpoint.start_flags.end(); +} + +// A walk through the checkpoint that follows the one before: only what its +// start says replaces the gates carried. +void continue_walk(const StoryCheckpoint& checkpoint){ + if (checkpoint.start_gates){ + walk_state().gates = *checkpoint.start_gates; + } + if (std::ranges::find(checkpoint.start_flags, "card_key_held") != checkpoint.start_flags.end()){ + walk_state().card_key_held = true; + } +} + +// What `step` does to the walk's gates once done, besides a route's own. +void apply_step_effects(const StoryStep& step){ + if (step.gates_after){ + apply_gate_change(walk_state().gates, *step.gates_after); + } + if (std::ranges::find(step.flags_after, "card_key_held") != step.flags_after.end()){ + walk_state().card_key_held = true; + } +} + +// The story's maps as the walk's gates make them. +const std::vector& walk_maps(){ + thread_local std::optional>> resolved; + if (!has_gates(story_maps())){ + return story_maps(); + } + if (!resolved || !(resolved->first == walk_state().gates)){ + resolved.emplace(walk_state().gates, resolve_maps(story_maps(), walk_state().gates)); + } + return resolved->second; +} + std::string describe(const std::vector& route){ std::string text; for (const RouteStep& step : route){ @@ -166,7 +222,7 @@ UnitTestResult check_held_legs(const std::string& name, const std::vector> route = fixed_route(story_maps(), MapPosition{pose.map, pose.tile}, Pokemon::story_arg>(step.args, "legs")); + const std::optional> route = fixed_route(walk_maps(), MapPosition{pose.map, pose.tile}, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return step.name + ": the legs can't be walked from " + describe(pose) + "."; } @@ -216,7 +272,8 @@ UnitTestResult check_route(StoryPose& pose, const StoryStep& step, std::vector(step.args, "target")); const RouteGoal goal{{target.map, target.tile}, target.facing}; - const std::optional> route = plan_overworld_route(story_maps(), start, goal, default_route_costs(), facing); + const Pokemon::GateRules rules{.card_key_held = walk_state().card_key_held}; + const std::optional> route = plan_overworld_route_gated(story_maps(), start, goal, walk_state().gates, rules, default_route_costs(), facing); if (!route){ return step.name + ": no route from " + to_string(start) + " to " + to_string(goal.position) + "."; } @@ -225,7 +282,7 @@ UnitTestResult check_route(StoryPose& pose, const StoryStep& step, std::vectorempty() ? facing : route->back().facing_after}; return true; } @@ -273,6 +331,7 @@ UnitTestResult check_checkpoint_steps(const StoryCheckpoint& checkpoint, StoryPo if (step.pose_after){ pose = one_tile(Pokemon::grid_pose_of(*step.pose_after)); } + apply_step_effects(step); } return true; } @@ -293,12 +352,14 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po // start: starts_after_unauthored_rows()), and adds the plans to `golden`. UnitTestResult chain_story_routes(std::vector& golden){ const std::vector& checkpoints = story_checkpoints(); - if (checkpoints.size() != 76 || checkpoints[0].start){ - return "Expected 76 checkpoints, the first from a new game."; + if (checkpoints.size() != 79 || checkpoints[0].start){ + return "Expected 79 checkpoints, the first from a new game."; } StoryPose pose; + walk_state() = WalkGates{}; for (size_t c = 0; c < checkpoints.size(); c++){ const StoryCheckpoint& checkpoint = checkpoints[c]; + continue_walk(checkpoint); if (c > 0 && starts_after_unauthored_rows(checkpoint.id)){ pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); }else if (c > 0){ @@ -546,12 +607,12 @@ std::vector legs_walked(const StoryPose& pose, const StoryStep& step) const MapPosition start{pose.map, pose.tile}; std::optional> route; if (step.kind == StoryStepKind::LEGS){ - route = fixed_route(story_maps(), start, Pokemon::story_arg>(step.args, "legs")); + route = fixed_route(walk_maps(), start, Pokemon::story_arg>(step.args, "legs")); }else if (step.args.contains("target")){ const MapData* map = find_map_named(pose.map); const std::optional facing = pose.facing ? pose.facing : map ? wall_beside(*map, pose.tile) : std::nullopt; const StoryPose target = one_tile(Pokemon::story_arg(step.args, "target")); - route = plan_overworld_route(story_maps(), start, RouteGoal{{target.map, target.tile}, target.facing}, story_route_costs(), facing); + route = plan_overworld_route_gated(story_maps(), start, RouteGoal{{target.map, target.tile}, target.facing}, walk_state().gates, Pokemon::GateRules{.card_key_held = walk_state().card_key_held}, story_route_costs(), facing); } return route ? *route : std::vector{}; } @@ -580,7 +641,7 @@ std::vector> wanderer_stops(const StoryPose& pose, co std::vector> stops; MapPosition from{pose.map, pose.tile}; for (const RouteStep& leg : legs_walked(pose, step)){ - const std::optional c = trainer_crossing(story_maps(), from, leg); + const std::optional c = trainer_crossing(walk_maps(), from, leg); if (c && std::any_of(c->seen.begin(), c->seen.end(), wanderer_sees)){ stops.push_back(c->seen.size() == 1 && !leg.wild && !leg.warps ? std::optional(c->seen[0]) : std::nullopt); } @@ -600,7 +661,7 @@ std::string held_past_lookers(const StoryPose& pose, const StoryStep& step, cons for (const RouteStep& leg : legs_walked(pose, step)){ const MapData* map = find_map_named(from.map); bool crosses = false; - for (const MapPosition& tile : leg.action == RouteAction::WALK && map ? leg_tiles(story_maps(), from, leg) : std::vector{}){ + for (const MapPosition& tile : leg.action == RouteAction::WALK && map ? leg_tiles(walk_maps(), from, leg) : std::vector{}){ for (const MapObject& object : map->objects){ crosses |= looks_around(object) && !beaten.contains(&object) && trainer_may_see(*map, object, tile.point); } @@ -619,7 +680,7 @@ std::vector tiles_walked(const StoryPose& pose, const StoryStep& st MapPosition from{pose.map, pose.tile}; for (const RouteStep& leg : legs_walked(pose, step)){ if (leg.action == RouteAction::WALK){ - const std::vector passed = leg_tiles(story_maps(), from, leg); + const std::vector passed = leg_tiles(walk_maps(), from, leg); tiles.insert(tiles.end(), passed.begin() + 1, passed.end()); } from = leg.end; @@ -670,6 +731,7 @@ UnitTestResult advance(StoryPose& pose, const StoryStep& step){ if (step.pose_after){ pose = one_tile(Pokemon::grid_pose_of(*step.pose_after)); } + apply_step_effects(step); return true; } @@ -678,6 +740,7 @@ UnitTestResult advance(StoryPose& pose, const StoryStep& step){ // `repelled`: a Repel the table used is on (it lasts past the // checkpoint's save): grass is walked as any floor. UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set& beaten, bool& repelled){ + begin_walk(checkpoint); StoryPose pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); for (size_t c = 0; c < checkpoint.steps.size(); c++){ const StoryStep& step = checkpoint.steps[c]; @@ -697,9 +760,9 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set> stops = walks ? wanderer_stops(pose, step) : std::vector>{}; - // 13.03's walk into Lewis's room, B1F of the Pokemon Mansion: its one way in, + // 13.03's walk into (and, planned, past) Lewis's room, B1F of the Pokemon Mansion: its one way in, // (22, 24), is beside his wander range (19..21, 24..26), on a cave's wild floor. - const bool lewis = checkpoint.id == "13.03" && step.name == "to_statue"; + const bool lewis = checkpoint.id == "13.03" && (step.name == "to_statue" || step.name == "to_elixir"); if (!lewis && std::count(stops.begin(), stops.end(), std::nullopt) > 0){ return where + "crosses a wandering trainer's sight where the walk can't tell where they'd stop the player."; } @@ -769,6 +832,7 @@ UnitTestResult test_legs_onto_stairs_their_way(){ if (!walked){ continue; } + begin_walk(checkpoint); StoryPose pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); for (const StoryStep& step : checkpoint.steps){ if (step.kind == StoryStepKind::ROUTE){ @@ -831,12 +895,13 @@ std::string approach_off_tile(const std::vector& legs){ // approach to the Rare Candy, "west 4" and "south 6" held open, ended a // tile west and met a gravestone (console B, 2026-11-12 04:39). // PASSED_ON_CONSOLE: approaches before 10.05 that passed their console -// runs as held legs (a follow-up to tap them). +// runs as held legs (a follow-up to tap them). 13.03 and 13.04 plan their statue +// approaches (PRESS_SWITCH) and have not run on a console. UnitTestResult test_approaches_end_on_their_tile(){ const std::set PASSED_ON_CONSOLE{ "02.02/below_oak", "03.02/before_brock", "05.07/below_bill_clefairy", "05.07/pc_front", "05.07/beside_bill", "06.01/behind_captain", "07.01/beside_chairman", "07.01/bike_clerk", - "09.01/below_poster_guard", "09.02/below_left_guard", "09.03/above_tea_woman", "10.01/below_fly_woman", + "09.01/below_poster_guard", "09.02/below_left_guard", "09.03/above_tea_woman", "10.01/below_fly_woman", "13.03/to_elixir", "13.04/to_key", // Not run on a console: 14.01 (#410) predates this rule. Its quiz machine approaches are held // open routes; tap them (follow-up) and drop these. "14.01/below_quiz_1", "14.01/below_quiz_2", "14.01/below_quiz_3", "14.01/below_quiz_4", @@ -849,6 +914,7 @@ UnitTestResult test_approaches_end_on_their_tile(){ if (!start){ continue; } + begin_walk(checkpoint); StoryPose pose = *start; // The legs of the ROUTE and LEGS steps since the last other step. std::vector approach; @@ -895,6 +961,7 @@ UnitTestResult test_facing_after_trainer_battles(){ if (!start){ continue; } + begin_walk(checkpoint); StoryPose pose = *start; for (size_t c = 0; c < checkpoint.steps.size(); c++){ const StoryStep& step = checkpoint.steps[c]; @@ -987,6 +1054,7 @@ UnitTestResult check_trigger(const TriggerCase& c){ return "No checkpoint " + c.checkpoint + "."; } const MapPosition onto{c.map, {c.onto_x, c.y}}; + begin_walk(*checkpoint); StoryPose pose = one_tile(Pokemon::grid_pose_of(*checkpoint->start)); for (const StoryStep& step : checkpoint->steps){ const std::string where = c.checkpoint + "/" + step.name + ": "; @@ -1036,6 +1104,7 @@ UnitTestResult test_nugget_bridge_order(){ } const std::vector& steps = checkpoint->steps; std::string met; + begin_walk(*checkpoint); StoryPose pose = one_tile(Pokemon::grid_pose_of(*checkpoint->start)); for (size_t c = 0; c < steps.size(); c++){ const MapData* map = find_map_named(pose.map); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay.cpp index 159a6c2488..c23b2eb102 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay.cpp @@ -26,6 +26,12 @@ JsonValue replay_story_checkpoint(std::string_view capture, std::string_view bin const auto entry = StoryReplayInternal::read_pose(scenario.to_object_throw().get_object_throw("entry").get_value_throw("pose"), data.maps); Pokemon::RunState state; state.pose = Pokemon::tile_pose(entry.position.map, {entry.position.point}, entry.facing); + // The run flags the checkpoint starts with (card_key_held opens card-key doors). + if (const JsonArray* flags = scenario.to_object_throw().get_array("start_flags")){ + for (const JsonValue& flag : *flags){ + state.flags.insert(flag.to_string_throw()); + } + } JsonArray logs; Pokemon::EventLogger logger = [&](const std::string& line){ logs.push_back(line); }; const Pokemon::CheckpointReport result = Pokemon::run_checkpoint(state, checkpoint, logger); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp index f46ebfbe11..3125211e69 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.cpp @@ -6,6 +6,8 @@ #include "Common/Cpp/Exceptions.h" #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" +#include "Pokemon/Navigation/Pokemon_GateTiles.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_StoryReplay_Executor.h" namespace PokemonAutomation{ @@ -77,9 +79,9 @@ bool ReplayStepGuard::stops_on_failure(const StoryStep&) const{ Pokemon::StoryAction ReplayExecutor::replay_action(StoryActionId id){ switch (id){ case StoryActionId::ROUTE: - return {.act = [this](const StoryStep& step, Pokemon::RunState&){ return replay_route(step); }}; + return {.act = [this](const StoryStep& step, Pokemon::RunState& state){ return replay_route(step, state); }}; case StoryActionId::STEP: - return {.act = [this](const StoryStep& step, Pokemon::RunState&){ return replay_step(step); }}; + return {.act = [this](const StoryStep& step, Pokemon::RunState& state){ return replay_step(step, state); }}; case StoryActionId::MASH: return {.act = [this](const StoryStep& step, Pokemon::RunState&){ return replay_scene(step); }}; default: @@ -153,9 +155,63 @@ void ReplayExecutor::observe_interruption(const OverworldPose& predicted){ m_interrupted = true; lose_pose("unknown-after-interruption"); } -ReplayLeg ReplayExecutor::prepare_leg(const JsonValue& value, OverworldPose& current) const{ +const std::vector& ReplayExecutor::maps_through(const Pokemon::GateState& gates) const{ + if (!has_gates(m_data->maps)){ + return m_data->maps; + } + if (!m_resolved || !(m_resolved->first == gates)){ + m_resolved.emplace(gates, resolve_maps(m_data->maps, gates)); + } + return m_resolved->second; +} +// An open_gate or a press_switch: A at the gate or statue the player +// faces, which the model has to find there (and, for a gate, the player to +// hold the Card Key). +ReplayLeg ReplayExecutor::prepare_gate_leg(const JsonValue& value, const OverworldPose& current, Pokemon::GateState& gates) const{ + const JsonObject& command = value.to_object_throw(); + fields(value, {"event", "kind", "map", "direction"}); + const bool opens = command.get_string_throw("kind") == "open_gate"; + const Direction facing = direction(command.get_string_throw("direction")); + if (command.get_string_throw("event") != m_active || command.get_string_throw("map") != current.position.map){ + throw ParseException("story replay: supplied route has wrong event/map"); + } + if (current.facing != facing){ + throw ParseException("story replay: supplied gate command is not facing its gate"); + } + const MapData& map = map_named(m_data->maps, current.position.map); + Pokemon::GateState after = gates; + if (opens){ + const Pokemon::MapGate* gate = m_rules.card_key_held + ? Pokemon::closed_card_key_gate_faced(map, current.position.point, facing, gates) : nullptr; + if (gate == nullptr){ + throw ParseException("story replay: no card-key gate to open (or no Card Key)"); + } + after.opened.insert(Pokemon::gate_key(map.name, gate->id)); + }else{ + const Pokemon::MapSwitch* pressed = Pokemon::switch_pressed(map, current.position.point, facing); + if (pressed == nullptr){ + throw ParseException("story replay: no statue to press"); + } + const std::string key = Pokemon::switch_key(*pressed); + if (pressed->toggle && gates.switch_on(key)){ + after.switches_on.erase(key); + }else{ + after.switches_on.insert(key); + } + } + RouteStep step{.action = opens ? RouteAction::OPEN_GATE : RouteAction::PRESS_SWITCH, .direction = facing, .tiles = 0}; + step.end = current.position; + step.facing_after = facing; + step.gate_change = Pokemon::gate_change_between(gates, after); + gates = std::move(after); + return ReplayLeg{.step = step, .action = value.clone()}; +} +ReplayLeg ReplayExecutor::prepare_leg(const JsonValue& value, OverworldPose& current, Pokemon::GateState& gates) const{ const JsonObject& command = value.to_object_throw(); const std::string kind = command.get_string_throw("kind"); + if (kind == "open_gate" || kind == "press_switch"){ + return prepare_gate_leg(value, current, gates); + } if (kind == "walk"){ fields(value, {"event", "kind", "map", "direction", "tiles"}); }else if (kind == "transition"){ @@ -175,7 +231,7 @@ ReplayLeg ReplayExecutor::prepare_leg(const JsonValue& value, OverworldPose& cur } RouteStep step{.action = kind == "turn" ? RouteAction::FACE : RouteAction::WALK, .direction = facing, .tiles = (int)tiles}; for (int64_t n = 0; n < tiles; n++){ - const auto next = predict_overworld_press(m_data->maps, current, facing); + const auto next = predict_overworld_press(maps_through(gates), current, facing); if (!next){ throw ParseException("story replay: native model rejects supplied route"); } @@ -201,10 +257,11 @@ std::vector ReplayExecutor::prepare_route(const StoryStep& step){ throw ParseException("story replay: supplied route exceeds action bound"); } OverworldPose current = m_pose; + Pokemon::GateState gates = m_gates; std::vector route; m_legs.clear(); for (const JsonValue& command : commands){ - m_legs.emplace_back(prepare_leg(command, current)); + m_legs.emplace_back(prepare_leg(command, current, gates)); route.push_back(m_legs.back().step); } const OverworldPose goal = authored_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target")), m_data->maps); @@ -215,13 +272,15 @@ std::vector ReplayExecutor::prepare_route(const StoryStep& step){ } void ReplayExecutor::default_plan(const StoryStep& step){ const OverworldPose goal = authored_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target")), m_data->maps); - const auto planned = plan_overworld_route(m_data->maps, m_pose.position, {goal.position, goal.facing}, story_route_costs(), m_pose.facing); + const auto planned = plan_overworld_route_gated( + m_data->maps, m_pose.position, {goal.position, goal.facing}, m_gates, m_rules, story_route_costs(), m_pose.facing + ); JsonObject plan; plan["policy"] = "native-story-route-costs"; plan["exact_python_leg_comparison"] = "not-comparable-different-planner-policies"; JsonArray legs; if (planned){ - const MapPosition actual = follow_overworld_route(m_data->maps, m_pose.position, *planned); + const MapPosition actual = follow_overworld_route(m_data->maps, m_pose.position, *planned, m_gates); if (!(actual == goal.position)){ throw ParseException("story replay: native default plan did not reach target"); } @@ -239,8 +298,11 @@ void ReplayExecutor::timed_plan(const StoryStep& step, const std::vectormaps, m_pose.position, m_pose.facing); - const RoutePlanning planning{.maps = &m_data->maps, .start = m_pose.position, + SimScript script; + script.gates = m_gates; + script.card_key_held = m_rules.card_key_held; + OverworldSim sim(m_data->maps, m_pose.position, m_pose.facing, script); + const RoutePlanning planning{.maps = &m_data->maps, .gates = m_gates, .start = m_pose.position, .label = step.name, .wall_check = WallCheck::SKIP}; const std::string failure = OverworldSimWalker(sim).run(route, planning); const auto goal = authored_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target")), m_data->maps); @@ -259,11 +321,20 @@ void ReplayExecutor::timed_plan(const StoryStep& step, const std::vectormaps, m_pose, step.direction); + const auto next = predict_overworld_press(maps_through(m_gates), m_pose, step.direction); if (!next){ throw ParseException("story replay: supplied walk became blocked"); } @@ -277,14 +348,16 @@ StepOutcome ReplayExecutor::walk_leg(const RouteStep& step){ m_moves++; } m_pose.facing = step.facing_after; - const MapPosition followed = follow_overworld_route(m_data->maps, start.position, {step}); + const MapPosition followed = follow_overworld_route(m_data->maps, start.position, {step}, m_gates); if (!(followed == m_pose.position)){ throw ParseException("story replay: walker and independent native route replay disagree"); } m_basis = "model-prediction"; return StepOutcome{}; } -Pokemon::Outcome ReplayExecutor::replay_route(const StoryStep& step){ +Pokemon::Outcome ReplayExecutor::replay_route(const StoryStep& step, Pokemon::RunState& state){ + m_gates = state.gates; + m_rules = Pokemon::gate_rules_of(state); default_plan(step); const std::vector route = prepare_route(step); size_t moves = 0; @@ -309,10 +382,11 @@ Pokemon::Outcome ReplayExecutor::replay_route(const StoryStep& step){ if (signal() && !m_interrupted){ throw ParseException("story replay: physical encounter injection was not reached"); } + state.gates = m_gates; return Pokemon::outcome_ok(native_pose(m_pose)); } -Pokemon::Outcome ReplayExecutor::replay_step(const StoryStep& step){ - const auto next = predict_overworld_press(m_data->maps, m_pose, Pokemon::story_arg(step.args, "direction")); +Pokemon::Outcome ReplayExecutor::replay_step(const StoryStep& step, const Pokemon::RunState& state){ + const auto next = predict_overworld_press(maps_through(state.gates), m_pose, Pokemon::story_arg(step.args, "direction")); if (!next){ lose_pose("unknown-after-transition"); return Pokemon::outcome_failed("step_unresolved"); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.h index 0801680e0d..011fb4d9dc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_Executor.h @@ -3,10 +3,13 @@ */ #ifndef PokemonAutomation_PokemonFRLG_StoryReplay_Executor_H #define PokemonAutomation_PokemonFRLG_StoryReplay_Executor_H +#include #include #include +#include #include "Common/Cpp/Json/JsonArray.h" #include "Pokemon/AutoStory/Pokemon_StoryActions.h" +#include "Pokemon/Navigation/Pokemon_GatedTypes.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h" #include "PokemonFRLG_AutoStoryStepInterrupts.h" #include "PokemonFRLG_AutoStoryStepTable.h" @@ -46,14 +49,21 @@ class ReplayExecutor : public Pokemon::StoryStepExecutor{ // The replay's action for `id`: a ROUTE, STEP or MASH; every other // action is unsupported. Pokemon::StoryAction replay_action(StoryActionId id); - Pokemon::Outcome replay_route(const StoryStep& step); - Pokemon::Outcome replay_step(const StoryStep& step); + // A ROUTE or STEP reads the maps through the run's gates, and a + // route's open_gate and press_switch commands change them. + Pokemon::Outcome replay_route(const StoryStep& step, Pokemon::RunState& state); + Pokemon::Outcome replay_step(const StoryStep& step, const Pokemon::RunState& state); Pokemon::Outcome replay_scene(const StoryStep& step); const JsonObject* signal() const; const JsonObject& parameters(const StoryStep& step) const; - ReplayLeg prepare_leg(const JsonValue& command, OverworldPose& current) const; + // `gates`: the gates before the command, and after it. + ReplayLeg prepare_leg(const JsonValue& command, OverworldPose& current, Pokemon::GateState& gates) const; + ReplayLeg prepare_gate_leg(const JsonValue& command, const OverworldPose& current, Pokemon::GateState& gates) const; + // The maps as `gates` make them: a closed gate is a wall. + const std::vector& maps_through(const Pokemon::GateState& gates) const; std::vector prepare_route(const StoryStep& step); StepOutcome walk_leg(const RouteStep& step); + StepOutcome gate_leg(const RouteStep& step); void default_plan(const StoryStep& step); void timed_plan(const StoryStep& step, const std::vector& route); void lose_pose(std::string basis); @@ -66,6 +76,11 @@ class ReplayExecutor : public Pokemon::StoryStepExecutor{ const ReplayData* m_data; const JsonObject* m_scenario; OverworldPose m_pose; + // The gates open and switches on, and what the player may open, as + // the run state says at the start of each step. + Pokemon::GateState m_gates; + Pokemon::GateRules m_rules; + mutable std::optional>> m_resolved; bool m_known = true; std::string m_basis = "scripted-observation"; std::string m_active; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_IO.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_IO.cpp index 5246a3afe8..28a241bee2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_IO.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_StoryReplay_IO.cpp @@ -349,15 +349,26 @@ ReplayScreen between_steps_screen(std::string_view kind){ } return screen; } +namespace{ +// The run flags a scenario starts with: strings. +void check_start_flags(const JsonValue& flags){ + for (const JsonValue& flag : flags.to_array_throw()){ + flag.to_string_throw(); + } +} +} // namespace void validate_scenario(const ReplayData& data, const JsonValue& scenario){ const JsonObject& root = scenario.to_object_throw(); for (const auto& [name, value] : root){ - if (name != "entry" && name != "signals" && name != "between_steps" && name != "check_actions"){ + if (name != "entry" && name != "signals" && name != "between_steps" && name != "check_actions" && name != "start_flags"){ throw ParseException("story replay: unknown scenario field"); } if (name == "check_actions"){ value.to_boolean_throw(); } + if (name == "start_flags"){ + check_start_flags(value); + } } const JsonObject& entry = fields(root.get_value_throw("entry"), {"basis", "screen", "pose"}); expect(entry, "basis", "scripted"); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.01.plan.json index da40ebbfcb..45918aefdc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.01.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "13.01", - "title": "Cinnabar to the Pokemon Mansion: 1F and 2F up to 3F's statue, press it", + "title": "Cinnabar to the Pokemon Mansion: 1F and 2F up to 3F's room of holes, the statue switch pressed on the way", "start": { "map": "CinnabarIsland_PokemonCenter_1F", "tiles": [ @@ -16,7 +16,7 @@ }, "events": [ { - "id": "mansion_3f", + "id": "mansion_holes", "kind": "route", "action": "run", "args": { @@ -24,60 +24,19 @@ "map": "PokemonMansion_3F", "tiles": [ [ - 8, - 3 + 19, + 13 ] ], - "facing": "east" + "facing": "south" } }, - "why": "out of Cinnabar's Center, up to the Mansion door (8, 3), 1F (8, 33) up its stairs (10, 13) to 2F (6, 14), through 2F's rooms to the stairs (9, 3), onto 3F's (8, 3); all in the switch's clear state, which is the map's" - }, - { - "id": "to_statue", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "south", - "tiles": 3 - }, - { - "direction": "east", - "tiles": 4 - } - ] - }, - "why": "a tap a tile on 3F in the clear state: down to (8, 6) and east along row 6 to (12, 6), below the statue (12, 5)" - }, - { - "id": "face_statue", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "PokemonMansion_3F", - "tiles": [ - [ - 12, - 6 - ] - ], - "facing": "north" - }, - "why": "turn north to the statue (12, 5)" - }, - { - "id": "press_3f_statue", - "kind": "talk", - "why": "face the statue (12, 5) and press A: \"Press the secret switch?\"" - }, - { - "id": "press_3f", - "kind": "answer", - "why": "YES: \"Who wouldn't?\"; the switch flag is set, 3F's (17-19,11-12) open, its (21,4-8) close" + "why": "out of Cinnabar's Center, up to the Mansion door (8, 3), 1F up its stairs, 2F's northern rooms to the stairs (9, 3), and on 3F through the barrier (17-19, 11-12) that a statue press opens: the route presses the statue the cheapest way and walks on to (19, 13), the room of holes", + "gates_after": { + "switches": { + "mansion": true + } + } } ] }, @@ -85,10 +44,8 @@ "menu": "full", "notes": { "checkpoint": [ - "Starts at Cinnabar's nurse, facing her, where 12.03 ends (Fly to Pallet Town and Surf down Route 21, as PokeGuy goes after Koga). Ends on 3F (12, 6) facing the statue it just pressed.", - "The Mansion's statue switches: one flag for all four floors. Switch model (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc; one global flag, set on a press and applied on each floor's load; the pack's maps are the flag-clear state only). Assumed per floor (read from pokefirered; the overlay data on PokemonSimulation's maps/frlg-mansion-switches branch, seen 2026-11-12, has the same tiles open or closed per state): 1F set: (22-24,10-11), (27-29,25-26), (32-34,25-26) open, (31-33,18-19) closed. 2F set: (24-26,14-15), (10,30-32) open, (12,4-8) closed, (10,28-29) wall. 3F set: (17-19,11-12) open, (21,4-8) closed. B1F set: (12,10-12), (20-22,22-23) open, (33-35,20-21) and (16,28-30) closed. Clear = the map as it is.", - "13.01 walks only in the clear state; the press at its end sets the flag, and every row after walks the set state until a statue is pressed again (13.03 presses B1F's two).", - "Mansion trainers met on this walk: 1F Johnson wanders row 8, 2F Arnie (5, 23) and 3F Simon (6-8, 12-14) are off the route (the route takes 2F's northern rooms and 3F's (8, 3) arrival)." + "Starts at Cinnabar's nurse, facing her, where 12.03 ends (Fly to Pallet Town and Surf down Route 21, as PokeGuy goes after Koga). Ends on 3F (19, 13) facing south, in the room of holes, with the switch on.", + "The Mansion's statue switches: one flag for all four floors (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc), a toggle each press flips and each floor applies on load. The pinned maps (PokemonSimulation 4b886bb) carry it as gates: barriers that open when the switch is on or off, and the statues that press it. A route plans the presses itself (PRESS_SWITCH: face the statue, A, Yes, B through the text) wherever a barrier is in the way, and the step's gates_after says the switch it leaves; a checkpoint that starts from a save says the switch in start_gates." ] } }, @@ -99,11 +56,11 @@ "map": "PokemonMansion_3F", "tiles": [ [ - 12, - 6 + 19, + 13 ] ], - "facing": "north" + "facing": "south" } } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.02.plan.json index db95982209..4a211eb32f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.02.plan.json @@ -3,167 +3,53 @@ "game": "frlg", "checkpoint": { "id": "13.02", - "title": "Pokemon Mansion 3F through the switch's opening, the hole to 1F, 1F's stairs to B1F", + "title": "Pokemon Mansion 3F's hole to 1F, 1F's stairs to B1F", "start": { "map": "PokemonMansion_3F", "tiles": [ [ - 12, - 6 + 19, + 13 ] ], - "facing": "north" + "facing": "south" }, "events": [ { - "id": "to_barrier", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "east", - "tiles": 7 - }, - { - "direction": "south", - "tiles": 4 - } - ] - }, - "why": "a tap a tile: east along row 6 to (19, 6), south to (19, 10), above 3F's opening (17-19, 11-12), set open by the press (the map has it closed)" - }, - { - "id": "into_opening_1", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_3F", - "tiles": [ - [ - 19, - 11 - ] - ], - "facing": "south" - }, - "why": "a step onto (19, 11): the opening is open only in the set state, closed on the map" - }, - { - "id": "into_opening_2", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_3F", - "tiles": [ - [ - 19, - 12 - ] - ], - "facing": "south" - }, - "why": "a step onto (19, 12), the opening's second row" - }, - { - "id": "through_opening", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_3F", - "tiles": [ - [ - 19, - 13 - ] - ], - "facing": "south" - }, - "why": "a step through onto (19, 13), the room of holes" - }, - { - "id": "to_hole_edge", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "south", - "tiles": 4 - } - ] - }, - "why": "a tap a tile down column 19 to (19, 17), above the hole row (18..20, 18); Braydon (22, 13) looks south along column 22, so x 19 is clear" - }, - { - "id": "down_the_hole", - "kind": "step", + "id": "to_ted_room", + "kind": "route", + "action": "run", "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_1F", - "tiles": [ - [ - 20, - 22 - ] - ], - "facing": "south" + "target": { + "map": "PokemonMansion_1F", + "tiles": [ + [ + 17, + 23 + ] + ], + "facing": "south" + } }, - "why": "a step onto the hole (19, 18), which drops to 1F (20, 22) (3F map.json warp to 1F warp 8)" + "why": "south to the hole row (18..20, 18), which drops to 1F's room (19..20, 22), west along row 23 to the room's west wall, out of the sight line of Ted at (22, 24) facing west (4 tiles: 18..21 on row 24)" }, { - "id": "to_stairs", - "kind": "legs", - "action": "taps", + "id": "past_ted", + "kind": "route", + "action": "run", "args": { - "legs": [ - { - "direction": "south", - "tiles": 1 - }, - { - "direction": "west", - "tiles": 3 - }, - { - "direction": "south", - "tiles": 2 - }, - { - "direction": "east", - "tiles": 1 - }, - { - "direction": "south", - "tiles": 2 - }, - { - "direction": "east", - "tiles": 4 - }, - { - "direction": "south", - "tiles": 2 - }, - { - "direction": "east", - "tiles": 4 - }, - { - "direction": "north", - "tiles": 2 - } - ] + "target": { + "map": "PokemonMansion_1F", + "tiles": [ + [ + 17, + 25 + ] + ], + "facing": "south" + } }, - "why": "a tap a tile along 1F's southern rooms to (26, 27): west to column 17 (Ted (22, 24) looks west along row 24 and sees x 18-21 only), down to row 27, east on to (22, 27), (22, 29), (26, 29) and up to (26, 27), east of the stairs (25, 27), an arrow warp to B1F (34, 29)" + "why": "south down the west wall: (17, 24) is the one tile of row 24 past Ted's 4-tile line" }, { "id": "down_to_b1f", @@ -181,18 +67,26 @@ "facing": "west" } }, - "why": "west from (26, 27) onto the stairs (25, 27), an arrow warp, to B1F's (34, 29)" + "why": "south to the hole row (18..20, 18), which drops to 1F's east rooms (a one-way warp), through them to the stairs (25, 27), an arrow warp, to B1F's (34, 29); the switch stays on", + "gates_after": { + "switches": { + "mansion": true + } + } } - ] + ], + "start_gates": { + "switches": { + "mansion": true + } + } }, "execution": { "menu": "full", "notes": { "checkpoint": [ - "Starts where 13.01 ends, 3F (12, 6) facing the pressed statue. Ends on B1F (34, 29), the foot of 1F's stairs, in the set state.", - "Barriers: Switch model (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc; one global flag, set on a press and applied on each floor's load; the pack's maps are the flag-clear state only). Assumed per floor (read from pokefirered; the overlay data on PokemonSimulation's maps/frlg-mansion-switches branch, seen 2026-11-12, has the same tiles open or closed per state): 1F set: (22-24,10-11), (27-29,25-26), (32-34,25-26) open, (31-33,18-19) closed. 2F set: (24-26,14-15), (10,30-32) open, (12,4-8) closed, (10,28-29) wall. 3F set: (17-19,11-12) open, (21,4-8) closed. B1F set: (12,10-12), (20-22,22-23) open, (33-35,20-21) and (16,28-30) closed. Clear = the map as it is.", - "This row walks 3F and 1F in the set state: 3F (19, 11-12) are open, so the three single steps are declared (the map has the barrier there); the holes (18..20, 18) drop to 1F (19, 22) and (20, 22), and 1F's east rooms (x 17-37, y 20-33) are reachable only by them (a wall at x 16 splits them from the west).", - "The hole is the way pokeguy goes (floor drop, then the staircase to the basement, before 1:19:56)." + "Starts where 13.01 ends, 3F (19, 13) facing south, the switch on (start_gates). Ends on B1F (34, 29), the foot of 1F's stairs. The hole is the way pokeguy goes (floor drop, then the staircase to the basement, before 1:19:56).", + "The Mansion's statue switches: one flag for all four floors (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc), a toggle each press flips and each floor applies on load. The pinned maps (PokemonSimulation 4b886bb) carry it as gates: barriers that open when the switch is on or off, and the statues that press it. A route plans the presses itself (PRESS_SWITCH: face the statue, A, Yes, B through the text) wherever a barrier is in the way, and the step's gates_after says the switch it leaves; a checkpoint that starts from a save says the switch in start_gates." ] } }, @@ -211,4 +105,4 @@ } } } -} +} \ No newline at end of file diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.03.plan.json index bf9b0b8466..e73298c632 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.03.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "13.03", - "title": "Pokemon Mansion B1F: the statue by Lewis's room, the Elixir, TM14, the statue by the Elixir room", + "title": "Pokemon Mansion B1F: the Elixir and TM14", "start": { "map": "PokemonMansion_B1F", "tiles": [ @@ -16,176 +16,27 @@ }, "events": [ { - "id": "to_lewis_room", - "kind": "legs", - "action": "taps", + "id": "to_elixir", + "kind": "route", + "action": "run", "args": { - "legs": [ - { - "direction": "west", - "tiles": 7 - }, - { - "direction": "north", - "tiles": 9 - }, - { - "direction": "west", - "tiles": 5 - } - ] - }, - "why": "B1F arrives in the set state (the flag is set), which closes its north: a tap a tile west to (27, 29), up column 27 to (27, 20) and west along row 20 to (22, 20), above the opening (20-22, 22-23), set open" - }, - { - "id": "into_room_1", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 22, - 21 - ] - ], - "facing": "south" - }, - "why": "a step to (22, 21)" - }, - { - "id": "into_room_2", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 22, - 22 - ] - ], - "facing": "south" - }, - "why": "a step onto (22, 22): the opening (20-22, 22-23) is open only in the set state, closed on the map" - }, - { - "id": "into_room_3", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 22, - 23 - ] - ], - "facing": "south" - }, - "why": "a step onto (22, 23), the opening's second row" - }, - { - "id": "to_statue", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "south", - "tiles": 1 - }, - { - "direction": "east", - "tiles": 1 - }, - { - "direction": "south", - "tiles": 6 - }, - { - "direction": "east", - "tiles": 1 - } - ] - }, - "why": "a tap a tile down to (22, 24), east to (23, 24) and down column 23 to (23, 30), then east to (24, 30), below the statue (24, 29); Burglar Lewis wanders (19-21, 24-26) with sight 1, and a battle is taken as it comes (pokeguy passed without one)" - }, - { - "id": "face_statue", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 24, - 30 - ] - ], - "facing": "north" - }, - "why": "turn north to the statue (24, 29)" - }, - { - "id": "press_b1f_south", - "kind": "talk", - "why": "press A: \"Press the secret switch?\"" - }, - { - "id": "press_south", - "kind": "answer", - "why": "YES: the flag clears, B1F's north opens again ((12, 10-12) and (20-22, 22-23) close, (33-35, 20-21) and (16, 28-30) open: the map)" - }, - { - "id": "south_to_north", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "west", - "tiles": 9 - }, - { - "direction": "north", - "tiles": 10 - }, - { - "direction": "east", - "tiles": 14 - }, - { - "direction": "south", - "tiles": 2 - }, - { - "direction": "east", - "tiles": 4 - }, - { - "direction": "north", - "tiles": 16 - }, - { - "direction": "north", - "tiles": 1 - }, - { - "direction": "east", - "tiles": 1 - } - ] - }, - "why": "a tap a tile in the clear state, which is the map's: west to (15, 30), up column 15 to (15, 20), east along row 20 to (29, 20), down to (29, 22), east to (33, 22), up column 33 to (33, 5) (Ivan (34, 13) looks south along column 34 with sight 6, so not x 34), and east to (34, 5), facing (35, 5)" + "target": { + "map": "PokemonMansion_B1F", + "tiles": [ + [ + 34, + 5 + ] + ], + "facing": "east" + } + }, + "why": "B1F arrives with the switch on, which closes its north ((33-35, 20-21), (16, 28-30)): the route presses the statue it needs and walks up to (34, 5), beside the hidden ELIXIR on (35, 5)", + "gates_after": { + "switches": { + "mansion": false + } + } }, { "id": "hidden_elixir", @@ -194,55 +45,21 @@ }, { "id": "to_tm14", - "kind": "legs", - "action": "taps", + "kind": "route", + "action": "run", "args": { - "legs": [ - { - "direction": "south", - "tiles": 1 - }, - { - "direction": "west", - "tiles": 4 - }, - { - "direction": "south", - "tiles": 4 - }, - { - "direction": "west", - "tiles": 11 - }, - { - "direction": "north", - "tiles": 5 - }, - { - "direction": "east", - "tiles": 4 - } - ] + "target": { + "map": "PokemonMansion_B1F", + "tiles": [ + [ + 23, + 5 + ] + ], + "facing": "north" + } }, - "why": "a tap a tile back down: (34, 6), west to (30, 6), down to (30, 10), west along row 10 to (19, 10), up column 19 to (19, 5) and east to (23, 5), below TM14 (23, 4)" - }, - { - "id": "face_tm14", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 23, - 5 - ] - ], - "facing": "north" - }, - "why": "turn north to the ball" + "why": "back along the north rooms to (23, 5), below the ball (23, 4)" }, { "id": "tm14", @@ -260,76 +77,20 @@ "keep": ["tackle", "withdraw", "tail-whip", "water-gun", "bubble", "bite", "mega-kick", "water-pulse", "surf"] }, "why": "TM14 Blizzard over Dig (pokeguy, PokemonSimulation docs/progression/pokeguy-moves.md: Strength, Surf, Bite, Blizzard; the user approved the TM spend 2026-11-12), taught as soon as it is picked up; keep list: every move the lead can know but Dig, so the one other move (Dig) goes; fails if none or several are outside the list" - }, - { - "id": "to_north_statue", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "west", - "tiles": 4 - }, - { - "direction": "south", - "tiles": 5 - }, - { - "direction": "east", - "tiles": 11 - }, - { - "direction": "north", - "tiles": 4 - }, - { - "direction": "west", - "tiles": 3 - } - ] - }, - "why": "a tap a tile back: west to (19, 5), down column 19 to (19, 10), east along row 10 to (30, 10), up to (30, 6) and west to (27, 6), below the statue (27, 5)" - }, - { - "id": "face_north_statue", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 27, - 6 - ] - ], - "facing": "north" - }, - "why": "turn north to the statue (27, 5)" - }, - { - "id": "press_b1f_north", - "kind": "talk", - "why": "press A: \"Press the secret switch?\" (pokeguy 1:20:09 presses the statue before the TM, the Elixir between)" - }, - { - "id": "press_north", - "kind": "answer", - "why": "YES: the flag is set; (12, 10-12) open, (33-35, 20-21) and (16, 28-30) close" } - ] + ], + "start_gates": { + "switches": { + "mansion": true + } + } }, "execution": { "menu": "full", "notes": { "checkpoint": [ - "Starts on B1F (34, 29) where 13.02 ends. Ends below the second statue (27, 5), at (27, 6), with the flag set: (12, 10-12) is the opening the walk to the SECRET KEY takes.", - "Barriers: Switch model (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc; one global flag, set on a press and applied on each floor's load; the pack's maps are the flag-clear state only). Assumed per floor (read from pokefirered; the overlay data on PokemonSimulation's maps/frlg-mansion-switches branch, seen 2026-11-12, has the same tiles open or closed per state): 1F set: (22-24,10-11), (27-29,25-26), (32-34,25-26) open, (31-33,18-19) closed. 2F set: (24-26,14-15), (10,30-32) open, (12,4-8) closed, (10,28-29) wall. 3F set: (17-19,11-12) open, (21,4-8) closed. B1F set: (12,10-12), (20-22,22-23) open, (33-35,20-21) and (16,28-30) closed. Clear = the map as it is.", - "The two B1F statues are (24, 29) (press from (24, 30)) and (27, 5) (from (27, 6)). B1F is entered in the set state whichever way it was left, so the first press is a reset to clear: that opens the north, which the set state closes ((33-35, 20-21), (16, 28-30) are open in the clear state). The path to the Elixir and TM14 is the clear state, as the map is.", - "Open: Burglar Lewis (wandering (19-21, 24-26), sight 1: Growlithe, Ponyta Lv34) cannot be avoided in the room (its one way in, (22, 24), is beside his range; the sim meets him there and the AutoStory test lists to_statue as the one wanderer crossing it allows); the row relies on the normal battle code if he fights. Ivan (34, 13, looking south, sight 6) is passed on x 33. The Elixir is a hidden item: the walk faces it from (34, 5).", - "PokeGuy (1:19:56 to 1:20:21): basement statue, the Elixir 1:20:06, another statue 1:20:09, TM14 1:20:15." + "Starts on B1F (34, 29) where 13.02 ends, the switch on (start_gates). Ends below TM14's ball at (23, 5), with the switch as the route to the Elixir left it.", + "The Mansion's statue switches: one flag for all four floors (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc), a toggle each press flips and each floor applies on load. The pinned maps (PokemonSimulation 4b886bb) carry it as gates: barriers that open when the switch is on or off, and the statues that press it. A route plans the presses itself (PRESS_SWITCH: face the statue, A, Yes, B through the text) wherever a barrier is in the way, and the step's gates_after says the switch it leaves; a checkpoint that starts from a save says the switch in start_gates." ] } }, @@ -340,8 +101,8 @@ "map": "PokemonMansion_B1F", "tiles": [ [ - 27, - 6 + 23, + 5 ] ], "facing": "north" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.04.plan.json index b33ae0ce44..cada9585b4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-13.04.plan.json @@ -8,110 +8,35 @@ "map": "PokemonMansion_B1F", "tiles": [ [ - 27, - 6 + 23, + 5 ] ], "facing": "north" }, "events": [ - { - "id": "to_opening", - "kind": "legs", - "action": "taps", - "args": { - "legs": [ - { - "direction": "east", - "tiles": 3 - }, - { - "direction": "south", - "tiles": 4 - }, - { - "direction": "west", - "tiles": 17 - } - ] - }, - "why": "a tap a tile in the set state: east to (30, 6), down to (30, 10) and west along row 10 to (13, 10), east of the opening (12, 10-12), set open (closed on the map)" - }, - { - "id": "into_opening", - "kind": "step", - "args": { - "direction": "west" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 12, - 10 - ] - ], - "facing": "west" - }, - "why": "a step onto (12, 10): open only in the set state" - }, - { - "id": "through_opening", - "kind": "step", - "args": { - "direction": "west" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 11, - 10 - ] - ], - "facing": "west" - }, - "why": "a step through onto (11, 10)" - }, { "id": "to_key", - "kind": "legs", - "action": "taps", + "kind": "route", + "action": "run", "args": { - "legs": [ - { - "direction": "west", - "tiles": 3 - }, - { - "direction": "north", - "tiles": 4 - }, - { - "direction": "west", - "tiles": 3 - } - ] + "target": { + "map": "PokemonMansion_B1F", + "tiles": [ + [ + 5, + 6 + ] + ], + "facing": "south" + } }, - "why": "a tap a tile: west to (8, 10), up column 8 to (8, 6) and west to (5, 6), above the SECRET KEY (5, 7)" - }, - { - "id": "face_key", - "kind": "step", - "args": { - "direction": "south" - }, - "declared_after": { - "map": "PokemonMansion_B1F", - "tiles": [ - [ - 5, - 6 - ] - ], - "facing": "south" - }, - "why": "turn south to the ball" + "why": "to (5, 6), above the SECRET KEY (5, 7): the opening (12, 10-12) is open only with the switch on, so the route presses the statue it passes", + "gates_after": { + "switches": { + "mansion": true + } + } }, { "id": "secret_key", @@ -137,15 +62,19 @@ }, "why": "out to the Mansion's door (pokeguy 1:20:24-36, his ESCAPE ROPE count 3 to 2); the player stands on (8, 4), where 14.01 starts" } - ] + ], + "start_gates": { + "switches": { + "mansion": false + } + } }, "execution": { "menu": "full", "notes": { "checkpoint": [ - "Starts below B1F's second statue, at (27, 6), where 13.03 ends, the flag set. Ends outside the Mansion door on Cinnabar (8, 4) facing south, where 14.01 starts.", - "Barriers: Switch model (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc; one global flag, set on a press and applied on each floor's load; the pack's maps are the flag-clear state only). Assumed per floor (read from pokefirered; the overlay data on PokemonSimulation's maps/frlg-mansion-switches branch, seen 2026-11-12, has the same tiles open or closed per state): 1F set: (22-24,10-11), (27-29,25-26), (32-34,25-26) open, (31-33,18-19) closed. 2F set: (24-26,14-15), (10,30-32) open, (12,4-8) closed, (10,28-29) wall. 3F set: (17-19,11-12) open, (21,4-8) closed. B1F set: (12,10-12), (20-22,22-23) open, (33-35,20-21) and (16,28-30) closed. Clear = the map as it is.", - "The walk west along row 10 crosses (12, 10-12), which is closed on the pack's map and open in the set state: its two steps are declared because the pack's map has the barrier there.", + "Starts below TM14's ball, at (23, 5), where 13.03 ends. Ends outside the Mansion door on Cinnabar (8, 4) facing south, where 14.01 starts.", + "The Mansion's statue switches: one flag for all four floors (pokefirered data/scripts/pokemon_mansion.inc, PokemonMansion_*F scripts.inc), a toggle each press flips and each floor applies on load. The pinned maps (PokemonSimulation 4b886bb) carry it as gates: barriers that open when the switch is on or off, and the statues that press it. A route plans the presses itself (PRESS_SWITCH: face the statue, A, Yes, B through the text) wherever a barrier is in the way, and the step's gates_after says the switch it leaves; a checkpoint that starts from a save says the switch in start_gates.", "Not taken: the FULL RESTORE (2F (2, 29)) and TM22 (1F (6, 21)); pokeguy leaves by Escape Rope after the key (1:20:24-36)." ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04.plan.json index 330d22ae1d..6419b15000 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04.plan.json @@ -32,7 +32,7 @@ "notes": { "checkpoint": [ "Starts below Victory Road's mouth, where 19.03 ends. Strength is taught here, at the cave's start, because every floor's boulders need it (pokeguy teaches it over Water Pulse at Victory Road, 1:43:24 on his video: the 12.02 note that pointed at 19.02, D3 meant this row).", - "Ends on Victory Road 1F's south end (11, 20). The boulder puzzles of the three floors are not authored: the maps have the boulders as objects but not the switches' barriers (1F (12, 14) and (12, 15); 2F (13, 10) and (13, 11), (33, 16) and (33, 17); 3F (12, 12) and (12, 13)) nor which tiles the switches press (1F (20, 16); 2F (2, 19), (14, 19); 3F (7, 7)), so the planner would walk through them. Pokemon_BoulderSolver in PokemonFRLG_AutoStoryBoulders_Tests.cpp holds the data and the search; the barriers need the user's map edit (TODO)." + "Ends on Victory Road 1F's south end (11, 20), where 19.04b, the first of the cave's boulder rows, starts." ] } }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04b.plan.json new file mode 100644 index 0000000000..2ab0158fbb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04b.plan.json @@ -0,0 +1,196 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "19.04b", + "title": "Victory Road 1F: the boulder onto the floor switch, up to 2F", + "start": {"map": "VictoryRoad_1F", "tiles": [[11, 20]], "facing": "north"}, + "events": [ + { + "id": "behind_boulder_1", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[7, 17]]}}, + "why": "north of the south boulder (7, 18), the one that reaches the switch" + }, + { + "id": "push_south", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "south", "tiles": 1, "activate": true}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[7, 18]], "facing": "south"}, + "why": "Strength on (A, YES), the boulder down to (7, 19), the row it runs east along" + }, + { + "id": "by_boulder_2_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[6, 18]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_2", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[6, 19]]}}, + "why": "round to its west side" + }, + { + "id": "push_east_row19", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "east", "tiles": 5}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[11, 19]], "facing": "east"}, + "why": "east along row 19 to (12, 19), below the gap north" + }, + { + "id": "by_boulder_3_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[10, 20]]}}, + "why": "round the pushed boulder to (10, 20), so the step onto the cave mouth (11, 20) is eastward: south onto it would take its warp out to Route 23" + }, + { + "id": "behind_boulder_3", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[12, 20]]}}, + "why": "below it, by the cave's mouth" + }, + { + "id": "push_north_col12", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "north", "tiles": 2}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[12, 18]], "facing": "north"}, + "why": "north to (12, 17), the corridor east to the switch" + }, + { + "id": "by_boulder_4_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[11, 18]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_4", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[11, 17]]}}, + "why": "west of it" + }, + { + "id": "push_east_row17", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "east", "tiles": 7}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[18, 17]], "facing": "east"}, + "why": "east along row 17 to (19, 17)" + }, + { + "id": "by_boulder_5_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[18, 18]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_5", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[19, 18]]}}, + "why": "below it" + }, + { + "id": "push_north_col19", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "north", "tiles": 2}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[19, 16]], "facing": "north"}, + "why": "north to (19, 15), level with the switch's column" + }, + { + "id": "by_boulder_6_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[20, 14]]}}, + "why": "round the pushed boulder, now on (19, 15), over the switch's column (20, 16) to (20, 14): the maps still show it where it started, and the planner would walk through its new tile" + }, + { + "id": "by_boulder_6_top", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[18, 14]]}}, + "why": "west along row 14, above the boulder, to above its west side" + }, + { + "id": "behind_boulder_6", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[18, 15]]}}, + "why": "west of it" + }, + { + "id": "push_east_col20", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "east", "tiles": 1}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[19, 15]], "facing": "east"}, + "why": "east to (20, 15), above the switch" + }, + { + "id": "by_boulder_7_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[19, 14]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_7", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[20, 14]]}}, + "why": "above it" + }, + { + "id": "push_onto_switch", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "south", "tiles": 1}, + "declared_after": {"map": "VictoryRoad_1F", "tiles": [[20, 15]], "facing": "south"}, + "why": "onto the switch (20, 16): VAR_MAP_SCENE_VICTORY_ROAD_1F is set and the barrier (12, 14), (12, 15) opens for good", + "gates_after": {"switches": {"VictoryRoad_1F/floor_switch_1": true}} + }, + { + "id": "below_ladder", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_1F", "tiles": [[4, 7]], "facing": "north"}}, + "why": "through the opened barrier, over the platform and round to column 4 below the ladder: column 5 is in Rolando's sight (the cooltrainer at (5, 2), facing south, sight 4)" + }, + { + "id": "ladder_2f", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[1, 9]]}}, + "why": "north up column 4, past Rolando's line, and west onto the ladder (3, 2), which leads to 2F's (1, 9)" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts on Victory Road 1F's south end (11, 20), where 19.04 ends; Strength is HM04 on the lead (19.04).", + "The pushes are the boulder solver's (PokemonFRLG_AutoStoryBoulders_Tests.cpp) for the switch (20, 16), from the map's boulders (pokefirered data/maps/VictoryRoad_1F/map.json) and PokemonSimulation's floor switch and barrier (VAR_MAP_SCENE_VICTORY_ROAD_1F, one-way). Strength stays on until the player leaves the map, so only the first push asks.", + "Ends on Victory Road 2F (1, 9), the foot of 1F's ladder." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "VictoryRoad_2F", "tiles": [[1, 9]]} + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04c.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04c.plan.json new file mode 100644 index 0000000000..3cc87410b5 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04c.plan.json @@ -0,0 +1,220 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "19.04c", + "title": "Victory Road 2F and 3F: the west boulder and the north boulder onto their switches", + "start": {"map": "VictoryRoad_2F", "tiles": [[1, 9]]}, + "events": [ + { + "id": "behind_boulder_1", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[7, 17]]}}, + "why": "east of the west boulder (6, 17)" + }, + { + "id": "push_west", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "west", "tiles": 2, "activate": true}, + "declared_after": {"map": "VictoryRoad_2F", "tiles": [[5, 17]], "facing": "west"}, + "why": "Strength on again (a new map), the boulder west to (4, 17)" + }, + { + "id": "by_boulder_2_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[5, 16]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_2", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[4, 16]]}}, + "why": "above it" + }, + { + "id": "push_south", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "south", "tiles": 2}, + "declared_after": {"map": "VictoryRoad_2F", "tiles": [[4, 18]], "facing": "south"}, + "why": "south to (4, 19), the switch's row" + }, + { + "id": "by_boulder_3_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[5, 18]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_3", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[5, 19]]}}, + "why": "east of it" + }, + { + "id": "push_onto_2f_switch", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "west", "tiles": 2}, + "declared_after": {"map": "VictoryRoad_2F", "tiles": [[3, 19]], "facing": "west"}, + "why": "onto the switch (2, 19): VAR_MAP_SCENE_VICTORY_ROAD_2F_BOULDER1 is set and the barrier (13, 10), (13, 11) opens for good", + "gates_after": {"switches": {"VictoryRoad_2F/floor_switch_1": true}} + }, + { + "id": "ladder_3f", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[5, 2]]}}, + "why": "to the ladder (3, 3), which leads to 3F's (5, 2)" + }, + { + "id": "behind_boulder_4", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[32, 6]]}}, + "why": "east along 3F's north side to below the north boulder (32, 5)" + }, + { + "id": "push_north", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "north", "tiles": 2, "activate": true}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[32, 4]], "facing": "north"}, + "why": "Strength on (3F is a new map), the boulder up to (32, 3), the row west" + }, + { + "id": "by_boulder_5_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[33, 4]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_5", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[33, 3]]}}, + "why": "east of it" + }, + { + "id": "push_west_row3", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "west", "tiles": 21}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[12, 3]], "facing": "west"}, + "why": "west along row 3 to (12, 3)" + }, + { + "id": "by_boulder_6_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[12, 2]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_6", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[11, 2]]}}, + "why": "above it, now on (11, 3)" + }, + { + "id": "push_south_col11", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "south", "tiles": 1}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[11, 3]], "facing": "south"}, + "why": "down to (11, 4), the row west to the switch" + }, + { + "id": "by_boulder_7_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[12, 3]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_7", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[12, 4]]}}, + "why": "east of it" + }, + { + "id": "push_west_row4", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "west", "tiles": 5}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[7, 4]], "facing": "west"}, + "why": "west along row 4 to (6, 4)" + }, + { + "id": "by_boulder_8_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[7, 3]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_8", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[6, 3]]}}, + "why": "above it" + }, + { + "id": "push_south_col6", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "south", "tiles": 3}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[6, 6]], "facing": "south"}, + "why": "down to (6, 7), beside the switch" + }, + { + "id": "by_boulder_9_corner", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[5, 6]]}}, + "why": "round the pushed boulder, which the maps still show where it started: the planner would walk through its new tile" + }, + { + "id": "behind_boulder_9", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[5, 7]]}}, + "why": "west of it" + }, + { + "id": "push_onto_3f_switch", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "east", "tiles": 1}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[6, 7]], "facing": "east"}, + "why": "onto the switch (7, 7): VAR_MAP_SCENE_VICTORY_ROAD_3F is set and the barrier (12, 12), (12, 13) opens for good", + "gates_after": {"switches": {"VictoryRoad_3F/floor_switch_1": true}} + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts on Victory Road 2F (1, 9), where 19.04b ends.", + "Two floor switches, each the boulder solver's pushes (PokemonFRLG_AutoStoryBoulders_Tests.cpp) on the decomp's maps: 2F's (2, 19) with the boulder at (6, 17), then, up the ladder (3, 3), 3F's (7, 7) with the boulder at (32, 5). Strength asks again on each new map.", + "Ends on 3F (6, 7), beside the pressed switch; 3F's barrier is open, the way to its hole (34, 18)." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "VictoryRoad_3F", "tiles": [[6, 7]], "facing": "east"} + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json new file mode 100644 index 0000000000..40ad9b42bb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.04d.plan.json @@ -0,0 +1,157 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "19.04d", + "title": "Victory Road 3F's hole: a boulder down to 2F, onto its switch, out to Route 23", + "start": {"map": "VictoryRoad_3F", "tiles": [[6, 7]], "facing": "east"}, + "events": [ + { + "id": "hole_way_1", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[6, 6]]}}, + "why": "north off the pressed switch: the maps still show its button bare, and the planner would step onto the boulder at (7, 7)" + }, + { + "id": "hole_way_2", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[25, 8]]}}, + "why": "east along 3F's north side and down to (25, 8), below the gap (25, 7) onto the platform" + }, + { + "id": "hole_way_3", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[25, 6]]}}, + "why": "up through the gap onto the platform's second row: (25, 5) is in Alexa's line (the cooltrainer at (21, 5), facing east, sight 4)" + }, + { + "id": "hole_way_4", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[16, 6]]}}, + "why": "west along row 6, below Alexa, to the platform's west end" + }, + { + "id": "hole_way_5", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[16, 13]]}}, + "why": "down the column x 16 to the barrier's row" + }, + { + "id": "hole_way_6", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[11, 13]]}}, + "why": "west through the opened barrier (12, 13)" + }, + { + "id": "hole_way_7", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[4, 14]]}}, + "why": "round the west room to (4, 14), the way down to the south room" + }, + { + "id": "hole_way_8", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[17, 15]]}}, + "why": "east along row 15, north of Caroline's line (the cooltrainer at (11, 16), facing east, sight 5) and Colby's (the cooltrainer at (10, 17), facing west, sight 5)" + }, + { + "id": "hole_way_9", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[17, 19]]}}, + "why": "down x 17, east of Caroline's line, to the south room's bottom row" + }, + { + "id": "behind_hole_boulder", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_3F", "tiles": [[32, 18]]}}, + "why": "east along row 19 to below, then west of, the boulder (33, 18) beside the hole" + }, + { + "id": "push_into_hole", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "east", "tiles": 1, "activate": true}, + "declared_after": {"map": "VictoryRoad_3F", "tiles": [[33, 18]], "facing": "east"}, + "why": "Strength on (the map was left for the save), the boulder into the hole (34, 18); it falls to 2F (33, 19), where the game now shows it (FLAG_HIDE_VICTORY_ROAD_2F_BOULDER cleared)" + }, + { + "id": "drop_to_2f", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[34, 19]]}}, + "why": "east onto the hole (34, 18), down to 2F's (34, 19), east of the fallen boulder; a route, so the fade is waited out before the next press" + }, + { + "id": "push_west_row19", + "kind": "game_action", + "action": "push_boulder", + "args": {"direction": "west", "tiles": 19, "activate": true}, + "declared_after": {"map": "VictoryRoad_2F", "tiles": [[15, 19]], "facing": "west"}, + "why": "Strength on (a new map), the boulder west along row 19 to the switch (14, 19): VAR_MAP_SCENE_VICTORY_ROAD_2F_BOULDER2 is set and the barrier (33, 16), (33, 17) opens for good", + "gates_after": {"switches": {"VictoryRoad_2F/floor_switch_2": true}} + }, + { + "id": "exit_way_1", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[31, 19]]}}, + "why": "back east along row 19 to (31, 19), south of Daisuke's line (the black belt at (20, 11), looking south and west, sight 4)" + }, + { + "id": "exit_way_2", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[35, 17]]}}, + "why": "north by (31, 18) and east through the opened barrier (33, 17) to beside the ladder (36, 17), below Nelson (the rocker at (31, 16), facing west)" + }, + { + "id": "above_exit", + "kind": "route", + "action": "run", + "args": {"target": {"map": "VictoryRoad_2F", "tiles": [[48, 11]], "facing": "south"}}, + "why": "onto the ladder (36, 17), 3F's east corridor to its ladder (37, 10), down to 2F (38, 9) and east to above the exit (48, 12)" + }, + { + "id": "onto_exit", + "kind": "step", + "args": {"direction": "south"}, + "declared_after": {"map": "VictoryRoad_2F", "tiles": [[48, 12]], "facing": "south"}, + "why": "south onto the exit mat (48, 12), a warp taken by walking south on it" + }, + { + "id": "exit_route23", + "kind": "step", + "args": {"direction": "south"}, + "declared_after": {"map": "Route23", "tiles": [[18, 29]], "facing": "south"}, + "why": "south again on the mat: out of the cave mouth (18, 28), which the game walks the player off a tile, onto Route 23 (18, 29)" + } + ], + "start_gates": {"switches": {"VictoryRoad_3F/floor_switch_1": true}} + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts on Victory Road 3F (6, 7), where 19.04c ends; 3F's switch is on (start_gates) and so its barrier is open.", + "3F's boulder (33, 18) pushed into the hole (34, 18) lands on 2F (33, 19); the player follows it down the hole and pushes it west onto 2F's second switch (14, 19), which opens the barrier (33, 16), (33, 17) before 2F's ladder (36, 17). The maps show 2F's boulder from the start; the game hides it until 3F's falls.", + "Ends on Route 23 (18, 29), facing south, a tile below the cave mouth, where 19.05 starts." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": {"map": "Route23", "tiles": [[18, 29]], "facing": "south"} + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.05.plan.json index 5e46ffceec..0c9ce04697 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.05.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-19.05.plan.json @@ -4,7 +4,7 @@ "checkpoint": { "id": "19.05", "title": "Victory Road's exit to Indigo Plateau: heal at its Center", - "start": {"map": "Route23", "tiles": [[18, 28]], "facing": "south"}, + "start": {"map": "Route23", "tiles": [[18, 29]], "facing": "south"}, "events": [ { "id": "indigo_door", @@ -13,7 +13,7 @@ "args": { "target": {"map": "IndigoPlateau_Exterior", "tiles": [[11, 7]], "facing": "north"} }, - "why": "from Victory Road's second-floor exit (Route 23 (18, 28)) north along Route 23 to Indigo Plateau (its north connection) and up to below the Center's door (11, 6)" + "why": "from below Victory Road's second-floor exit (Route 23 (18, 29)) north along Route 23 to Indigo Plateau (its north connection) and up to below the Center's door (11, 6)" }, { "id": "indigo_nurse", @@ -35,7 +35,7 @@ "menu": "full", "notes": { "checkpoint": [ - "Starts on Route 23 (18, 28), where Victory Road 2F's exit (48, 12) leaves the player, facing south. Victory Road's floors are not authored (19.04's note), so this row's start is its own (starts_after_unauthored_rows()).", + "Starts on Route 23 (18, 29), facing south, where 19.04d ends: Victory Road 2F's exit (48, 12) lets out on the cave mouth (18, 28), and the game walks the player a tile off it.", "Ends at Indigo Plateau's nurse below the counter (13, 12): the save point of the League's door, where the first League row (Lorelei) starts." ] } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 2de75ee5a7..7072335806 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1528,8 +1528,8 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/Navigation/Pokemon_RuntimeMap.h Source/Pokemon/Navigation/Pokemon_RuntimeMap_Tests.cpp Source/Pokemon/Navigation/Pokemon_RuntimeMap_Tests.h - Source/Pokemon/Navigation/Pokemon_NavigationTestMaps.h Source/Pokemon/Navigation/Pokemon_NavigationGateTestMaps.h + Source/Pokemon/Navigation/Pokemon_NavigationTestMaps.h Source/Pokemon/Navigation/Pokemon_RouteLog.cpp Source/Pokemon/Navigation/Pokemon_RouteLog.h Source/Pokemon/Navigation/Pokemon_RouteLog_Tests.cpp @@ -2029,6 +2029,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBikeTaps.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldBike_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGatedRoute.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGateMaps_Tests.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldGates_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle.h @@ -2128,8 +2130,12 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows16_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows19_Tests.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryGates_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryMansion_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBoulders_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVictoryRoad_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows13_Tests.h diff --git a/devtools/maps/map-resources.lock.json b/devtools/maps/map-resources.lock.json index 24f10bf535..6f55191d46 100644 --- a/devtools/maps/map-resources.lock.json +++ b/devtools/maps/map-resources.lock.json @@ -3,9 +3,9 @@ "repository": "dayfine/PokemonSimulation", "games": { "frlg": { - "revision": "0c46df1e5e9abe79016f2c8610aeb784835768fe", + "revision": "1cacf81b2377ec1413317d905ad5415f6fe8dad5", "manifest_path": "data/maps/runtime-manifest.json", - "manifest_sha256": "70f1947e4b2474319e87959480abad04f130834d235ef7b8a2f24a0256314c14" + "manifest_sha256": "0fbd71b8f985746c673ef530fa69fea17b7c6b808156fc7d7dbdadade7e7dd9a" } } }