diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp index 3933913e12..56aadd3bf0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_SaveCardReader.cpp @@ -80,6 +80,7 @@ class PlaceNameMatcher : public OCR::SmallDictionaryMatcher{ {"vermilion-city", "Vermilion City"}, {"celadon-city", "Celadon City"}, {"rocket-hideout", "Rocket Hideout"}, + {"fuchsia-city", "Fuchsia City"}, }){ JsonArray names; names.push_back(std::string(name)); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index f6d168d32a..d22d14caee 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -99,6 +99,10 @@ constexpr std::string_view MAP_NAMES[] = { "RocketHideout_B2F", "RocketHideout_B3F", "RocketHideout_B4F", + // Fuchsia City's Center, Koga's gym and the Warden's house. + "FuchsiaCity", + "FuchsiaCity_Gym", + "FuchsiaCity_WardensHouse", "CeruleanCave_1F", "CeruleanCave_2F", "CeruleanCave_B1F", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 38b6dd563a..29b5308a6d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -102,6 +102,7 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryVermilion(database); add_tests_AutoStoryVermilionGym(database); add_tests_AutoStoryCeladon(database); + add_tests_AutoStoryFuchsiaGym(database); } void add_tests(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 788385d2b4..242f892144 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -357,6 +357,7 @@ std::string save_card_place(const std::string& map){ {"LavenderTown", "lavender-town"}, {"CeladonCity", "celadon-city"}, {"RocketHideout", "rocket-hideout"}, + {"FuchsiaCity", "fuchsia-city"}, }; for (const auto& [prefix, place] : PLACES){ if (map == prefix || map.rfind(prefix + "_", 0) == 0){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp new file mode 100644 index 0000000000..c461dd1832 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp @@ -0,0 +1,270 @@ +/* AutoStory Fuchsia Gym Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Rows 12.01 and 12.02 (StoryData/frlg-12.01.plan.json, 12.02) on the + * overworld sim: from Fuchsia's nurse into the gym past Jugglers Kayden + * and Kirk and round its top edge to west of Koga; and from Koga out to + * the Warden and back to the nurse. And the lead's attacks against the + * gym's parties. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStoryMember.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +const std::string GYM = "FuchsiaCity_Gym"; + +struct AutoStoryFuchsiaGymInput{ + std::string name; + std::function body; +}; + +struct AutoStoryFuchsiaGymExpectation{ + std::string_view description; +}; + +struct AutoStoryFuchsiaGymCase{ + AutoStoryFuchsiaGymInput input; + AutoStoryFuchsiaGymExpectation expectation; +}; + +class Test_AutoStoryFuchsiaGym : public UnitTest{ +public: + explicit Test_AutoStoryFuchsiaGym(AutoStoryFuchsiaGymCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - Simulation: {}", 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::format("{}: {}", e.name(), e.message()); + } + } + +private: + AutoStoryFuchsiaGymCase m_case; +}; + +const StoryCheckpoint& checkpoint(std::string_view id){ + for (const StoryCheckpoint& row : story_checkpoints()){ + if (row.id == id){ + return row; + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, std::format("No checkpoint {}.", id)); +} + +// The rows on the sim, which can't walk into a Center with no map. Kept +// across sims: the trainers fought. +struct GymWalk{ + StoryPose at; + std::optional sim; + std::vector fought; + + explicit GymWalk(StoryPose start) + : at(std::move(start)) + { + place(); + } + // A fresh sim on `at`, after a step it can't walk. + void place(){ + if (sim){ + const std::vector& beaten = sim->state().trainers_beaten; + fought.insert(fought.end(), beaten.begin(), beaten.end()); + } + sim.emplace(story_maps(), MapPosition{at.map, at.tile}, *at.facing); + } + std::vector all_fought() const{ + std::vector all = fought; + const std::vector& beaten = sim->state().trainers_beaten; + all.insert(all.end(), beaten.begin(), beaten.end()); + return all; + } +}; + +// A step of a row on the sim: row_step_on_sim(), but the way into a +// Center, which has no map, and Koga's battle, which a talk starts, leave +// the player where the table says. +std::string gym_step_on_sim(const StoryStep& step, const std::string& id, GymWalk& walk){ + const bool center = step.action == CENTER_ENTER_VARIANT; + if (center || (step.kind == StoryStepKind::BATTLE && step.name == "koga")){ + walk.at = *story_pose(Pokemon::pose_of(*step.pose_after)); + if (center){ + walk.place(); + } + return ""; + } + return row_step_on_sim(*walk.sim, walk.at, step, id); +} + +// Row `id`'s steps on the sim from `walk.at`: the failure, or empty. +std::string row_on_sim(std::string_view id, GymWalk& walk){ + const StoryCheckpoint& row = checkpoint(id); + for (const StoryStep& step : row.steps){ + if (const std::string failure = gym_step_on_sim(step, row.id, walk); !failure.empty()){ + return std::format("{}: ended on {}; {}", id, to_string(walk.sim->state().position), failure); + } + if (!walk.sim->state().violations.empty()){ + return std::format("{}/{}: a violation on the way: {}", id, step.name, walk.sim->state().violations.back()); + } + } + return ""; +} + +// 12.01 from the nurse: the gym, Kayden fought from (14, 16) and Kirk from +// (14, 11), round the top edge to west of Koga, where 12.02 starts; then +// 12.02 from there to the Warden and the nurse, meeting no one else. The +// sim's lookers see every way at once, so Edgar, whose lines the legs to +// the walls cross, always stops the walk there: the worst case, which +// the console meets only when he looks that way. +UnitTestResult test_gym_rows(){ + GymWalk walk(*story_pose(Pokemon::pose_of(*checkpoint("12.01").start))); + if (const std::string failure = row_on_sim("12.01", walk); !failure.empty()){ + return failure; + } + const MapPosition west_of_koga{GYM, {6, 13}}; + if (!(walk.sim->state().position == west_of_koga) || walk.sim->state().facing != Direction::EAST){ + return std::format("12.01: ended on {}, not west of Koga {} facing east.", to_string(walk.sim->state().position), to_string(west_of_koga)); + } + if (walk.all_fought() != std::vector{"rocker", "rocker", "man"}){ + return std::format("12.01: fought {} trainers, not Kayden, Kirk and Edgar.", walk.all_fought().size()); + } + const StoryPose next = *story_pose(Pokemon::pose_of(*checkpoint("12.02").start)); + if (next.map != GYM || !(next.tile == west_of_koga.point)){ + return "12.02 doesn't start where 12.01 ends."; + } + if (const std::string failure = row_on_sim("12.02", walk); !failure.empty()){ + return failure; + } + if (walk.all_fought().size() != 3){ + return "12.02: fought a trainer after Koga."; + } + if (walk.at.map != "FuchsiaCity_PokemonCenter_1F"){ + return std::format("12.02: ended on {}, not at Fuchsia's nurse.", walk.at.map); + } + return true; +} + +// The lead as pokeguy brings it to the gym after HM03 (12.01): Surf over +// Water Gun, Water Pulse, Bite, Mega Kick. It picks Surf against Koga's +// Poison types (pokeguy: Surf throughout) and Surf or Bite, never Mega +// Kick (5 PP) or Water Pulse, against the Jugglers' Psychic types. +UnitTestResult test_lead_moves_in_gym(){ + PartyMember lead; + lead.species = "blastoise"; + lead.moves_read = true; + lead.level = 39; + lead.moves = {{"surf", 15}, {"water-pulse", 20}, {"bite", 25}, {"mega-kick", 5}}; + constexpr size_t SURF = 0; + constexpr size_t BITE = 2; + for (std::string_view foe : {"koffing", "muk", "weezing"}){ + if (attack_slot_against(lead, {std::string(foe)}) != SURF){ + return std::format("Against {}: expected Surf.", foe); + } + } + for (std::string_view foe : {"drowzee", "kadabra", "hypno"}){ + const std::optional slot = attack_slot_against(lead, {std::string(foe)}); + if (slot != SURF && slot != BITE){ + return std::format("Against {}: expected Surf or Bite.", foe); + } + } + return true; +} + +class QuietLogger : public Logger{ +public: + using Logger::log; + virtual void log(const std::string&, Color) override{} +}; + +// Battle checkpoint `id`'s precondition: a LEVEL step on the lead before +// its battle `battle`, at least `pokeguy`, pokeguy's level there (whose +// sims stand for the fight at that level or above). A lead at that level +// passes it; one a level below stops the checkpoint before the fight. +UnitTestResult check_lead_level_precondition(Logger& logger, std::string_view id, std::string_view battle, unsigned pokeguy){ + std::optional check; + for (const StoryStep& step : checkpoint(id).steps){ + if (step.kind == StoryStepKind::BATTLE && step.name == battle){ + break; + } + if (step.action == LEVEL_ACTION){ + check = level_check_of(step.args); + } + } + if (!check || check->slot != 0 || check->level != pokeguy){ + return std::format("{}: expected a LEVEL step on the lead, at least Lv{}, before {}.", id, pokeguy, battle); + } + for (const unsigned level : {pokeguy, pokeguy - 1}){ + const MemberReader lead = [level](size_t slot) -> std::optional{ + if (slot != 0){ + return std::nullopt; + } + return MemberInfo{.species = "blastoise", .level = level}; + }; + const LevelResult result = run_level_check(logger, lead, *check); + const LevelEnd expected = level >= pokeguy ? LevelEnd::REACHED : LevelEnd::BELOW; + if (result.end != expected || result.level != level){ + return std::format("{}: a Lv{} lead {} the Lv{} check.", id, level, level >= pokeguy ? "fails" : "passes", pokeguy); + } + } + return true; +} + +const AutoStoryFuchsiaGymCase AUTO_STORY_FUCHSIA_GYM_CASES[] = { + { + .input = {.name = "12.01 past Kayden and Kirk to west of Koga and 12.02 to the Warden and the nurse", .body = test_gym_rows}, + .expectation = {.description = "Kayden and Kirk fought where the table steps into their lines, no one else; ends at Fuchsia's nurse"}, + }, + { + .input = {.name = "the lead's attacks in Fuchsia Gym", .body = test_lead_moves_in_gym}, + .expectation = {.description = "Surf against Koga's Pokemon, Surf or Bite against the Jugglers'"}, + }, + { + .input = {.name = "12.02 stops before Koga unless the lead is at least pokeguy's Lv39", .body = []{ + QuietLogger logger; + return check_lead_level_precondition(logger, "12.02", "koga", 39); + }}, + .expectation = {.description = "a Lv39 lead passes the LEVEL step, a Lv38 one stops there"}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryFuchsiaGym(UnitTestDatabase& database){ + for (const auto& item : AUTO_STORY_FUCHSIA_GYM_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp index c769fe016c..2d234983ea 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryParty.cpp @@ -116,6 +116,9 @@ struct Attack{ std::string_view move; }; constexpr Attack ATTACKS[] = { + // From HM03 (12.01) on, as pokeguy: Surf on everything it is not + // resisted by (1:15:14 on). + {.line = "squirtle", .move = "surf"}, {.line = "squirtle", .move = "water-gun"}, {.line = "squirtle", .move = "bite"}, {.line = "squirtle", .move = "bubble"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h index 4cd5d9abe1..28ffc843d2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden.h @@ -849,6 +849,49 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN[] = { "09.02 face north -> RocketHideout_B4F (19, 5)", "09.02 face_silph_scope from RocketHideout_B4F (19, 5) facing south to RocketHideout_B4F (19, 5) facing east", "09.02 face east -> RocketHideout_B4F (19, 5)", + "12.01 gym_east_wall from FuchsiaCity_PokemonCenter_1F (7, 4) facing north to FuchsiaCity_Gym (14, 21) facing north", + "12.01 walk south 5 (warp) -> FuchsiaCity (25, 32) [walk only]", + "12.01 walk south 1 -> FuchsiaCity (25, 33)", + "12.01 walk west 16 -> FuchsiaCity (9, 33)", + "12.01 walk north 1 (warp) -> FuchsiaCity_Gym (7, 21)", + "12.01 walk east 7 (to wall) -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.01 face north -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.01 west_of_koga from FuchsiaCity_Gym (6, 13) facing south to FuchsiaCity_Gym (6, 13) facing east", + "12.01 face east -> FuchsiaCity_Gym (6, 13) [walk only]", + "12.02 below_warden from FuchsiaCity_Gym (6, 13) facing east to FuchsiaCity_WardensHouse (3, 6) facing north", + "12.02 walk north 1 (to wall) -> FuchsiaCity_Gym (6, 12) [walk only]", + "12.02 walk west 6 (to wall) -> FuchsiaCity_Gym (0, 12) [walk only]", + "12.02 walk north 1 (to wall) -> FuchsiaCity_Gym (0, 11) [walk only]", + "12.02 walk east 2 (to wall) -> FuchsiaCity_Gym (2, 11) [walk only]", + "12.02 walk north 1 -> FuchsiaCity_Gym (2, 10) [walk only]", + "12.02 walk east 7 (to wall) -> FuchsiaCity_Gym (9, 10) [walk only]", + "12.02 walk north 8 (to wall) -> FuchsiaCity_Gym (9, 2) [walk only]", + "12.02 walk east 5 (to wall) -> FuchsiaCity_Gym (14, 2) [walk only]", + "12.02 walk south 19 (to wall) -> FuchsiaCity_Gym (14, 21) [walk only]", + "12.02 walk west 7 -> FuchsiaCity_Gym (7, 21) [walk only]", + "12.02 walk south 1 (warp) -> FuchsiaCity (9, 33) [walk only]", + "12.02 walk south 4 (to wall) -> FuchsiaCity (9, 37)", + "12.02 walk west 7 (to wall) -> FuchsiaCity (2, 37)", + "12.02 walk north 12 -> FuchsiaCity (2, 25)", + "12.02 walk east 28 (to wall) -> FuchsiaCity (30, 25)", + "12.02 walk south 7 -> FuchsiaCity (30, 32)", + "12.02 walk east 3 -> FuchsiaCity (33, 32)", + "12.02 walk north 1 (warp) -> FuchsiaCity_WardensHouse (6, 9)", + "12.02 walk west 5 (to wall) -> FuchsiaCity_WardensHouse (1, 9) [walk only]", + "12.02 walk north 3 (to wall) -> FuchsiaCity_WardensHouse (1, 6) [walk only]", + "12.02 walk east 2 -> FuchsiaCity_WardensHouse (3, 6) [walk only]", + "12.02 face north -> FuchsiaCity_WardensHouse (3, 6) [walk only]", + "12.02 below_center_door from FuchsiaCity_WardensHouse (3, 6) facing north to FuchsiaCity (25, 32) facing north", + "12.02 walk east 3 -> FuchsiaCity_WardensHouse (6, 6) [walk only]", + "12.02 walk south 4 (warp) -> FuchsiaCity (33, 32) [walk only]", + "12.02 walk west 4 -> FuchsiaCity (29, 32)", + "12.02 walk north 7 -> FuchsiaCity (29, 25)", + "12.02 walk west 27 (to wall) -> FuchsiaCity (2, 25)", + "12.02 walk south 12 (to wall) -> FuchsiaCity (2, 37)", + "12.02 walk east 9 (to wall) -> FuchsiaCity (11, 37)", + "12.02 walk north 5 (to wall) -> FuchsiaCity (11, 32)", + "12.02 walk east 14 -> FuchsiaCity (25, 32)", + "12.02 face north -> FuchsiaCity (25, 32)", }; } // namespace PokemonFRLG diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h index 6b15acaab2..f4de691d69 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -10,6 +10,7 @@ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H #define PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H +#include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" namespace PokemonAutomation{ @@ -26,6 +27,17 @@ void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); void add_tests_AutoStoryCeladon(UnitTestDatabase& database); // Rows from 08.01 on on the overworld sim (PokemonFRLG_AutoStoryLavender_Tests.cpp). void add_tests_AutoStoryLavender(UnitTestDatabase& database); +// Rows 12.01 and 12.02, Fuchsia Gym, on the overworld sim (PokemonFRLG_AutoStoryFuchsiaGym_Tests.cpp). +void add_tests_AutoStoryFuchsiaGym(UnitTestDatabase& database); + +// Whether checkpoint `id` was authored before the rows that lead up to it: +// it starts from its own declared pose, not where the row before it in +// the table ends. 12.01 starts from Fly's landing in Fuchsia, after the +// Safari Zone (11.02); segments 10 and 11 are authored separately. An id leaves +// this list once the rows before it are in. +inline bool starts_after_unauthored_rows(std::string_view id){ + return id == "12.01"; +} } // namespace PokemonFRLG 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 1bfb846f94..c51bfab90f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp @@ -139,7 +139,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"; +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 12.01 12.02"; const RunPlanScenario RUN_PLAN_CASES[] = { { @@ -230,11 +230,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"}, + .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 12.01 12.02"}, }, { .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"}, + .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 12.01 12.02"}, }, { .input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman", @@ -259,7 +259,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"}, + .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 12.01 12.02"}, }, { .input = { .name = "Starter RNG first, with both on", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp index 6a3d5e0278..dc4c899f6c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -36,6 +36,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryPaceSim.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -224,9 +225,13 @@ UnitTestResult test_whole_story(){ if (sim.begun() != ids || sim.saves.size() != ids.size()){ return "Expected each checkpoint once, in order, each saving at its end:" + joined(sim.game.trace); } - // Each checkpoint starts where the save before it stands. + // Each checkpoint starts where the save before it stands, but one + // authored before the rows that lead up to it. for (size_t c = 1; c < sim.rows.size(); c++){ const StoryCheckpoint& data = sim.rows[c]; + if (starts_after_unauthored_rows(data.id)){ + continue; + } const std::optional start = story_pose(*start_pose(data)); const std::optional saved = story_pose(sim.saves[c - 1].second); const bool same = start && saved && start->map == saved->map && start->tile == saved->tile 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 0a5f768539..4bc561e81f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -32,6 +32,7 @@ #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryPcStorage.h" #include "PokemonFRLG_AutoStoryPlanGolden.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryMoveData.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -275,16 +276,19 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po } // Plans every route of the story, each checkpoint from where the one -// before leaves the player, and adds the plans to `golden`. +// before leaves the player (or, past rows not authored yet, from its own +// 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() != 39 || checkpoints[0].start){ - return "Expected 39 checkpoints, the first from a new game."; + if (checkpoints.size() != 41 || checkpoints[0].start){ + return "Expected 41 checkpoints, the first from a new game."; } StoryPose pose; for (size_t c = 0; c < checkpoints.size(); c++){ const StoryCheckpoint& checkpoint = checkpoints[c]; - if (c > 0){ + if (c > 0 && starts_after_unauthored_rows(checkpoint.id)){ + pose = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); + }else if (c > 0){ const StoryPose start = one_tile(Pokemon::grid_pose_of(*checkpoint.start)); const bool same_facing = !start.facing || start.facing == pose.facing; if (start.map != pose.map || !(start.tile == pose.tile) || !same_facing){ @@ -687,7 +691,7 @@ UnitTestResult check_lines(const StoryCheckpoint& checkpoint, std::set