diff --git a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp index 929a888bbd..979c88c3f0 100644 --- a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp @@ -20,6 +20,7 @@ #include "Inference/PokemonBDSP_MenuDetector.h" #include "Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h" #include "Programs/AutoStory/PokemonBDSP_AutoStory_Tests.h" +#include "Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -292,6 +293,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_MenuDetector(database); add_tests_AutoStory_MapGrids(database); add_tests_AutoStory(database); + add_tests_AutoStory_Segment00(database); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md index 8117fba767..2c37d39a69 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md @@ -27,12 +27,18 @@ Each map file's header starts with the same three lines, kept current with the c | Oreburgh City | decomp (pokediamond) | none yet (01.04, 01.05 run as records) | probe the Center doorstep (x 46 or 47) | | Oreburgh Gate | decomp (pokediamond) | none yet | | | Floaroma Town | decomp (pokediamond), the old couple from the console | 01.11 (1x, as a record) | | -| Twinleaf Town | decomp (pokediamond) | none: 00.01 to 00.03 replay recorded stick inputs (#1717), no route on the grid | redo 00.01 to 00.03 as planned walks | -| Verity Lakefront, Lake Verity | decomp (pokediamond) | none: 00.02, 00.03 replay recorded stick inputs (#1717) | redo as planned walks | +| Twinleaf Town | decomp (pokediamond) | none: 00.01 replays recorded stick inputs (#1717); its lines and records are on the grid (Segment00Lines, task #22), tested offline | a new-game run of the lines, then switch 00.01 to them | +| Verity Lakefront | decomp (pokediamond) | none: 00.01 to 00.03 replay recorded stick inputs (#1717); lines and records on the grid, tested offline | the run must say which entrance tile the lake's scene leaves us on | +| Lake Verity | decomp (pokediamond) | none, and no walk: the scene carries us in and the game warps us out | none | +| Oreburgh Gym | decomp (pokediamond) | none: 01.04 walks it as a record (north until a trainer stops us), traced on the grid | a plan on it if the record ever fails | Rules: terrain from the decomp, people and Platinum-only edits from the console; a route is coded only over tiles a human or a probe has walked; a map change -re-runs every checkpoint listed on it. The decomp comparison that found the 3/4 +re-runs every checkpoint listed on it. Scenes' trigger rectangles come from the +decomp too (the events files' coord events: Diamond's binaries parsed by hand, +Platinum's JSON readable), listed in `Segment00Lines::scene_triggers()` for +00.01 to 00.03; a line into a scene must step into its rectangle on its last +tile only, which the Segment 00 tests check. The decomp comparison that found the 3/4 rows is the 2026-10-31 report (`compare.md`, with the decoded grids); the re-derivation of 2026-10-31 took every grid above from `devtools/maps decomp --repo pret/pokediamond` and translated each file's named tiles with its diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.cpp new file mode 100644 index 0000000000..915bdc1474 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.cpp @@ -0,0 +1,61 @@ +/* BDSP AutoStory - Oreburgh Gym tiles + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "PokemonBDSP_AutoStory_MapGrids.h" +#include "PokemonBDSP_AutoStory_OreburghGym.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ +namespace OreburghGym{ + +using namespace Pokemon; + + +// Map source: the decomp (Diamond land_data 0228, 2026-10-31) with the +// objects from its events file. +// Console checks: none yet. 01.04 walks it as a record (north until a +// trainer stops us), not as a plan. +// Status: no checkpoint passes on this grid yet. +// +// Decoded from Pokemon Diamond's collision table for this map (the +// pret/pokediamond decompilation, +// files/fielddata/land_data/land_data_release/narc_0228: the only cell of +// matrix 113, at column 0, row 0; MAP_OREBURGH_GYM in +// include/constants/maps.h), with the objects from its events file +// (zone_event narc_0046, events_oreburgh_gym.json in Platinum); BDSP keeps +// Diamond/Pearl's layout. Local (x, y) = world (x - 0, z - 0) in the Gym's +// own matrix; 32 x 32 tiles, of which the floor is columns 1 to 10, rows 3 +// to 24. The tiers' edges and the pillars are '#'. +// Door: (5, 24), walked into heading south to leave; coming in puts us on +// (5, 23). Column 5 runs straight from there to Roark on row 3: the Gym is +// walked north up the middle. Objects, from the events file: +// Roark (5, 3), looks south; +// Gym Guide (6, 23), looks south, beside the entrance; +// Youngster (4, 18), looks east, sees 3: (5..7, 18); +// Youngster (7, 11), looks west, sees 4: (3..6, 11); +// the two wall signs, (3, 23) and (7, 23), read from row 23: 'S'. +// Both trainers see the middle column, so a walk north from the entrance +// is stopped twice before Roark (01.04's record). +const TileGrid& grid(){ + return story_grid("OreburghGym"); +} + +const TilePos ENTRANCE{5, 23}; +const TilePos ROARK{5, 3}; + +std::vector trainer_sights(){ + return { + {"Youngster (first tier)", {4, 18}, Direction::EAST, 3}, + {"Youngster (second tier)", {7, 11}, Direction::WEST, 4}, + }; +} + + +} +} +} +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.h new file mode 100644 index 0000000000..2cb6dc8489 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.h @@ -0,0 +1,38 @@ +/* BDSP AutoStory - Oreburgh Gym tiles + * + * From: https://github.com/PokemonAutomation/ + * + * The Gym's inside, decoded from the Pokemon Diamond decompilation + * (pret/pokediamond); see the .cpp's header for the cell, the offset and + * the objects. For checkpoint 01.04's walk up to Roark. + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_OreburghGym_H +#define PokemonAutomation_PokemonBDSP_AutoStory_OreburghGym_H + +#include +#include "Pokemon/Navigation/Pokemon_TileGrid.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ +namespace OreburghGym{ + + +const Pokemon::TileGrid& grid(); + +// Where coming in through the door puts us: the tile above it, beside the +// Gym Guide. Roark stands at the top of the same column. +extern const Pokemon::TilePos ENTRANCE; +extern const Pokemon::TilePos ROARK; + +// The two Youngsters, who face the column up the middle from either side: +// walking north from the entrance meets both. +std::vector trainer_sights(); + + +} +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp index 98fee479b8..fc0c0b7b61 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp @@ -6,11 +6,17 @@ #include "PokemonBDSP_AutoStory_RouteRecords.h" #include "PokemonBDSP_AutoStory_JubilifeCity.h" +#include "PokemonBDSP_AutoStory_Route201.h" #include "PokemonBDSP_AutoStory_Route203.h" #include "PokemonBDSP_AutoStory_Route204.h" #include "PokemonBDSP_AutoStory_RavagedPath.h" #include "PokemonBDSP_AutoStory_OreburghCity.h" +#include "PokemonBDSP_AutoStory_OreburghGym.h" #include "PokemonBDSP_AutoStory_FloaromaTown.h" +#include "PokemonBDSP_AutoStory_SandgemTown.h" +#include "PokemonBDSP_AutoStory_Segment00Lines.h" +#include "PokemonBDSP_AutoStory_TwinleafTown.h" +#include "PokemonBDSP_AutoStory_VerityLakefront.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -20,30 +26,82 @@ namespace RouteRecords{ using namespace Pokemon; namespace{ +const TileGrid* twinleaf(){ return &TwinleafTown::grid(); } +const TileGrid* route201(){ return &Route201::grid(); } +const TileGrid* lakefront(){ return &VerityLakefront::grid(); } +const TileGrid* sandgem(){ return &SandgemTown::grid(); } const TileGrid* jubilife(){ return &JubilifeCity::grid(); } const TileGrid* route203(){ return &Route203::grid(); } const TileGrid* ravaged_path(){ return &RavagedPath::grid(); } const TileGrid* route204_north(){ return &Route204::north_grid(); } const TileGrid* oreburgh_city(){ return &OreburghCity::grid(); } +const TileGrid* oreburgh_gym(){ return &OreburghGym::grid(); } const TileGrid* floaroma(){ return &FloaromaTown::grid(); } -const TileGrid* none(){ return nullptr; } + +// 00.01: the house, Twinleaf, Route 201 and the Lakefront out to the lake. +std::vector checkpoint_0001_records(){ + return { + {"00.01", "The house's doorstep to Barry's door", "Twinleaf Town", twinleaf, true, Segment00Lines::HOUSE_DOORSTEP, { + {Direction::WEST, 7, LegEnd::COUNT, "along row 22 to column 13, clear of the south-west house"}, + {Direction::NORTH, 10, LegEnd::COUNT, "up column 13 to row 12, below Barry's mailbox"}, + {Direction::WEST, 4, LegEnd::COUNT, "onto (9, 12), the one tile that starts Barry's scene: he bursts out of his door"}, + {Direction::NORTH, 1, LegEnd::DOOR, "after the scene, into Barry's house; the stairs, his room and the way back out are replays"}, + }, "Segment00Lines line 1, not walked by the program yet; the Twinleaf grid and the scene's tile from the Diamond decomp (land_data 0000, zone_event 0389)"}, + {"00.01", "Barry's doorstep to Route 201", "Twinleaf Town", twinleaf, true, Segment00Lines::BARRY_DOORSTEP, { + {Direction::EAST, 6, LegEnd::COUNT, "along row 12 to column 15"}, + {Direction::NORTH, 12, LegEnd::COUNT, "up column 15 to (15, 0), the last tile in town; the guitarist's stop on row 3 is inert once Barry has talked upstairs"}, + {Direction::NORTH, 0, LegEnd::BANNER, "on north onto Route 201"}, + }, "Segment00Lines line 2, not walked by the program yet"}, + {"00.01", "Route 201: Barry's tall-grass warning, then west to the Lakefront", "Route 201", route201, true, Segment00Lines::ROUTE_201_ARRIVAL, { + {Direction::NORTH, 6, LegEnd::COUNT, "up the exit path to (15, 18): Barry's warning fires on that row"}, + {Direction::WEST, 3, LegEnd::COUNT, "after the scene, along row 18 to column 12"}, + {Direction::NORTH, 2, LegEnd::COUNT, "to row 16, the lower level's row to the Lakefront"}, + {Direction::WEST, 12, LegEnd::COUNT, "to (0, 16), the route's last tile"}, + {Direction::WEST, 0, LegEnd::BANNER, "on west onto the Verity Lakefront"}, + }, "Segment00Lines lines 2 and 3, not walked by the program yet; traced on Route201::grid(), the decomp's since #111"}, + {"00.01", "Verity Lakefront: to below the lake's entrance", "Verity Lakefront", lakefront, true, Segment00Lines::LAKEFRONT_ARRIVAL, { + {Direction::WEST, 11, LegEnd::COUNT, "along row 23 to column 20"}, + {Direction::NORTH, 2, LegEnd::COUNT, "to row 21"}, + {Direction::WEST, 3, LegEnd::COUNT, "to column 17, the entrance path's east column"}, + {Direction::NORTH, 7, LegEnd::COUNT, "up column 17 to (17, 14), two tiles short of the lake's scene; 00.01 ends here"}, + }, "Segment00Lines line 3, not walked by the program yet"}, + }; } -// The walks planned on a grid (00.04 and 00.05's walk_route goals, 01.03's -// Mine legs, 01.06's Route 203 and Jubilife legs, 01.08's Route 204 South, -// 01.09's Ravaged Path, 01.10's waypoints) are data already, tested in -// PokemonBDSP_AutoStory_Tests.cpp; these are the rest. -// -// Not recorded, because they are not routes: 00.01 to 00.03 (the house, -// Twinleaf, Route 201, the Lakefront and the lake) replay the stick inputs -// Butters recorded for #1717 (tutorial_part_1_navigation, entry_visible, -// tutorial_part_2_navigation, starter_nav: timed holds, diagonals among -// them, and "move until transition"). No tile count can be read off them. -// They get redone as planned walks on the Twinleaf, Verity Lakefront and -// Lake Verity grids (decoded 2026-11-01) in the compact series; until then -// those grids carry no route and no trace. -const std::vector& all(){ - static const std::vector records{ +// 00.02 and 00.03: into the lake's scene, and back to Sandgem. +std::vector checkpoints_0002_0003_records(){ + return { + {"00.02", "Into the lake's scene", "Verity Lakefront", lakefront, true, Segment00Lines::BELOW_LAKE_ENTRANCE, { + {Direction::NORTH, 2, LegEnd::COUNT, "onto (17, 12): Barry hears Rowan and the two of us walk into Lake Verity"}, + {Direction::NORTH, 0, LegEnd::SCENE, "the starter, the Starly and the way back out to (17, 12) are the game's; nothing is walked at the lake"}, + }, "starter_nav() presses north twice from where 00.01 ends; Segment00Lines line 3's last two tiles; the scene's tiles from the Diamond decomp (zone_event 0319)"}, + {"00.03", "Verity Lakefront: from the lake's entrance back onto Route 201", "Verity Lakefront", lakefront, true, Segment00Lines::LAKE_ENTRANCE, { + {Direction::SOUTH, 9, LegEnd::COUNT, "down column 17 to row 21"}, + {Direction::EAST, 12, LegEnd::COUNT, "along row 21 to column 29"}, + {Direction::EAST, 0, LegEnd::BANNER, "on east onto Route 201"}, + }, "Segment00Lines line 4, not walked by the program yet; which of the two entrance tiles the scene leaves us on is for the console"}, + {"00.03", "Route 201: Rowan's scene, then east through the grass to Sandgem", "Route 201", route201, true, Segment00Lines::ROUTE_201_RETURN, { + {Direction::EAST, 5, LegEnd::COUNT, "to (5, 14): Rowan and Dawn's scene fires on that column"}, + {Direction::EAST, 12, LegEnd::COUNT, "after the scene, along row 14 to column 17"}, + {Direction::EAST, 12, LegEnd::COUNT, "through the tall grass to column 29; the Breeder wanders rows 14 to 16 there"}, + {Direction::EAST, 12, LegEnd::COUNT, "to column 41"}, + {Direction::NORTH, 7, LegEnd::COUNT, "up column 41 to row 7, beside the north-east grass"}, + {Direction::EAST, 1, LegEnd::COUNT, "into the grass"}, + {Direction::NORTH, 2, LegEnd::COUNT, "to row 5"}, + {Direction::EAST, 10, LegEnd::COUNT, "through the grass to (52, 5), its last tile"}, + {Direction::EAST, 11, LegEnd::COUNT, "to (63, 5), the route's last tile"}, + {Direction::EAST, 0, LegEnd::BANNER, "on east into Sandgem Town"}, + }, "Segment00Lines lines 4 and 5, not walked by the program yet; the grass legs need the wild-battle handling of the replay's walk_through_grass(); traced on Route201::grid()"}, + {"00.03", "Sandgem Town: Dawn at the entrance", "Sandgem Town", sandgem, true, Segment00Lines::SANDGEM_ARRIVAL, { + {Direction::EAST, 4, LegEnd::COUNT, "along row 12 to (4, 12): Dawn's scene, which leads us into Rowan's lab for the Pokedex"}, + {Direction::EAST, 0, LegEnd::SCENE, "the lab is the game's; 00.03 ends in front of Rowan"}, + }, "Segment00Lines line 5, not walked by the program yet; on Sandgem's row 12, where its coord event (zone_event 0396) is"}, + }; +} + +// 01.01 to 01.05: Jubilife to Oreburgh and back out. +std::vector segment01_records_to_oreburgh(){ + return { {"01.01", "Jubilife Pokemon Center to Barry on Route 203", "Jubilife City", jubilife, true, std::nullopt, { {Direction::SOUTH, 0, LegEnd::NPC, "out of the Center's door; a girl below it stops us"}, {Direction::WEST, 4, LegEnd::COUNT, "stick 720 ms: onto the main road", false}, @@ -62,9 +120,9 @@ const std::vector& all(){ {Direction::WEST, 20, LegEnd::COUNT, "D-pad taps along the Center's row to below the Gym's door"}, {Direction::NORTH, 1, LegEnd::DOOR, "into the Gym (the fade)"}, }, "oreburgh_street_to_gym(); 20 taps measured on the console (r204 to r215, 3 runs on the same tile); the decomp's Center door is at x 47, the taps say the doorstep is x 46"}, - {"01.04", "Inside the Oreburgh Gym", "", none, false, std::nullopt, { - {Direction::NORTH, 0, LegEnd::NPC, "up the Gym to its trainers and Roark"}, - }, "oreburgh_gym_battles(); no grid for the Gym's inside"}, + {"01.04", "Inside the Oreburgh Gym", "Oreburgh Gym", oreburgh_gym, true, OreburghGym::ENTRANCE, { + {Direction::NORTH, 0, LegEnd::NPC, "up column 5 from the entrance to Roark on row 3; the Youngsters at (4, 18) and (7, 11) see the column and stop us on rows 18 and 11 on the way"}, + }, "oreburgh_gym_battles(); the Gym's grid from the Diamond decomp (land_data 0228), its trainers and their sight from the events file (zone_event 0046)"}, {"01.05", "Oreburgh Gym to the Gate and out onto Route 203", "Oreburgh City", oreburgh_city, true, OreburghCity::GYM_DOORSTEP, { {Direction::EAST, 20, LegEnd::COUNT, "D-pad taps from the Gym's doorstep back to the Center's door"}, {Direction::WEST, 0, LegEnd::WALL, "to the stairs' cliff"}, @@ -76,6 +134,12 @@ const std::vector& all(){ {Direction::WEST, 0, LegEnd::TRANSITION, "into the Oreburgh Gate (a row probed when a wall comes first)"}, {Direction::WEST, 0, LegEnd::BANNER, "through the Gate until Route 203's banner"}, }, "oreburgh_gym_to_center(), oreburgh_to_route203(); the Center visit between the two taps legs is not a walk"}, + }; +} + +// 01.07 to 01.11: Jubilife north to Floaroma. +std::vector segment01_records_from_jubilife(){ + return { {"01.07", "Jubilife's east edge to Rowan's scene", "Jubilife City", jubilife, true, std::nullopt, { {Direction::WEST, 14, LegEnd::COUNT, "stick 2 x 1120 ms along the long road to the crossroads with the north street", false}, {Direction::NORTH, 0, LegEnd::SCENE, "up the street until Rowan's scene starts (about 6 s); the green-haired man may stand in the way"}, @@ -97,6 +161,34 @@ const std::vector& all(){ {Direction::NORTH, 0, LegEnd::NPC, "until the old man stops us (a turn)"}, }, "floaroma_old_couple(); by hand 2026-10-31 (batches m1 to m9), r251a"}, }; +} + +} + +// The walks planned on a grid (00.04 and 00.05's walk_route goals, 01.03's +// Mine legs, 01.06's Route 203 and Jubilife legs, 01.08's Route 204 South, +// 01.09's Ravaged Path, 01.10's waypoints) are data already, tested in +// PokemonBDSP_AutoStory_Tests.cpp; these are the rest. +// +// 00.01 to 00.03 (the house, Twinleaf, Route 201, the Lakefront and the +// lake) still replay the stick inputs Butters recorded for #1717 +// (tutorial_part_1_navigation, entry_visible, tutorial_part_2_navigation, +// starter_nav: timed holds, diagonals among them, and "move until +// transition"), off which no tile count can be read. Their records below +// are the same walks as lines on the decomp grids +// (Data/PokemonBDSP_AutoStory_Segment00Lines, task #22), legs the program +// does not walk yet: a new-game run has to confirm where each scene leaves +// the player before Segment_00 switches to them. The house interiors (the +// player's, Barry's) have no grid and stay replays. +const std::vector& all(){ + static const std::vector records = []{ + std::vector all; + for (auto part : {checkpoint_0001_records, checkpoints_0002_0003_records, segment01_records_to_oreburgh, segment01_records_from_jubilife}){ + const std::vector records = part(); + all.insert(all.end(), records.begin(), records.end()); + } + return all; + }(); return records; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.cpp new file mode 100644 index 0000000000..fe4bed1a06 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.cpp @@ -0,0 +1,156 @@ +/* BDSP AutoStory - Segment 00's walked lines + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "PokemonBDSP_AutoStory_Route201.h" +#include "PokemonBDSP_AutoStory_SandgemTown.h" +#include "PokemonBDSP_AutoStory_StoryMaps.h" +#include "PokemonBDSP_AutoStory_TwinleafTown.h" +#include "PokemonBDSP_AutoStory_VerityLakefront.h" +#include "PokemonBDSP_AutoStory_Segment00Lines.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ +namespace Segment00Lines{ + +using namespace Pokemon; + + +const char* const MAP_TWINLEAF_TOWN = "Twinleaf Town"; +const char* const MAP_VERITY_LAKEFRONT = "Verity Lakefront"; + + +// Offsets are the decomp's world coordinates of each map's tile (0, 0): +// the Sinnoh matrix's cells are 32 tiles square, the Lakefront is cell +// (column 2, row 26), Route 201 cells (3..4, 26), Twinleaf (3, 27) and +// Sandgem (5, 26). Route201::grid() leaves off the cell's seven wall rows +// at the top, so it starts 7 rows lower; SandgemTown::grid() is its whole +// cell. +const MapSet& segment00_maps(){ + static const MapSet maps = []{ + MapSet maps; + maps.add(MAP_TWINLEAF_TOWN, TwinleafTown::grid(), {96, 864}); + maps.add(MAP_ROUTE_201, Route201::grid(), {96, 839}); + maps.add(MAP_VERITY_LAKEFRONT, VerityLakefront::grid(), {64, 832}); + maps.add(MAP_SANDGEM_TOWN, SandgemTown::grid(), {160, 832}); + return maps; + }(); + return maps; +} + + +// From the Diamond decomp's coord events (zone_event narc_0389 Twinleaf, +// 0327 Route 201, 0319 Verity Lakefront, 0396 Sandgem; Lake Verity's +// narc_0298 has none: its scene is the map's own script, run on arrival). +// Each is a rectangle in world tiles with the story variable and value it +// fires at; Platinum's readable events files name the variables and carry +// the same rectangles for Twinleaf and the Lakefront. Listed as local +// tiles of our grids. Not here, having no grid: the player's house's door +// tile (6, 10), where Mom's warning fires on the way out (narc_0392, value +// 1). +const std::vector& scene_triggers(){ + static const std::vector triggers{ + {"Barry's door", MAP_TWINLEAF_TOWN, {9, 12}, 1, 1, + "before Barry has burst out of his house (var 0x40e6 = 0)"}, + {"the guitarist stops us leaving", MAP_TWINLEAF_TOWN, {12, 3}, 8, 1, + "between Barry's door and his talk upstairs (var 0x4070 = 1; 2 after it)"}, + {"Barry's tall-grass warning", MAP_ROUTE_201, {14, 18}, 6, 1, + "the first time north of Twinleaf (var 0x4086 = 0)"}, + {"Route 201's row 19 after the warning", MAP_ROUTE_201, {14, 19}, 6, 1, + "after the warning and before the lake (var 0x4086 = 1); its script is Diamond's binary, not read"}, + {"Rowan and Dawn on the way back", MAP_ROUTE_201, {5, 14}, 1, 3, + "after the lake (var 0x4086 = 2)"}, + {"Barry at the lake's entrance", MAP_VERITY_LAKEFRONT, {16, 12}, 2, 1, + "the first visit (var 0x4082 = 0): he hears Rowan and the two walk into Lake Verity; the same tiles fire again at 3, later in the story"}, + {"Dawn at Sandgem's entrance", MAP_SANDGEM_TOWN, {4, 11}, 1, 5, + "the first time in from Route 201 (var 0x4071 = 0): she leads us to Rowan's lab"}, + }; + return triggers; +} + +bool trigger_covers(const SceneTrigger& trigger, const MapTile& tile){ + return tile.map == trigger.map && + tile.pos.x >= trigger.corner.x && tile.pos.x < trigger.corner.x + trigger.width && + tile.pos.y >= trigger.corner.y && tile.pos.y < trigger.corner.y + trigger.height; +} + + +const TilePos HOUSE_DOORSTEP{20, 22}; +const TilePos BARRY_DOORSTEP{9, 12}; +const TilePos TWINLEAF_NORTH_EXIT{15, 0}; +const TilePos ROUTE_201_ARRIVAL{15, 24}; +const TilePos BARRY_WARNING{15, 18}; +const TilePos LAKEFRONT_ARRIVAL{31, 23}; +const TilePos BELOW_LAKE_ENTRANCE{17, 14}; +const TilePos LAKE_ENTRANCE{17, 12}; +const TilePos ROUTE_201_RETURN{0, 14}; +const TilePos ROWAN_STOP{5, 14}; +const TilePos ROUTE_201_EAST_END{63, 5}; +const TilePos SANDGEM_ARRIVAL{0, 12}; +const TilePos DAWN_STOP{4, 12}; + +// Corners are chosen on the maps' features (a row clear of the houses, +// the exit path, a map's last tile, the tile a scene fires on); where a +// straight run is longer than the planner's 12-tile open leg (the row +// through the Lakefront, the row along Route 201) it is split at the +// twelfth tile. The lower level of Route 201 (rows 13 to 16) is the way +// both to and from the lake: the upper level's ledges only drop onto it. +// Row 16 is used westward and row 14 eastward: on the way out Rowan and +// the counterpart are not yet on (8, 14..15) and Barry is gone from (16, +// 16), but 16 keeps the line one row off the Breeder's range; on the way +// back 14 reaches Rowan's column with the fewest corners. +// +// What a new-game run must confirm before the segment switches to these: +// where each scene leaves the player (Barry's warning and Rowan's scene +// are assumed to leave us on the trigger tile; the lake's scene to warp +// us back onto (17, 12), the right-hand entrance tile, facing south), and +// that the stretches through tall grass are walked with the wild-battle +// handling the replay's walk_through_grass() has, which walk_waypoints() +// does not. +namespace{ +// Corners on each map, and a line from them: parentheses keep the table +// flat enough for the code-health linter's brace limit. +MapTile twinleaf(const TilePos& pos){ return {MAP_TWINLEAF_TOWN, pos}; } +MapTile route201(const TilePos& pos){ return {MAP_ROUTE_201, pos}; } +MapTile lakefront(const TilePos& pos){ return {MAP_VERITY_LAKEFRONT, pos}; } +MapTile sandgem(const TilePos& pos){ return {MAP_SANDGEM_TOWN, pos}; } +WalkedLine walked( + std::string checkpoint, std::string name, std::vector corners, + std::string ends_in, std::vector live_triggers +){ + return {std::move(checkpoint), std::move(name), std::move(corners), std::move(ends_in), std::move(live_triggers)}; +} +} + +const std::vector& lines(){ + static const std::vector lines{ + walked("00.01", "the house's doorstep to Barry's door", { + twinleaf(HOUSE_DOORSTEP), twinleaf({13, 22}), twinleaf({13, 12}), twinleaf(BARRY_DOORSTEP), + }, "Barry's door", {"Barry's door"}), + walked("00.01", "Barry's doorstep to Route 201", { + twinleaf(BARRY_DOORSTEP), twinleaf({15, 12}), twinleaf(TWINLEAF_NORTH_EXIT), route201(BARRY_WARNING), + }, "Barry's tall-grass warning", {"Barry's tall-grass warning"}), + walked("00.01", "Route 201's west half to the lake's entrance", { + route201(BARRY_WARNING), route201({12, 18}), route201({12, 16}), route201({0, 16}), + lakefront({20, 23}), lakefront({20, 21}), lakefront({17, 21}), lakefront(LAKE_ENTRANCE), + }, "Barry at the lake's entrance", {"Barry at the lake's entrance", "Route 201's row 19 after the warning"}), + walked("00.03", "the lake's entrance back to Rowan", { + lakefront(LAKE_ENTRANCE), lakefront({17, 21}), lakefront({29, 21}), route201(ROWAN_STOP), + }, "Rowan and Dawn on the way back", {"Rowan and Dawn on the way back"}), + walked("00.03", "Rowan to Dawn at Sandgem's entrance", { + route201(ROWAN_STOP), route201({17, 14}), route201({29, 14}), route201({41, 14}), + route201({41, 7}), route201({42, 7}), route201({42, 5}), route201({52, 5}), + route201(ROUTE_201_EAST_END), sandgem(DAWN_STOP), + }, "Dawn at Sandgem's entrance", {"Dawn at Sandgem's entrance"}), + }; + return lines; +} + +} +} +} +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.h new file mode 100644 index 0000000000..8269643c84 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.h @@ -0,0 +1,84 @@ +/* BDSP AutoStory - Segment 00's walked lines + * + * From: https://github.com/PokemonAutomation/ + * + * Checkpoints 00.01 to 00.03 (the house, Twinleaf, Route 201, the Verity + * Lakefront, the lake, and back to Sandgem) replay recorded stick holds + * today. These are the same walks as lines on the grids: corner to corner, + * each stretch one straight leg, ending on the tile that starts the next + * scene. The scenes' trigger rectangles come from the Diamond decomp's + * events files, so a test can show each line steps into its scene on its + * last tile and not before. Nothing runs them on the console yet (task + * #22); the segment keeps its replays until a new-game run has checked + * the lines. + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_Segment00Lines_H +#define PokemonAutomation_PokemonBDSP_AutoStory_Segment00Lines_H + +#include +#include +#include "Pokemon/Navigation/Pokemon_MapSet.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ +namespace Segment00Lines{ + + +// Map names in segment00_maps(); Route 201 and Sandgem Town go by +// StoryMaps' MAP_ROUTE_201 and MAP_SANDGEM_TOWN. +extern const char* const MAP_TWINLEAF_TOWN; +extern const char* const MAP_VERITY_LAKEFRONT; + +// Twinleaf Town, Route 201, the Verity Lakefront and Sandgem Town joined on +// one grid at their world offsets from the decomp. Lake Verity is not in +// it: its own matrix, and the scene walks us in and the game warps us out, +// so no line is walked there. +const Pokemon::MapSet& segment00_maps(); + +// A rectangle of tiles that starts a scene when the player steps in while +// the story is in `when`. From the decomp's coord events, as local tiles. +struct SceneTrigger{ + std::string name; + std::string map; + Pokemon::TilePos corner; // north-west tile + int width; + int height; + std::string when; // the story state it fires in +}; +const std::vector& scene_triggers(); +bool trigger_covers(const SceneTrigger& trigger, const Pokemon::MapTile& tile); + +// A line walked corner to corner: every stretch between two corners is one +// straight open leg (whole tiles, as the D-pad walks them). +struct WalkedLine{ + std::string checkpoint; + std::string name; + std::vector corners; // the first is where the line starts + std::string ends_in; // the scene the last corner steps into, "" for none + std::vector live_triggers; // the scenes armed while this line is walked +}; +const std::vector& lines(); + +// Named tiles on the lines, where the route records start and end. +extern const Pokemon::TilePos HOUSE_DOORSTEP; // Twinleaf: below the player's door +extern const Pokemon::TilePos BARRY_DOORSTEP; // Twinleaf: below Barry's door; his scene's tile +extern const Pokemon::TilePos TWINLEAF_NORTH_EXIT; // Twinleaf: the last tile before Route 201 +extern const Pokemon::TilePos ROUTE_201_ARRIVAL; // Route 201: the first tile north of Twinleaf +extern const Pokemon::TilePos BARRY_WARNING; // Route 201: Barry's tall-grass warning +extern const Pokemon::TilePos LAKEFRONT_ARRIVAL; // Lakefront: the first tile west of Route 201 +extern const Pokemon::TilePos BELOW_LAKE_ENTRANCE; // Lakefront: two tiles short of the lake's scene +extern const Pokemon::TilePos LAKE_ENTRANCE; // Lakefront: the lake's scene; where it leaves us +extern const Pokemon::TilePos ROUTE_201_RETURN; // Route 201: the first tile east of the Lakefront +extern const Pokemon::TilePos ROWAN_STOP; // Route 201: Rowan and Dawn's scene +extern const Pokemon::TilePos ROUTE_201_EAST_END; // Route 201: the last tile before Sandgem +extern const Pokemon::TilePos SANDGEM_ARRIVAL; // Sandgem: the first tile east of Route 201 +extern const Pokemon::TilePos DAWN_STOP; // Sandgem: Dawn's scene + + +} +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGym.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGym.json new file mode 100644 index 0000000000..ad30eae0d7 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGym.json @@ -0,0 +1,68 @@ +{ + "name": "OreburghGym", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.cpp", + "revision": "ce701d495c94", + "date": "2026-11-01" + }, + "tiles": [ + "################################", + "################################", + "################################", + "#..........#####################", + "#..........#####################", + "#..........#####################", + "#..##.##...#####################", + "#..........#####################", + "#..##.##...#####################", + "#..........#####################", + "#..........#####################", + "###.....#.######################", + "#..........#####################", + "#####.##...#####################", + "#####.##...#####################", + "#..........#####################", + "#..........#####################", + "#..........#####################", + "#..........#####################", + "##.#....########################", + "##.#....########################", + "#..........#####################", + "#..#...#...#####################", + "#..S...S...#####################", + "#....D.....#####################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################" + ], + "objects": [ + { + "name": "npc_5_3", + "kind": "npc", + "x": 5, + "y": 3 + }, + { + "name": "npc_7_11", + "kind": "npc", + "x": 7, + "y": 11 + }, + { + "name": "npc_4_18", + "kind": "npc", + "x": 4, + "y": 18 + }, + { + "name": "npc_6_23", + "kind": "npc", + "x": 6, + "y": 23 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.cpp new file mode 100644 index 0000000000..6256a5e6dd --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.cpp @@ -0,0 +1,266 @@ +/* BDSP AutoStory Segment 00 Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/Navigation/Pokemon_MapSet.h" +#include "Pokemon/Navigation/Pokemon_TileGrid.h" +#include "Data/PokemonBDSP_AutoStory_OreburghGym.h" +#include "Data/PokemonBDSP_AutoStory_Segment00Lines.h" +#include "Data/PokemonBDSP_AutoStory_StoryMaps.h" +#include "Utils/PokemonBDSP_AutoStory_RouteWalk.h" +#include "PokemonBDSP_AutoStory_Segment00_Tests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +namespace{ + +using Pokemon::Direction; +using Pokemon::MapSet; +using Pokemon::MapTile; +using Pokemon::TileGrid; +using Pokemon::TilePos; +using Pokemon::TileType; +using Segment00Lines::SceneTrigger; +using Segment00Lines::WalkedLine; + +std::string describe(const MapTile& tile){ + return tile.map + " " + Pokemon::to_string(tile.pos); +} + +const SceneTrigger* find_trigger(const std::string& name){ + for (const SceneTrigger& trigger : Segment00Lines::scene_triggers()){ + if (trigger.name == name){ + return &trigger; + } + } + return nullptr; +} + +// Plans one stretch of a line with the waypoint costs and returns the leg, +// or an error. The stretch must be the one straight leg a human took: to a +// wall or open, as the grid has it, ending exactly on the corner. +struct Stretch{ + Pokemon::TileLeg leg; + std::string error; +}; +Stretch plan_stretch(const MapSet& maps, const TilePos& from, const TilePos& to, const std::string& name){ + const auto plan = Pokemon::plan_robust_route(maps.world(), std::vector{from}, + [&](const TilePos& pos){ return pos == to; }, waypoint_plan_costs()); + if (!plan){ + return {{}, name + ": no plan."}; + } + if (plan->size() != 1){ + std::string text = name + ": " + std::to_string(plan->size()) + " legs, expected the one straight leg:"; + for (const Pokemon::PlannedLeg& leg : *plan){ + text += " " + to_string(leg.leg); + } + return {{}, text}; + } + const Pokemon::PlannedLeg& leg = (*plan)[0]; + if (leg.after.size() != 1 || !(leg.after[0] == to)){ + return {{}, name + ": the leg " + to_string(leg.leg) + " does not end exactly on the corner."}; + } + return {leg.leg, ""}; +} + +// Every tile a line stands on, its start first, as local tiles; logs each +// stretch's leg. Empty with `error` set when a stretch does not plan. +std::vector line_tiles(Logger& logger, const MapSet& maps, const WalkedLine& line, std::string& error){ + const std::string name = line.checkpoint + " " + line.name; + std::vector tiles{line.corners[0]}; + TilePos at = maps.to_world(line.corners[0].map, line.corners[0].pos); + std::string text = name + ": from " + describe(line.corners[0]); + for (size_t i = 1; i < line.corners.size(); i++){ + const MapTile& corner = line.corners[i]; + const TilePos goal = maps.to_world(corner.map, corner.pos); + const Stretch stretch = plan_stretch(maps, at, goal, name + " stretch " + std::to_string(i) + " to " + describe(corner)); + if (!stretch.error.empty()){ + error = stretch.error; + return {}; + } + text += "\n " + to_string(stretch.leg) + " to " + describe(corner); + for (size_t k = 0; k < stretch.leg.tiles; k++){ + at = at.next(stretch.leg.direction); + const std::optional local = maps.to_local(at); + if (!local){ + error = name + ": the line leaves the maps at " + Pokemon::to_string(at) + "."; + return {}; + } + tiles.push_back(*local); + } + } + logger.log(text); + return tiles; +} + +// The last tile steps into the line's scene; no earlier tile is in any +// scene armed while the line is walked (an inert one is only logged). +std::string check_triggers(Logger& logger, const WalkedLine& line, const std::vector& tiles){ + const std::string name = line.checkpoint + " " + line.name; + for (const std::string& live : line.live_triggers){ + if (find_trigger(live) == nullptr){ + return name + ": no scene trigger named \"" + live + "\"."; + } + } + const auto armed = [&](const std::string& trigger){ + return std::ranges::find(line.live_triggers, trigger) != line.live_triggers.end(); + }; + if (!line.ends_in.empty() && !armed(line.ends_in)){ + return name + ": the scene it ends in, \"" + line.ends_in + "\", is not among its live triggers."; + } + for (size_t i = 0; i < tiles.size(); i++){ + for (const SceneTrigger& trigger : Segment00Lines::scene_triggers()){ + if (!Segment00Lines::trigger_covers(trigger, tiles[i])){ + continue; + } + const bool live = armed(trigger.name); + const bool last = i + 1 == tiles.size(); + logger.log(name + ": tile " + std::to_string(i + 1) + " of " + std::to_string(tiles.size()) + ", " + describe(tiles[i]) + + ", is in \"" + trigger.name + "\" (" + (live ? "armed" : "inert: " + trigger.when) + ")."); + if (live && !(last && trigger.name == line.ends_in)){ + return name + ": steps into the armed scene \"" + trigger.name + "\" at " + describe(tiles[i]) + ", before its end."; + } + } + } + if (!line.ends_in.empty() && !Segment00Lines::trigger_covers(*find_trigger(line.ends_in), tiles.back())){ + return name + ": its last tile " + describe(tiles.back()) + " is not in \"" + line.ends_in + "\"."; + } + return ""; +} + +// The tiles the route records start and end on, each of which must lie on +// one of the lines. +struct NamedTile{ + const char* name; + MapTile tile; +}; +std::vector named_tiles(){ + return { + {"HOUSE_DOORSTEP", {Segment00Lines::MAP_TWINLEAF_TOWN, Segment00Lines::HOUSE_DOORSTEP}}, + {"BARRY_DOORSTEP", {Segment00Lines::MAP_TWINLEAF_TOWN, Segment00Lines::BARRY_DOORSTEP}}, + {"TWINLEAF_NORTH_EXIT", {Segment00Lines::MAP_TWINLEAF_TOWN, Segment00Lines::TWINLEAF_NORTH_EXIT}}, + {"ROUTE_201_ARRIVAL", {MAP_ROUTE_201, Segment00Lines::ROUTE_201_ARRIVAL}}, + {"BARRY_WARNING", {MAP_ROUTE_201, Segment00Lines::BARRY_WARNING}}, + {"LAKEFRONT_ARRIVAL", {Segment00Lines::MAP_VERITY_LAKEFRONT, Segment00Lines::LAKEFRONT_ARRIVAL}}, + {"BELOW_LAKE_ENTRANCE", {Segment00Lines::MAP_VERITY_LAKEFRONT, Segment00Lines::BELOW_LAKE_ENTRANCE}}, + {"LAKE_ENTRANCE", {Segment00Lines::MAP_VERITY_LAKEFRONT, Segment00Lines::LAKE_ENTRANCE}}, + {"ROUTE_201_RETURN", {MAP_ROUTE_201, Segment00Lines::ROUTE_201_RETURN}}, + {"ROWAN_STOP", {MAP_ROUTE_201, Segment00Lines::ROWAN_STOP}}, + {"ROUTE_201_EAST_END", {MAP_ROUTE_201, Segment00Lines::ROUTE_201_EAST_END}}, + {"SANDGEM_ARRIVAL", {MAP_SANDGEM_TOWN, Segment00Lines::SANDGEM_ARRIVAL}}, + {"DAWN_STOP", {MAP_SANDGEM_TOWN, Segment00Lines::DAWN_STOP}}, + }; +} + +// The lines 00.01 to 00.03 would walk (Data/PokemonBDSP_AutoStory_Segment00Lines): +// every stretch plans as one straight leg on the decomp grids, and each +// line enters its scene's trigger rectangle on its last tile only. The +// named tiles the route records start from all lie on the lines. +class Test_Segment00Lines : public UnitTest{ +public: + Test_Segment00Lines() + : UnitTest("PokemonBDSP::AutoStory - Segment 00: the lines into each scene") + {} + + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const MapSet& maps = Segment00Lines::segment00_maps(); + for (const SceneTrigger& trigger : Segment00Lines::scene_triggers()){ + if (trigger.width <= 0 || trigger.height <= 0){ + return "Scene trigger \"" + trigger.name + "\" has no tiles."; + } + maps.to_world(trigger.map, trigger.corner); // throws for a map not in the set + } + std::vector walked; + for (const WalkedLine& line : Segment00Lines::lines()){ + if (line.corners.size() < 2){ + return line.checkpoint + " " + line.name + ": a line needs two corners."; + } + std::string error; + const std::vector tiles = line_tiles(logger, maps, line, error); + if (!error.empty()){ + return error; + } + error = check_triggers(logger, line, tiles); + if (!error.empty()){ + return error; + } + walked.insert(walked.end(), tiles.begin(), tiles.end()); + } + for (const NamedTile& tile : named_tiles()){ + const bool on_a_line = std::ranges::any_of(walked, [&](const MapTile& t){ + return t.map == tile.tile.map && t.pos == tile.tile.pos; + }); + if (!on_a_line){ + return std::string(tile.name) + " " + describe(tile.tile) + " is on none of the lines."; + } + } + return true; + } +}; + +// The Oreburgh Gym's inside (Data/PokemonBDSP_AutoStory_OreburghGym): the +// column up from the entrance runs to Roark with nothing in the way but the +// two Youngsters' sight lines, which is what 01.04's "north until a trainer +// stops us" relies on. +class Test_OreburghGymGrid : public UnitTest{ +public: + Test_OreburghGymGrid() + : UnitTest("PokemonBDSP::AutoStory - Oreburgh Gym: the column up to Roark") + {} + + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const TileGrid& gym = OreburghGym::grid(); + if (!gym.standable(OreburghGym::ENTRANCE)){ + return "The entrance tile is not standable."; + } + if (gym.at(OreburghGym::ENTRANCE.next(Direction::SOUTH)) != TileType::DOOR){ + return "The door is not below the entrance tile."; + } + if (gym.at(OreburghGym::ROARK) != TileType::NPC){ + return "Roark is not on an NPC tile."; + } + const Pokemon::WallHit up = Pokemon::walk_to_wall(gym, OreburghGym::ENTRANCE, Direction::NORTH); + if (!(up.wall == OreburghGym::ROARK)){ + return "North from the entrance stops at " + Pokemon::to_string(up.stop) + ", not in front of Roark."; + } + logger.log("Oreburgh Gym: north from the entrance walks " + std::to_string(up.tiles) + " tiles to Roark."); + for (const Pokemon::TrainerSight& trainer : OreburghGym::trainer_sights()){ + if (gym.at(trainer.pos) != TileType::NPC){ + return trainer.name + " is not on an NPC tile."; + } + const std::vector seen = Pokemon::sight_tiles(gym, trainer); + const bool sees_column = std::ranges::any_of(seen, [&](const TilePos& pos){ + return pos.x == OreburghGym::ENTRANCE.x && pos.y < OreburghGym::ENTRANCE.y && pos.y > OreburghGym::ROARK.y; + }); + if (!sees_column){ + return trainer.name + " does not see the column up to Roark."; + } + std::string text = "Oreburgh Gym: " + trainer.name + " sees"; + for (const TilePos& pos : seen){ + text += " " + Pokemon::to_string(pos); + } + logger.log(text); + } + return true; + } +}; + +} + + +void add_tests_AutoStory_Segment00(UnitTestDatabase& database){ + database.add(); + database.add(); +} + + +} +} +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.h new file mode 100644 index 0000000000..a956b4073c --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.h @@ -0,0 +1,27 @@ +/* BDSP AutoStory Segment 00 Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_Segment00_Tests_H +#define PokemonAutomation_PokemonBDSP_AutoStory_Segment00_Tests_H + +#include "Common/Cpp/TestRunners/UnitTest.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + + +// Offline checks of Segment 00's walked lines against the grids and the +// scenes' trigger rectangles, and of the Oreburgh Gym's inside. +void add_tests_AutoStory_Segment00(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_00.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_00.cpp index 30b19917dd..99aece50f1 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_00.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_00.cpp @@ -175,9 +175,9 @@ namespace PokemonAutomation { stream.log("[DEBUG] Piplup Selection: Selection complete"); } - // Navigation functions for each part of the tutorial. These functions are meant to be used - // in order and rely on the state of the game being what it is at the end of the previous function. - // They may also be modified or removed without warning. + // Navigation functions for each part of the tutorial, used in order; each relies on the game state the one before left. + // TODO (task #22): they replay Butters' recorded stick holds; the same walks are lines on the decomp grids in Data/PokemonBDSP_AutoStory_Segment00Lines, + // tested offline with the route records. Swap in walk_waypoints() over Segment00Lines::lines() only after a new-game run has confirmed where each scene leaves the player, with walk_through_grass()'s battle handling on the Route 201 grass. // --------------------------------------------------------------------------- // Segment 00-01 begins diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h index 45b11164d2..3d53dcf980 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h @@ -16,6 +16,7 @@ #include #include #include "Common/Cpp/Time.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/Tools/VideoStream.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "Pokemon/Navigation/Pokemon_MapSet.h" diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index a3d27d04d5..625af88a54 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1567,6 +1567,10 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.h Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.h + Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.cpp + Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGym.h + Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.cpp + Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Segment00Lines.h Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.h Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h @@ -1576,6 +1580,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.h + Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.cpp + Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Segment00_Tests.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.cpp Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Location.h Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_NewGame.cpp