diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp index 8a623e2745..3ba0bda2d4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp @@ -271,10 +271,24 @@ std::optional spin_direction(const MapData& map, const TilePos& point return direction; } } - return std::nullopt; + // A map file's own glyphs (Viridian Gym). + switch (tile_at(map, point)){ + case TileKind::SPIN_NORTH: + return Direction::NORTH; + case TileKind::SPIN_SOUTH: + return Direction::SOUTH; + case TileKind::SPIN_WEST: + return Direction::WEST; + case TileKind::SPIN_EAST: + return Direction::EAST; + default: + return std::nullopt; + } } bool stops_spinning(const MapData& map, const TilePos& point){ - return coded_spin_stop(map.name, point) || in_region(map, SPIN_STOP_REGION, point); + return coded_spin_stop(map.name, point) + || in_region(map, SPIN_STOP_REGION, point) + || tile_at(map, point) == TileKind::STOP_SPIN; } std::optional spin_slide(const MapData& map, const PlayerState& state){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index d1f2ff632c..060a6a82bb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -150,8 +150,11 @@ constexpr std::string_view MAP_NAMES[] = { // Route 21 north of it to Pallet Town (12.03). "CinnabarIsland", "CinnabarIsland_Gym", + // Route 21 from Pallet Town south to Cinnabar (12.03), and Viridian Gym with its + // spinner tiles (the map file's glyphs: PokemonFRLG_OverworldSpin.h). "Route21_North", "Route21_South", + "ViridianCity_Gym", // Silph Co.'s floors, 1F to 11F (the lift's map, SilphCo_Elevator, is // not built in). "SilphCo_1F", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h index 6a4a5a9730..19fa7665b8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h @@ -21,9 +21,10 @@ namespace PokemonFRLG{ // Spinner tiles (Rocket Hideout B2F and B3F, Viridian Gym): pokefirered's // MB_SPIN_UP, MB_SPIN_DOWN, MB_SPIN_LEFT, MB_SPIN_RIGHT and -// MB_STOP_SPINNING. The tile glyphs can't say so: the hideout's floors -// have them coded (coded_spin_direction(), PokemonFRLG_CodedRooms.h); -// another map may list them in these regions, as it does WILD_REGION. +// MB_STOP_SPINNING. The hideout's floors have them coded +// (coded_spin_direction(), PokemonFRLG_CodedRooms.h); Viridian Gym's map +// file writes them as glyphs ('u', 'd', 'l', 'r' and the stop 'o'); another +// map may list them in these regions, as it does WILD_REGION. // "spin_north": MB_SPIN_UP. // "spin_south": MB_SPIN_DOWN. // "spin_west": MB_SPIN_LEFT. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index ebc3c8651a..c515e04367 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -60,6 +60,7 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows15_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows13_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows16_Tests.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTable.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h" #include "Programs/AutoStory/Data/Json_Tests.h" @@ -118,6 +119,7 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryCinnabarGym(database); add_tests_AutoStorySilph(database); add_tests_AutoStoryMansion(database); + add_tests_AutoStoryViridian(database); } void add_tests(UnitTestDatabase& database){ 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 a01c2de5c2..91f276348a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -132,6 +132,8 @@ const std::map KNOWN_FAILING{ "fly_pallet: a Fly that doesn't leave Fuchsia City goes unseen, and the row, which walks on from Fuchsia's streets to Pallet's shore, ends on Cinnabar's nurse tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, {"PokemonFRLG::AutoStory - Fault sweep: 14.03, warp no-op", "fly_celadon: a Fly that doesn't leave Cinnabar Island goes unseen, and the row, which walks on from Celadon's heal spot, ends below Erika: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, + {"PokemonFRLG::AutoStory - Fault sweep: 17.02, warp no-op", + "fly_viridian: a Fly that doesn't leave Saffron City goes unseen, and the row, which walks on from Saffron's streets, ends on Viridian's Gym tile: the same fix as 11.01's, the fly landing on its town's tile (FlyTown::landing) checked before the step ends"}, {"PokemonFRLG::AutoStory - Fault sweep: 08.03, off the Bicycle at a bike leg", "riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"}, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h new file mode 100644 index 0000000000..d50829d6d9 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h @@ -0,0 +1,77 @@ +/* FRLG AutoStory Plan Golden, Segment 17 + * + * From: https://github.com/PokemonAutomation/ + * + * The golden's lines for 17.02 to 17.04 (after PokemonFRLG_AutoStoryPlanGolden16.h's), + * in the story's order. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryPlanGolden17_H +#define PokemonAutomation_PokemonFRLG_AutoStoryPlanGolden17_H + +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +// The stored plan lines of 17.02 to 17.04, Saffron to Viridian Gym. +inline constexpr std::string_view FRLG_PLAN_GOLDEN_17_GYM[] = { + "17.02 saffron_outside from SaffronCity_PokemonCenter_1F (7, 4) facing north to SaffronCity (24, 39) facing south", + "17.02 walk south 5 (warp) -> SaffronCity (24, 39) [walk only]", + "17.02 below_gym_door from ViridianCity (26, 27) facing south to ViridianCity (36, 11) facing north", + "17.02 walk west 4 -> ViridianCity (22, 27)", + "17.02 walk north 21 -> ViridianCity (22, 6)", + "17.02 walk east 19 (to wall) -> ViridianCity (41, 6)", + "17.02 walk south 5 -> ViridianCity (41, 11)", + "17.02 walk west 5 -> ViridianCity (36, 11)", + "17.02 face north -> ViridianCity (36, 11)", + "17.02 below_warren_line from ViridianCity_Gym (17, 22) facing north to ViridianCity_Gym (15, 8) facing north", + "17.02 walk north 7 (to wall) -> ViridianCity_Gym (17, 15) [walk only]", + "17.02 walk west 3 (to wall) -> ViridianCity_Gym (14, 15) [walk only]", + "17.02 walk north 2 (to wall) -> ViridianCity_Gym (14, 13) [walk only]", + "17.02 walk west 1 -> ViridianCity_Gym (13, 13) [walk only]", + "17.02 walk north 3 (to wall) -> ViridianCity_Gym (13, 10) [walk only]", + "17.02 walk east 3 (to wall) -> ViridianCity_Gym (16, 10) [walk only]", + "17.02 walk north 2 -> ViridianCity_Gym (16, 8) [walk only]", + "17.02 walk west 1 (to wall) -> ViridianCity_Gym (15, 8) [walk only]", + "17.02 face north -> ViridianCity_Gym (15, 8) [walk only]", + "17.03 below_takashi_line from ViridianCity_Gym (15, 7) facing north to ViridianCity_Gym (10, 6) facing north", + "17.03 walk north 1 (to wall) -> ViridianCity_Gym (15, 6) [walk only]", + "17.03 walk west 3 (to wall) -> ViridianCity_Gym (12, 6) [walk only]", + "17.03 walk south 1 (to wall) -> ViridianCity_Gym (12, 7) [walk only]", + "17.03 walk west 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]", + "17.03 walk north 1 -> ViridianCity_Gym (10, 6) [walk only]", + "17.03 below_giovanni from ViridianCity_Gym (10, 5) facing north to ViridianCity_Gym (2, 3) facing north", + "17.03 walk north 2 -> ViridianCity_Gym (10, 3) [walk only]", + "17.03 walk west 3 -> ViridianCity_Gym (7, 3) [walk only]", + "17.03 walk south 3 (to wall) -> ViridianCity_Gym (7, 6) [walk only]", + "17.03 walk west 5 -> ViridianCity_Gym (2, 6) [walk only]", + "17.03 walk north 3 -> ViridianCity_Gym (2, 3) [walk only]", + "17.04b gym_exit from ViridianCity_Gym (2, 3) facing north to ViridianCity (36, 11) facing south", + "17.04b walk south 4 (to wall) -> ViridianCity_Gym (2, 7) [walk only]", + "17.04b walk east 4 (to wall) -> ViridianCity_Gym (6, 7) [walk only]", + "17.04b walk north 1 (to wall) -> ViridianCity_Gym (6, 6) [walk only]", + "17.04b walk east 1 (to wall) -> ViridianCity_Gym (7, 6) [walk only]", + "17.04b walk north 3 -> ViridianCity_Gym (7, 3) [walk only]", + "17.04b walk east 4 (spins 6) -> ViridianCity_Gym (17, 3) [walk only]", + "17.04b walk east 1 (spins 11) -> ViridianCity_Gym (18, 14) [walk only]", + "17.04b walk south 8 (to wall) -> ViridianCity_Gym (18, 22) [walk only]", + "17.04b walk west 1 -> ViridianCity_Gym (17, 22) [walk only] [tapped]", + "17.04b walk south 1 (warp) -> ViridianCity (36, 11) [walk only]", + "17.04b below_center_door from ViridianCity (36, 11) facing south to ViridianCity (26, 27) facing north", + "17.04b walk east 5 (to wall) -> ViridianCity (41, 11)", + "17.04b walk north 7 (to wall) -> ViridianCity (41, 4)", + "17.04b walk west 13 (to wall) -> ViridianCity (28, 4)", + "17.04b walk south 4 (to wall) -> ViridianCity (28, 8)", + "17.04b walk west 6 -> ViridianCity (22, 8)", + "17.04b walk south 19 -> ViridianCity (22, 27)", + "17.04b walk east 4 -> ViridianCity (26, 27)", + "17.04b face north -> ViridianCity (26, 27)", +}; + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h new file mode 100644 index 0000000000..82c75c9f65 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows17_Tests.h @@ -0,0 +1,27 @@ +/* AutoStory Row Tests, Segment 17 + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the tests that run segment 17's rows (Saffron to + * Cinnabar by Fly and Surf, and Viridian Gym) on the overworld sim. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows17_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryRows17_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Rows 17.02 to 17.04b and Viridian Gym's spinner tiles, on the overworld sim (PokemonFRLG_AutoStoryViridian_Tests.cpp). +void add_tests_AutoStoryViridian(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif 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 436a867179..695738d0e9 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"; +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"; 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"}, + .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"}, }, { .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"}, + .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"}, }, { .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"}, + .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"}, }, { .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 9108463dc5..24679243de 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -237,6 +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", }; // `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 819936c8b1..3ba3dbe560 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h @@ -19,11 +19,13 @@ namespace PokemonFRLG{ // 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 story's order (STORY_ORDER in PokemonFRLG_AutoStoryTable.cpp) ends. -// 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. +// 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). 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 == "14.01"; + return id == "17.02" || id == "14.01"; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp new file mode 100644 index 0000000000..2c0aeb9cbc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp @@ -0,0 +1,129 @@ +/* AutoStory Viridian Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Viridian Gym's spinner tiles (rows 17.02 to 17.04b, + * StoryData/frlg-17.0N.plan.json) on the overworld sim. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" +#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSpin.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" +#include "PokemonFRLG_AutoStoryRows17_Tests.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +struct AutoStoryViridianInput{ + std::string name; + std::function body; +}; + +struct AutoStoryViridianExpectation{ + std::string_view description; +}; + +struct AutoStoryViridianCase{ + AutoStoryViridianInput input; + AutoStoryViridianExpectation expectation; +}; + +class Test_AutoStoryViridian : public UnitTest{ +public: + explicit Test_AutoStoryViridian(AutoStoryViridianCase 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: + AutoStoryViridianCase m_case; +}; + +// Viridian Gym's arrow tiles (the map file's glyphs): stepped onto, the +// player slides until a stop tile or a wall, turned by each arrow met. +UnitTestResult check_gym_slide(const TilePos& from, const TilePos& end, Direction facing, int tiles){ + const MapData* gym = nullptr; + for (const MapData& map : story_maps()){ + if (map.name == "ViridianCity_Gym"){ + gym = ↦ + } + } + if (gym == nullptr){ + return "No ViridianCity_Gym map."; + } + const std::optional slide = spin_slide(*gym, PlayerState{from, ELEVATION_GROUND, false}); + if (!slide){ + return std::format("No slide from {}.", to_string(from)); + } + if (!(slide->end.position == end) || slide->facing != facing || slide->tiles != tiles){ + return std::format( + "From {}: slid {} tile(s) to {} facing {}; expected {} to {} facing {}.", + to_string(from), slide->tiles, to_string(slide->end.position), direction_name(slide->facing), + tiles, to_string(end), direction_name(facing) + ); + } + return true; +} + +UnitTestResult test_gym_east_arrow(){ + return check_gym_slide({11, 3}, {17, 3}, Direction::EAST, 6); +} +UnitTestResult test_gym_south_arrow_chain(){ + return check_gym_slide({18, 3}, {18, 14}, Direction::SOUTH, 11); +} +UnitTestResult test_gym_north_arrow(){ + return check_gym_slide({0, 20}, {0, 11}, Direction::NORTH, 9); +} + +const AutoStoryViridianCase AUTO_STORY_VIRIDIAN_CASES[] = { + { + .input = {.name = "Viridian Gym: the east arrow at (11, 3) slides to its stop", .body = test_gym_east_arrow}, + .expectation = {.description = "6 tiles east to (17, 3)"}, + }, + { + .input = {.name = "Viridian Gym: the south arrows at (18, 3) slide to the stop below", .body = test_gym_south_arrow_chain}, + .expectation = {.description = "11 tiles south to (18, 14)"}, + }, + { + .input = {.name = "Viridian Gym: the north arrow at (0, 20) slides to its stop", .body = test_gym_north_arrow}, + .expectation = {.description = "9 tiles north to (0, 11)"}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryViridian(UnitTestDatabase& database){ + for (const auto& item : AUTO_STORY_VIRIDIAN_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation 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 369cd2c030..d88532ea20 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -41,6 +41,7 @@ #include "PokemonFRLG_AutoStoryPlanGolden14.h" #include "PokemonFRLG_AutoStoryPlanGolden15.h" #include "PokemonFRLG_AutoStoryPlanGolden16.h" +#include "PokemonFRLG_AutoStoryPlanGolden17.h" #include "PokemonFRLG_AutoStoryPlanGolden13.h" #include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryMoveData.h" @@ -291,8 +292,8 @@ 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() != 66 || checkpoints[0].start){ - return "Expected 66 checkpoints, the first from a new game."; + if (checkpoints.size() != 70 || checkpoints[0].start){ + return "Expected 70 checkpoints, the first from a new game."; } StoryPose pose; for (size_t c = 0; c < checkpoints.size(); c++){ @@ -341,6 +342,7 @@ UnitTestResult test_golden_plans(){ golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_12_CELADON), std::end(FRLG_PLAN_GOLDEN_12_CELADON)); golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_15), std::end(FRLG_PLAN_GOLDEN_15)); golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_16), std::end(FRLG_PLAN_GOLDEN_16)); + golden.insert(golden.end(), std::begin(FRLG_PLAN_GOLDEN_17_GYM), std::end(FRLG_PLAN_GOLDEN_17_GYM)); const size_t stored = golden.size(); size_t first_diff = 0; while (first_diff < actual.size() && first_diff < stored && actual[first_diff] == golden[first_diff]){ @@ -925,10 +927,10 @@ UnitTestResult test_trainer_lines(){ } has_shoes = has_shoes || checkpoint.id == "03.03"; } - if (beaten.size() != 41){ + if (beaten.size() != 43){ return "Expected to fight Colton, Greg and James on Route 3, the Grunt at (12, 20) in Mt. Moon, Nugget Bridge's five" ", Franklin, Kelsey, Nob and Haley on Route 25, Jeff on Route 6, Dwayne, Baily and Tucker in Vermilion Gym, Alicia, Jeremy and Conner on Route 9" - ", Ashton, Winston, Martha, Allen, Lenny, Sofia, Dudley and Dana in Rock Tunnel, Rich on Route 8, the Lift Key Grunt on B4F, Ruth, Tammy, Jennifer and Emilia and the three Grunts in the Pokemon Tower, and Kayden , Kirk in Fuchsia Gym, and Tamia and Lori in Celadon Gym; the table fights " + ", Ashton, Winston, Martha, Allen, Lenny, Sofia, Dudley and Dana in Rock Tunnel, Rich on Route 8, the Lift Key Grunt on B4F, Ruth, Tammy, Jennifer and Emilia and the three Grunts in the Pokemon Tower, and Kayden , Kirk in Fuchsia Gym, and Tamia and Lori in Celadon Gym, and Warren and Takashi in Viridian Gym; the table fights " + std::to_string(beaten.size()) + " trainers."; } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json new file mode 100644 index 0000000000..32337f46e6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json @@ -0,0 +1,180 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "17.02", + "title": "Saffron to Viridian Gym: Fly, Warren", + "start": { + "map": "SaffronCity_PokemonCenter_1F", + "tiles": [ + [ + 7, + 4 + ] + ], + "facing": "north" + }, + "events": [ + { + "id": "saffron_outside", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "SaffronCity", + "tiles": [ + [ + 24, + 39 + ] + ], + "facing": "south" + } + }, + "why": "out of Saffron's Center onto the street below its door (24, 38): Fly works outdoors only" + }, + { + "id": "fly_viridian", + "kind": "game_action", + "action": "fly", + "args": { + "town": "ViridianCity", + "species": "pidgey" + }, + "declared_after": { + "map": "ViridianCity", + "tiles": [ + [ + 26, + 27 + ] + ], + "facing": "south" + }, + "why": "Fly to Viridian City (the badge-8 gym is the last before the Elite Four); lands below the Center's door (26, 26)" + }, + { + "id": "below_gym_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity", + "tiles": [ + [ + 36, + 11 + ] + ], + "facing": "north" + } + }, + "why": "east along the city to below the Gym's door (36, 10)" + }, + { + "id": "into_gym", + "kind": "step", + "args": { + "direction": "north" + }, + "declared_after": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 17, + 22 + ] + ], + "facing": "north" + }, + "why": "through the Gym's door (36, 10) onto the mat (17, 22) inside" + }, + { + "id": "below_warren_line", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 15, + 8 + ] + ], + "facing": "north" + } + }, + "why": "north and west through the gym's open floor (no arrow tile on this way) to (15, 8), below Warren's line (14..16, 7)" + }, + { + "id": "lead_lv47_for_the_gym", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 47 + }, + "why": "the lead at least Lv47 before the gym's fights (Giovanni's Rhyhorn is Lv50), checked before the first trainer's line; below it the run stops" + }, + { + "id": "warren_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (15, 7), the end of Warren's line (sight 3, facing east): he walks over" + }, + { + "id": "warren", + "kind": "battle", + "args": { + "trainer": "TRAINER_COOLTRAINER_WARREN", + "foes": [ + "marowak", + "marowak", + "rhyhorn", + "nidorina", + "nidoqueen" + ] + }, + "declared_after": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 15, + 7 + ] + ], + "facing": "north" + }, + "why": "Warren (TRAINER_COOLTRAINER_WARREN): Marowak Lv37, Marowak Lv37, Rhyhorn Lv38, Nidorina Lv39, Nidoqueen Lv39" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts at Saffron's nurse: it follows the Silph Co. and Sabrina rows, which are not all authored in this stack, so its start is its own (starts_after_unauthored_rows()). Nothing later needs the One Island trip (Bill is declined in 14.02): its Sevii quest flags are optional, the Ruby/Sapphire stone and Network Machine are post-game.", + "Fly to Viridian City, then in through the Gym's door. The route keeps off the arrow tiles on purpose (design section 12 scripts them; the planned way never meets one), and ends on (15, 7) after Warren's battle." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 15, + 7 + ] + ], + "facing": "north" + } + } + } +} \ No newline at end of file diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json new file mode 100644 index 0000000000..25600f94d1 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json @@ -0,0 +1,112 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "17.03", + "title": "Viridian Gym: Takashi, to Giovanni", + "start": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 15, + 7 + ] + ], + "facing": "north" + }, + "events": [ + { + "id": "below_takashi_line", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 10, + 6 + ] + ], + "facing": "north" + } + }, + "why": "back up column 15, west along row 6 to (10, 6), below Takashi's line (10, 3..5)" + }, + { + "id": "takashi_line", + "kind": "step", + "action": "trainer_line", + "args": { + "direction": "north" + }, + "why": "onto (10, 5), the end of Takashi's line (sight 3, facing south)" + }, + { + "id": "takashi", + "kind": "battle", + "args": { + "trainer": "TRAINER_BLACK_BELT_TAKASHI", + "foes": [ + "machoke", + "machop", + "machoke", + "machoke" + ] + }, + "declared_after": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 10, + 5 + ] + ], + "facing": "north" + }, + "why": "Takashi (TRAINER_BLACK_BELT_TAKASHI): Machoke Lv38, Machop Lv38, Machoke Lv38, Machoke Lv43" + }, + { + "id": "below_giovanni", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + } + }, + "why": "west along row 3 and down to (2, 3), facing Giovanni (2, 2)" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Ends at (2, 3) facing Giovanni (2, 2): the save in front of him, as for the other leaders." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + } + } + } +} \ No newline at end of file diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json new file mode 100644 index 0000000000..df66993362 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json @@ -0,0 +1,83 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "17.04", + "title": "Viridian Gym: Giovanni and the EARTHBADGE", + "start": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + }, + "events": [ + { + "id": "lead_lv50_for_giovanni", + "kind": "game_action", + "action": "level", + "args": { + "slot": 1, + "min": 50 + }, + "why": "the precondition for Giovanni (Rhyhorn Lv50): below it the run stops before the fight" + }, + { + "id": "challenge_giovanni", + "kind": "talk", + "why": "Giovanni (2, 2)" + }, + { + "id": "giovanni", + "kind": "battle", + "args": { + "trainer": "TRAINER_LEADER_GIOVANNI", + "foes": [ + "rhyhorn", + "dugtrio", + "nidoqueen", + "nidoking", + "rhydon" + ] + }, + "declared_after": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + }, + "why": "Giovanni: Rhyhorn Lv45, Dugtrio Lv42, Nidoqueen Lv44, Nidoking Lv45, Rhydon Lv50; then the EARTHBADGE and TM26 Earthquake" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "A boss battle is its own checkpoint (user, 2026-11-12): Giovanni's fight is all this row does. It ends in front of him after the EARTHBADGE and TM26 text, and saves there; 17.04b goes on out of the gym." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + } + } + } +} \ No newline at end of file diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json new file mode 100644 index 0000000000..4281616ef2 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json @@ -0,0 +1,101 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "17.04b", + "title": "Out of the gym, heal at Viridian's Center", + "start": { + "map": "ViridianCity_Gym", + "tiles": [ + [ + 2, + 3 + ] + ], + "facing": "north" + }, + "events": [ + { + "id": "gym_exit", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity", + "tiles": [ + [ + 36, + 11 + ] + ], + "facing": "south" + } + }, + "why": "back through the gym to the door and out onto Viridian City below it" + }, + { + "id": "below_center_door", + "kind": "route", + "action": "run", + "args": { + "target": { + "map": "ViridianCity", + "tiles": [ + [ + 26, + 27 + ] + ], + "facing": "north" + } + }, + "why": "west and down to below the Center's door (26, 26)" + }, + { + "id": "viridian_nurse", + "kind": "game_action", + "action": "center_enter", + "declared_after": { + "map": "ViridianCity_PokemonCenter_1F", + "tiles": [ + [ + 7, + 4 + ] + ], + "facing": "north" + }, + "why": "the Center script in, up to the nurse" + }, + { + "id": "heal_viridian", + "kind": "heal", + "why": "full HP and PP" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "checkpoint": [ + "Starts in front of Giovanni, where 17.04 ends after his battle and saves.", + "Ends at Viridian's nurse (declared: the gym exit is a street tile; the Center is where the next row starts)." + ] + } + }, + "metadata": { + "phase": "testing", + "postconditions": { + "position": { + "map": "ViridianCity_PokemonCenter_1F", + "tiles": [ + [ + 7, + 4 + ] + ], + "facing": "north" + } + } + } +} \ No newline at end of file diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index e595a8b9c1..dabb7d7783 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2112,7 +2112,9 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySilph_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows16_Tests.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows17_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_AutoStoryRows13_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryUnauthoredStarts_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryChoice.cpp @@ -2204,6 +2206,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden14.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden15.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden16.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden13.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryResources.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryResources.h