diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index d0966df32f..021c06a41f 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -197,6 +197,8 @@ add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES}) include(cmake/EmbedTextFiles.cmake) pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/TestMaps Pokemon/Navigation/Pokemon_Navigation_Tests.h PokemonAutomation::Pokemon navigation_test_map_json) +pa_embed_text_files(SerialProgramsLib Source/PokemonBDSP/Programs/AutoStory/Maps + PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.h PokemonAutomation::NintendoSwitch::PokemonBDSP bdsp_map_json) # Create binary target diff --git a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp index 10dd5da86f..929a888bbd 100644 --- a/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp @@ -18,6 +18,7 @@ #include "Programs/AutoStory/PokemonBDSP_AutoStoryTools.h" #include "PokemonBDSP_Tests.h" #include "Inference/PokemonBDSP_MenuDetector.h" +#include "Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h" #include "Programs/AutoStory/PokemonBDSP_AutoStory_Tests.h" namespace PokemonAutomation{ @@ -289,6 +290,7 @@ bool run_bag_screenshot_tests(Logger& logger, const std::string& folder){ void add_tests(UnitTestDatabase& database){ database.add(); add_tests_MenuDetector(database); + add_tests_AutoStory_MapGrids(database); add_tests_AutoStory(database); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md index b75f9f3292..8117fba767 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/MAPS.md @@ -2,10 +2,10 @@ Each map file's header starts with the same three lines, kept current with the code: -- **Map source**: where the tiles come from. "Decomp" means the Pokemon Platinum - decompilation's collision table (pret/pokeplatinum `map_data_NNN.bin`) with the - objects from its events file; BDSP keeps Diamond/Pearl's layout, and Platinum's - few changes show up on the console. "DP image" means a Bulbapedia map image +- **Map source**: where the tiles come from. "Decomp" means a decompilation's + collision table (pret/pokediamond `land_data` narc, or pret/pokeplatinum + `map_data_NNN.bin`) with the objects from its events file; BDSP keeps + Diamond/Pearl's layout, and Platinum's few changes show up on the console. "DP image" means a Bulbapedia map image traced by hand or by colour; those images have 12 px rows for 16 px columns, so a traced grid has 3/4 of a tile per row and drifts by the map's height differences (cliffs are painted taller than their tiles). @@ -15,12 +15,12 @@ Each map file's header starts with the same three lines, kept current with the c | map | source | checkpoints passing | next | |---|---|---|---| -| Route 201 | DP image (3/4 rows) | 00.02-00.04 | re-derive from the decomp | -| Route 202 | DP image (3/4 rows) | 00.04 | re-derive from the decomp | -| Sandgem Town | DP image rows 0-6, decomp rows 7+ | 00.04, 00.05 | two tiles on row 6; row-2 narrowing | -| Jubilife City | DP image (3/4 rows), console NPCs | 00.05, 01.01, 01.06, 01.07 | re-derive from the decomp | -| Oreburgh Mine B2F | DP image (stretched), console | 01.02, 01.03 (3x) | row 18 open, west ledge, top corridor row | -| Route 203 | DP image, east stretch from the console | 01.06 | re-derive the west and middle stretches | +| Route 201 | decomp (Diamond) | none yet (00.02-00.04 and mart_lady passed on the image grid) | re-run them | +| Route 202 | decomp (Diamond) | none yet (00.04 passed on the image grid) | re-run 00.04; the save-spot legs grew three rows | +| Sandgem Town | decomp (Diamond) | none yet (00.04, 00.05 passed with image rows 0-6) | re-run; the Route 202 entry stop is (29,1) | +| Jubilife City | decomp (Diamond), console NPCs | none yet (00.05, 01.01, 01.06, 01.07 passed on the image grid) | re-run; re-anchor the Mart clown and the steps walk | +| Oreburgh Mine B2F | decomp (Diamond) | none yet (01.02, 01.03 passed 3x on the stretched image grid) | re-run both | +| Route 203 | decomp (Diamond) | none yet (01.06 passed on the image grid) | re-run; the row to Jubilife is 18, four sand rows | | Route 204 South | decomp | 01.08 (1x) | more passes | | Ravaged Path | decomp rows 30-53 | 01.09 by hand | program pass | | Route 204 North | decomp | 01.10 (1x) | probe column 23; (12,6) marked from the console | @@ -33,5 +33,7 @@ Each map file's header starts with the same three lines, kept current with the c 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 -rows is the 2026-10-31 report (`compare.md`, with the decoded grids), to be -checked in with the re-derivation. +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 +console anchors. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_FloaromaTown.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_FloaromaTown.cpp index ea0b44d151..c91f67d5ea 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_FloaromaTown.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_FloaromaTown.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_FloaromaTown.h" namespace PokemonAutomation{ @@ -66,42 +67,7 @@ using namespace Pokemon; // has), and it has a Beauty at (10, 19) looking south instead of the man at // (11, 26). const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(######........................##)", // 0 - R"(##NN##........................##)", // 1 - R"(..............................##)", // 2 - R"(..............................##)", // 3 - R"(..............................##)", // 4 - R"(..............................##)", // 5 - R"(..............................##)", // 6 - R"(..................#####.......##)", // 7 - R"(..................#####.......##)", // 8 - R"(..................#####.......##)", // 9 - R"(......N...........#####.......##)", // 10 - R"(..........####...S##.##N......##)", // 11 - R"(..........####................##)", // 12 - R"(..........####................##)", // 13 - R"(..........#D##................##)", // 14 - R"(.......................####..S##)", // 15 - R"(.......................####...##)", // 16 - R"(.......................#D##...##)", // 17 - R"(..............................##)", // 18 - R"(.............S..................)", // 19 - R"(................................)", // 20 - R"(...................N............)", // 21 - R"(................................)", // 22 - R"(..NN..........#####....####...##)", // 23 - R"(..............#####....####...##)", // 24 - R"(..............#####....####...##)", // 25 - R"(...........N..##D##....#D##...##)", // 26 - R"(..............................##)", // 27 - R"(..............................##)", // 28 - R"(..............................##)", // 29 - R"(########.#...###################)", // 30 - R"(########.#...###################)", // 31 - }); - return grid; + return story_grid("FloaromaTown"); } const TilePos ROUTE_204_ARRIVAL{11, 29}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.cpp index 0c85e697bf..16089d130c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.cpp @@ -4,6 +4,9 @@ * */ +#include +#include +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_JubilifeCity.h" namespace PokemonAutomation{ @@ -14,116 +17,93 @@ namespace JubilifeCity{ using namespace Pokemon; -// Map source: Bulbapedia DP map image, classified by colour (2026-10-28); -// rows are 3/4 of a tile (64 real rows in 48). The story NPCs are placed -// from the console. -// Console checks: lamps' row and the Center door (00.05), east stairs to -// Route 203 (01.06, r230a), the north street (01.07). The decomp puts -// the traced door columns one column east of the console's. -// Status: 00.05, 01.01, 01.06 and 01.07 pass on it. Next: re-derive from the -// decomp (cells (23..24, 4..5)); re-check door spacing. +// Map source: the decomp (pret/pokediamond land_data narc_0018, 0016, 0017 +// and 0015, 2026-10-31) with the objects from its events file. Platinum +// differs only around the Global Terminal (columns 14..26, rows 30..45). +// Console checks (2026-10-30/31): the lamps (43,53) and (49,53), north from +// (52,53) to the Pokemon Center's door, the School's door from the +// Center's doorstep, the east street to Route 203 (01.06, r230a), the +// north street (01.07), and the four 00.05 people, placed from the +// console on the tiles the events file gives them. +// Status: no checkpoint has run on this grid yet. 00.05, 01.01, 01.06 and +// 01.07 passed on the colour-classified image grid it replaces (48 rows +// for 64) and must be re-run; re-check the Mart clown's tile (he wanders +// 182..184 on row 33 in Diamond) and the hand walk from the steps' top +// east to the house and north to the Center (the decomp has the plaza +// only 171..177 wide on rows 58..59). // -// Read from Bulbapedia's DP map of Jubilife City (1024 x 772 px): 16 px tiles -// from the top-left corner; the last 4 px rows are left out. Road and paved -// plaza are walkable; buildings, roofs, trees, planters, lamps, signs, fences -// and fountains are blocked. Tiles were classified by colour and only the -// ones on the 00.05 route checked by eye, so some open plaza next to a lamp -// or a pattern line may read as blocked; the planner goes around those, and -// anything the map lacks is found by the route walker. -// The DP layout matches BDSP (console B, 2026-10-28): the Trainers' School -// and the Pokemon Center either side of the main road, the Poke Mart and the -// fountain park north of them, the TV station at the top of the main road -// and the Poketch Company in the north-west. -// NPCs are the 00.05 story people, placed from the console: they stand still. -// Columns 59..63 of rows 16..17 are the stairs east to Route 203 (from the -// image, 2026-10-31; not walked on the console yet). +// Decoded from Pokemon Diamond's collision table: cells (23..24, 4..5) of +// the Sinnoh matrix, with the objects from its events file. Local (x, y) = +// world (x - 128, z - 736); 64 x 64 tiles. The console's measurements on +// the image grid were a column east of its doors; on this grid the lamps, +// the doors and the four people all land where the console put them. +// +// Exits: south, the 3-wide neck (45..47, 61) down to Route 202; east, the +// street (rows 21..24) to Route 203; north, (42..55, 0..1) to Route 204; +// west, the Route 218 gate on rows 22..23 (its warp tiles are 'D'). Doors +// are 'D' tiles walked into from below; the Trainers' School's doorway +// (40,40) and the Global Terminal's (21,42) are warp tiles stepped onto and +// marked 'D' as well, so a plan never steps on them. The main road runs +// from the steps (46..47, 60..62) north between the lamps (43,53), (49,53) +// and on up to the north exit; the doors' row 40 is open between the School +// and the Center (43..49), and the plaza below it is rows 41..52. +// People who stand still, from the events file: the Poketch president +// (46,35) and the clown west of the TV station (36,16), the 00.05 story +// people (hidden by flags before and after); an Ace Trainer (36,25) on the +// north road's west side, a Cashier (26,42), an Expert (44,44), two kids +// (52,46), (54,46) on the plaza and a School Kid (17,55): none of these +// five has been seen on the console yet. The clown by the Mart (55,33) and +// the one by the Poketch Company (15,18) wander three tiles in Diamond but +// stood still on the console (00.05, three runs): on the grid at their +// spawn tiles. Wanderers left off: an Ace Trainer along row 20 (21..23), +// one along row 21 (45..47), a Twin around (33,18), a School Kid on column +// 51 (rows 33..35), a Pokefan around (41,30). Rowan and the grunts at the +// north exit, the Collectors and Dawn are hidden by story flags. const TileGrid& grid(){ - // 0 1 2 3 4 5 6 - // 0123456789012345678901234567890123456789012345678901234567890123 - static const TileGrid grid({ - R"(################################################################)", // 0 - R"(################################################################)", // 1 - R"(##########################################......################)", // 2 - R"(##########################################......################)", // 3 - R"(##########################################......################)", // 4 - R"(###########################...##########.......#################)", // 5 - R"(###########################...##########........################)", // 6 - R"(########.##########.#######...##########..#.....################)", // 7 - R"(########.##########.#######...##########.......#################)", // 8 - R"(########.##########.#######....#########..#....#################)", // 9 - R"(########.##########.#######...#####D####..#....#################)", // 10 - R"(########..#########.#######.......N.......#....#################)", // 11 - R"(########............#######...............#....########....#####)", // 12 - R"(########...##N......#######..........##...#....########....#####)", // 13 - R"(######.#####.......#######.....................#######...#######)", // 14 - R"(##........................................#....#...........#####)", // 15 - R"(##...#..................................................#.......)", // 16 - R"(##...#...###..............###...........................#.......)", // 17 - R"(##...#..#####.################............#............#########)", // 18 - R"(##############################..###########....#.###...#########)", // 19 - R"(##############################..###########....######..#########)", // 20 - R"(##############################..###########....#######..####.###)", // 21 - R"(##############################..##########.....#################)", // 22 - R"(##############################..###########....#......N#########)", // 23 - R"(########.#####################..#.....##.......#........########)", // 24 - R"(########.#####################.......####............#..####.###)", // 25 - R"(########.#####.#########.######.##########..N.....###..#########)", // 26 - R"(##############..########.######.###########....#######.#########)", // 27 - R"(########.#####.############################....#################)", // 28 - R"(########.#####.############################....#################)", // 29 - R"(#################################.##.##D###....####D############)", // 30 - R"(########.#####..#########.#####........................#########)", // 31 - R"(#############....#######..####.####....................#####.###)", // 32 - R"(#############....##.......########.....................#####.###)", // 33 - R"(##############............##############...........N.N.#########)", // 34 - R"(##############............##############...............#########)", // 35 - R"(#############.............##############...........#############)", // 36 - R"(########.#####.###...###.###############...........#############)", // 37 - R"(########.#####.###...###.###############...........#############)", // 38 - R"(########.#####.###...###.###############.#.....#...#############)", // 39 - R"(########.#.#.#...........##########.....S..........#########.###)", // 40 - R"(#########................##########................#########.###)", // 41 - R"(########.........#.......##########................#########.###)", // 42 - R"(########.#.#.#.#..........###############.......############.###)", // 43 - R"(#########################################.........##############)", // 44 - R"(###########################################....#################)", // 45 - R"(###########################################DDDD#################)", // 46 - R"(################################################################)", // 47 - }); - return grid; + return story_grid("JubilifeCity"); } // Checked on the console (2026-10-30, CFR "walk"): 00.05's save stands // below the steps, against the wall just east of them (the banner reads // Jubilife City). West along that wall does not stop at the steps (it runs // to the trees); a tile west, then north, climbs them. North up the main -// road from the steps passes the lamps (41,39), (47,39) and does not stop +// road from the steps passes the lamps (43,53), (49,53) and does not stop // before the north exit. From the lamps' row, west stops at the house at -// (35..39, 34..39) and east at the house at (51..55, 36..42); north from -// (50,39) stops in front of the Pokemon Center. The road's white curbs -// (columns 42 and 47) are not walls, as the colour reading had them. +// (37..42, 47..52) and east at the house at (53..57, 49..56); north from +// (52,53) stops in front of the Pokemon Center. The steps are columns +// 45..47 of row 61; the save stands at (48,62) against (48,61), and the +// tile west then north puts us on column 47, a few rows up. On this grid +// east from rows 58..60 stops at column 49 and north from there at the lamp +// (49,53), not the Center: the climb must end on row 57 or above, or BDSP's +// plaza is wider than Diamond's there (re-check on the console). const std::vector& up_the_steps(){ - static const std::vector tiles{{45, 43}, {46, 43}, {45, 44}, {46, 44}, {45, 45}, {46, 45}}; + static const std::vector tiles{{46, 58}, {47, 58}, {46, 59}, {47, 59}, {46, 60}, {47, 60}}; return tiles; } -// Checked on the console (2026-10-30): from the Pokemon Center's doorstep, -// eleven one-tile holds west put us under this door, not the twelve these -// columns give; one of the two doors is a column off here. -const TilePos TRAINERS_SCHOOL_DOOR{39, 30}; -const TilePos POKEMON_CENTER_DOOR{51, 30}; -const TilePos TV_STATION_DOOR{35, 10}; +// The School's doorway is a warp tile stepped onto from (40,41); the +// Center's door is walked into from (52,41). On the console (2026-10-30) +// eleven one-tile holds west from the Center's doorstep put us under the +// School's door: the doorstep was the tile east of the door's column, as +// story_door_front() allows. +const TilePos TRAINERS_SCHOOL_DOOR{40, 40}; +const TilePos POKEMON_CENTER_DOOR{52, 40}; +const TilePos TV_STATION_DOOR{36, 15}; -// On the main road just north of the school and the Center. Talked to from -// the east, facing west (also works from the south). -const TilePos POKETCH_PRESIDENT{44, 26}; -// Below the Poke Mart's planters, where the road meets the plaza. -const TilePos CLOWN_MART{54, 23}; -// West of the TV station door. -const TilePos CLOWN_TV_STATION{34, 11}; -// East of the Poketch Company's sign. Talked to from the south on the -// console; from the east a walk west along row 13 stops right beside him. -const TilePos CLOWN_POKETCH_COMPANY{13, 13}; +// On the main road, five rows north of the School's and the Center's +// doors' row and six columns west of the Center's door. Talked to from the +// east, facing west (also works from the south). +const TilePos POKETCH_PRESIDENT{46, 35}; +// Below the Poke Mart's planters, where the road meets the plaza: his spawn +// tile; he wanders a tile either side in Diamond, and the console had him +// a tile east of it. +const TilePos CLOWN_MART{55, 33}; +// West of the TV station door, right below it. +const TilePos CLOWN_TV_STATION{36, 16}; +// East of the Poketch Company's sign, a row below it. Talked to from the +// south on the console; from the east a walk west along row 18 stops right +// beside him. +const TilePos CLOWN_POKETCH_COMPANY{15, 18}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.h index 367a3087ad..941b89ff77 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.h @@ -2,8 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * Jubilife City as a tile grid, read from Bulbapedia's DP map, with the - * places and people of checkpoint 00.05. + * Jubilife City as a tile grid, from the Diamond decompilation's collision + * table, with the places and people of checkpoint 00.05. */ #ifndef PokemonAutomation_PokemonBDSP_AutoStory_JubilifeCity_H @@ -21,8 +21,8 @@ namespace JubilifeCity{ const Pokemon::TileGrid& grid(); // Where we may stand after climbing the steps from where 00.05 starts: -// below them, against the wall just east of them (off this map's bottom -// edge), then a tile west and about two tiles north. +// below them, against the wall just east of them, then a tile west and +// about two tiles north. const std::vector& up_the_steps(); // Doors: walk north from the tile below to enter. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp index f7172ce4bd..3198d18e18 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_LakeVerity.h" namespace PokemonAutomation{ @@ -56,42 +57,7 @@ using namespace Pokemon; // separate map (MAP_LAKE_VERITY_GALACTIC), reached from the same Lakefront // warp tiles. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(################################)", // 0 - R"(################################)", // 1 - R"(################################)", // 2 - R"(################################)", // 3 - R"(......############....##########)", // 4 - R"(......############....##########)", // 5 - R"(.......###########......########)", // 6 - R"(.......###########......########)", // 7 - R"(.......###########".....########)", // 8 - R"(.......###########""....########)", // 9 - R"(################""""....########)", // 10 - R"(################NN""....########)", // 11 - R"(##############."""""..##########)", // 12 - R"(##############.""""...##########)", // 13 - R"(############..."""..############)", // 14 - R"(############........############)", // 15 - R"(##########..........############)", // 16 - R"(##########..........############)", // 17 - R"(############......##############)", // 18 - R"(############....N.##############)", // 19 - R"(############......##############)", // 20 - R"(############......##############)", // 21 - R"(##############..################)", // 22 - R"(################################)", // 23 - R"(################################)", // 24 - R"(################################)", // 25 - R"(################################)", // 26 - R"(################################)", // 27 - R"(################################)", // 28 - R"(################################)", // 29 - R"(################################)", // 30 - R"(################################)", // 31 - }); - return grid; + return story_grid("LakeVerity"); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.cpp new file mode 100644 index 0000000000..0b7a20d966 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.cpp @@ -0,0 +1,115 @@ +/* BDSP AutoStory - Map grids + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "PokemonBDSP_AutoStory_MapGrids.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + +using Pokemon::MapData; +using Pokemon::TileGrid; +using Pokemon::TileKind; +using Pokemon::TilePos; +using Pokemon::TileType; + + +namespace{ + +std::optional tile_type_of(TileKind kind){ + switch (kind){ + case TileKind::WALL: return TileType::BLOCKED; + case TileKind::OPEN: return TileType::WALKABLE; + case TileKind::TALL_GRASS: return TileType::TALL_GRASS; + case TileKind::LEDGE_SOUTH: return TileType::LEDGE; + case TileKind::DOOR: return TileType::DOOR; + case TileKind::SIGN: return TileType::SIGN; + default: return std::nullopt; + } +} + +} + +TileGrid tile_grid_from_map(const MapData& map){ + std::vector rows; + for (int y = 0; y < map.tiles.height; y++){ + std::string row; + for (int x = 0; x < map.tiles.width; x++){ + const TileKind kind = map.tiles.at(TilePos{x, y}); + const std::optional type = tile_type_of(kind); + if (!type){ + throw ParseException(std::format( + "{}: glyph '{}' at {} has no BDSP tile.", map.name, Pokemon::glyph_of(kind), Pokemon::to_string(TilePos{x, y}) + )); + } + row += Pokemon::tile_char(*type); + } + rows.push_back(std::move(row)); + } + for (const Pokemon::MapObject& object : map.objects){ + if (object.kind != Pokemon::ObjectKind::NPC || object.wander){ + throw ParseException(std::format("{}: object {} is not a person standing still.", map.name, object.name)); + } + rows[object.y][object.x] = Pokemon::tile_char(TileType::NPC); + } + return TileGrid(rows); +} + +std::optional grid_difference(const TileGrid& here, const TileGrid& there){ + if (here.width() != there.width() || here.height() != there.height()){ + return std::format("{} x {} here, {} x {} there", here.width(), here.height(), there.width(), there.height()); + } + for (int y = 0; y < here.height(); y++){ + for (int x = 0; x < here.width(); x++){ + const TilePos pos{x, y}; + if (here.at(pos) != there.at(pos)){ + return std::format( + "{}: '{}' here, '{}' there", + Pokemon::to_string(pos), Pokemon::tile_char(here.at(pos)), Pokemon::tile_char(there.at(pos)) + ); + } + } + } + return std::nullopt; +} + + +namespace{ + +const std::map& story_grids(){ + static const std::map grids = []{ + std::map parsed; + for (const auto& [name, json] : bdsp_map_json()){ + const MapData map = Pokemon::parse_map(parse_json(json), name + ".json"); + if (map.name != name){ + throw ParseException(std::format("{}.json: name is \"{}\".", name, map.name)); + } + parsed.emplace(name, tile_grid_from_map(map)); + } + return parsed; + }(); + return grids; +} + +} + +const TileGrid& story_grid(const std::string& name){ + const std::map& grids = story_grids(); + if (auto iter = grids.find(name); iter != grids.end()){ + return iter->second; + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "No BDSP story map named \"" + name + "\"."); +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.h new file mode 100644 index 0000000000..41f0d61d64 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.h @@ -0,0 +1,52 @@ +/* BDSP AutoStory - Map grids + * + * From: https://github.com/PokemonAutomation/ + * + * The story's maps are JSON files in the shared map schema + * (Pokemon_MapData.h), PokemonBDSP/Programs/AutoStory/Maps, built into the + * program by CMake, read with the shared loader and turned into the tile + * grids the planner walks. Each map's X::grid() returns story_grid("X"). + * + * TODO: move the maps to PokemonAutomation/Packages (Resources/PokemonBDSP/Maps) when ready + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_MapGrids_H +#define PokemonAutomation_PokemonBDSP_AutoStory_MapGrids_H + +#include +#include +#include +#include +#include "Pokemon/Navigation/Pokemon_MapData.h" +#include "Pokemon/Navigation/Pokemon_TileGrid.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +// (name, JSON text) of each map in PokemonBDSP/Programs/AutoStory/Maps/, +// built into the program by pa_embed_text_files() (cmake/EmbedTextFiles.cmake). +const std::vector>& bdsp_map_json(); + +// A map's tiles as a tile grid: walls, open ground, tall grass, south +// ledges, doors and signs; a standing person ("npc" object) is an NPC tile. +// Throws ParseException, naming the map, for what BDSP's grids have no +// tile for (water, ledges other than south, items, wanderers). +Pokemon::TileGrid tile_grid_from_map(const Pokemon::MapData& map); + +// "(x, y): 'N' here, '.' there", or nothing when the grids are the same +// size and equal cell for cell. +std::optional grid_difference(const Pokemon::TileGrid& here, const Pokemon::TileGrid& there); + +// The grid of the map `name`, read from bdsp_map_json() once. Throws +// InternalProgramError for a name it does not have. +const Pokemon::TileGrid& story_grid(const std::string& name); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghCity.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghCity.cpp index a9df9b327e..781af0c643 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghCity.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghCity.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_OreburghCity.h" namespace PokemonAutomation{ @@ -76,74 +77,7 @@ using namespace Pokemon; // and (39, 38), a Battle Girl at (51, 21), a Machop at (56, 46) and a // wandering Machop around (35, 45), none of which Diamond has. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 4 5 6 - R"(#########################################......#################)", // 0 - R"(#########################################...S..#################)", // 1 - R"(#########################################......#################)", // 2 - R"(#########################################......#################)", // 3 - R"(#########################################...####################)", // 4 - R"(#########################################...####################)", // 5 - R"(#########################################....###################)", // 6 - R"(############.#####.######.#.############.....###################)", // 7 - R"(###########..#####..#####...############.....###################)", // 8 - R"(#########....#####..#####...############.....###################)", // 9 - R"(##.....########D######D######D##########.....###################)", // 10 - R"(##..S..###..........................####........#.#...##########)", // 11 - R"(##..................................####.....S........##########)", // 12 - R"(#D..................................####..............##########)", // 13 - R"(##..................................####..............####.#####)", // 14 - R"(##..................................####..............####.#####)", // 15 - R"(##.....###N............#######......#D##..............####.#####)", // 16 - R"(##.....##.......####...#######...............#####....####.#####)", // 17 - R"(#########.......####.#.#######..............######......#.######)", // 18 - R"(#########.......####...#######..............######.....#########)", // 19 - R"(#########.......#D####S###D###...............##D##.....#########)", // 20 - R"(#########........................................#.....#########)", // 21 - R"(#########........................................#.....#########)", // 22 - R"(#########........................................#....##########)", // 23 - R"(#########........................................#....##########)", // 24 - R"(#########..N.....................................#....##########)", // 25 - R"(##########.#.#..########.........................#....##########)", // 26 - R"(########################.######.############.....#....##########)", // 27 - R"(########################.######.###........#.....#....##D#######)", // 28 - R"(########################.######.###.#..#...#.....#.........#####)", // 29 - R"(############################################.....###############)", // 30 - R"(############################################.....###############)", // 31 - R"(############################################.....###############)", // 32 - R"(############################################.....###############)", // 33 - R"(############################################.....###############)", // 34 - R"(############################################.....###############)", // 35 - R"(############################################.....##D############)", // 36 - R"(###################################.########.....#...........###)", // 37 - R"(###################################.....####.....#...........###)", // 38 - R"(###################################.....####.....#...........###)", // 39 - R"(###################################....#####.....#...........###)", // 40 - R"(#####################################..#.........#...........###)", // 41 - R"(#####################################..#..#.#....#....#.#....###)", // 42 - R"(#####################################..#..#.#....#....#.#....###)", // 43 - R"(###################################....#.....................###)", // 44 - R"(###################################....#.....................###)", // 45 - R"(###################################....#.....................###)", // 46 - R"(###################################....#.....................###)", // 47 - R"(###################################....#.....................###)", // 48 - R"(###################################..###..#.#................###)", // 49 - R"(###################################..###..#.#...#.#########.####)", // 50 - R"(###################################..###........#.#########.####)", // 51 - R"(###################################....#..........#####.....####)", // 52 - R"(###################################...............#####.....####)", // 53 - R"(#####################################.............##.........###)", // 54 - R"(#####################################..####.#.....###.....######)", // 55 - R"(#####################################..####.#S....###.....######)", // 56 - R"(###########################################.......####.......###)", // 57 - R"(############################################.....#####.......###)", // 58 - R"(############################################.....#####.....#####)", // 59 - R"(######################################################..#..#####)", // 60 - R"(################################################################)", // 61 - R"(################################################################)", // 62 - R"(################################################################)", // 63 - }); - return grid; + return story_grid("OreburghCity"); } const TilePos POKEMON_CENTER_DOOR{47, 20}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGate.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGate.cpp index d9cc7439a1..310728cda5 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGate.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGate.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_OreburghGate.h" namespace PokemonAutomation{ @@ -41,42 +42,7 @@ using namespace Pokemon; // (24, 22..24) and Curtis (17, 22..24). Platinum decodes this cave // identically, terrain and objects. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(################################)", // 0 - R"(################################)", // 1 - R"(################################)", // 2 - R"(################################)", // 3 - R"(############..#......###########)", // 4 - R"(###########..........###########)", // 5 - R"(###########........#.###########)", // 6 - R"(###########..###################)", // 7 - R"(###########..###################)", // 8 - R"(###########..###################)", // 9 - R"(###########.####################)", // 10 - R"(############.###################)", // 11 - R"(###########.####################)", // 12 - R"(###########..###################)", // 13 - R"(###########..###################)", // 14 - R"(###########..###################)", // 15 - R"(###########..###################)", // 16 - R"(###########..###################)", // 17 - R"(############.###################)", // 18 - R"(###########..###################)", // 19 - R"(#####..N##...##########...#.####)", // 20 - R"(####....##...##########.N...####)", // 21 - R"(###D........................D###)", // 22 - R"(####...#....................####)", // 23 - R"(###########..............#.#####)", // 24 - R"(############.....N.#############)", // 25 - R"(###########..#.#...#############)", // 26 - R"(################################)", // 27 - R"(################################)", // 28 - R"(################################)", // 29 - R"(################################)", // 30 - R"(################################)", // 31 - }); - return grid; + return story_grid("OreburghGate"); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.cpp index ff6ad9c075..53e2d1dd6d 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_OreburghMine.h" namespace PokemonAutomation{ @@ -14,69 +15,48 @@ namespace OreburghMine{ using namespace Pokemon; -// Map source: Bulbapedia DP map image through devtools/maps/levels.py -// (stretched to 16 px tiles), then the console (2026-10-28). -// Console checks: corridor zigzag, the coal block row, Roark a row above the -// bottom (2026-10-28). -// Status: 01.02 and 01.03 pass 3x on it. Next: the decomp has row 18 open, a -// west ledge, and one more top-corridor row (compare.md 2.6); apply and -// re-run. +// Map source: the decomp (pret/pokediamond land_data narc_0314, matrix 006; +// 2026-10-31) with the objects from its events file; Platinum's +// map_data_337 is the same. +// Console checks (2026-10-28): the corridor's rocks zigzag a row at a time, +// the room's second row passes under the worker on the first, Roark +// stands a row above the bottom row between two rocks; the walk north +// from the corridor's corner reached the entrance hall (r99). +// Status: no checkpoint has run on this grid yet. 01.02 and 01.03 passed +// 3x on the stretched image grid it replaces, which had every row one +// lower, the top corridor a row short, the room's second row blocked +// and no ledge in the west corridor; re-run both. // -// Read from Bulbapedia's DP map Oreburgh_Mine_B2F_DP.png with -// devtools/maps/levels.py (--profile cave --height 512 --offset 0,4 -// --objects on --edits oreburgh_mine_b2f_edits.txt). The archive image is -// squashed to 512x395; stretched back to 512x512 its rocks sit on 16 px -// tiles both ways. Rocks, boulders, crates, the coal block, the workers and -// their Machop are blocked. Checked on the console (2026-10-28): the -// corridor's small rocks zigzag a row at a time; the coal block's top edge -// is drawn over the room's second row, which is walkable and is how to pass -// the worker on the first row; Roark stands a row above the bottom row. +// Decoded from Pokemon Diamond's collision table: the one cell of matrix +// 006, with the objects from its events file. Local (x, y) = world (x, z); +// 32 x 32 tiles. The way up to the entrance hall is the warp tile (15,1), +// marked 'D': stepping onto it leaves the room. The console walked north +// into the hall from column 14 (r99), where this table has the way up only +// at column 15: a stick hold drifts, or BDSP's stairs are wider. +// The corridor from the top (13..17, 2..6) zigzags down to the room's first +// row (15); the room's second row (17) is open from 2 to 29 and passes +// under the worker and his Machop on the first; the coal block fills +// (7..24, 18..25) with the corridors either side; the west corridor has a +// ledge (2..4, 19), crossed southward only; the bottom rows 28..29 run +// under the block. +// Objects, from the events file: Roark (18,28), between two rocks (17,28) +// and (19,28); workers who stand still at (8,28) looking north, (26,20) +// looking west and (21,15) with Machop at (20,15) and (27,15); Poke Balls +// at (4,28) and (26,24), walls until picked up. A Machop wanders along row +// 28, columns 11..13, and is left off the grid. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(################################)", // 0 - R"(################################)", // 1 - R"(################################)", // 2 - R"(###############.################)", // 3 - R"(#############.....##############)", // 4 - R"(#############.....##############)", // 5 - R"(#############.....##############)", // 6 - R"(#############.....##############)", // 7 - R"(#############...################)", // 8 - R"(#############...################)", // 9 - R"(#############.....##############)", // 10 - R"(#############..#..##############)", // 11 - R"(###############...##############)", // 12 - R"(#############...################)", // 13 - R"(#############.....##############)", // 14 - R"(###############...##############)", // 15 - R"(########...####.....##.....#.###)", // 16 - R"(##............................##)", // 17 - R"(##.#..###################.....##)", // 18 - R"(##....###################.....##)", // 19 - R"(##...######################...##)", // 20 - R"(#####.#####################...##)", // 21 - R"(##.########################...##)", // 22 - R"(##..########################..##)", // 23 - R"(##..########################..##)", // 24 - R"(##....#####################...##)", // 25 - R"(#####.#####################...##)", // 26 - R"(####..####################....##)", // 27 - R"(####..####################..####)", // 28 - R"(####....#..#.....#N#........####)", // 29 - R"(######......................####)", // 30 - R"(################################)", // 31 - }); - return grid; + return story_grid("OreburghMine"); } +// The first open row below the warp tile, where the walk in from the hall +// leaves us (or the row below: the plan's first legs run to walls and meet). const std::vector& corridor_top(){ - static const std::vector tiles{{14, 4}, {15, 4}, {16, 4}}; + static const std::vector tiles{{14, 2}, {15, 2}, {16, 2}}; return tiles; } -const TilePos ROARK{18, 29}; -const TilePos CORRIDOR_EXIT_START{14, 11}; +const TilePos ROARK{18, 28}; +const TilePos CORRIDOR_EXIT_START{14, 10}; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.h index 48764f46ba..4dc823b486 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.h @@ -21,7 +21,7 @@ namespace OreburghMine{ const Pokemon::TileGrid& grid(); // Where the walk in from the entrance hall leaves us: the top of the rocky -// corridor, below its timber frame. +// corridor, the first open row below the warp tile. const std::vector& corridor_top(); // Roark, between two rocks a row above the room's bottom row. Talked to from diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RavagedPath.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RavagedPath.cpp index 1af104acc6..500bc58358 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RavagedPath.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RavagedPath.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_RavagedPath.h" namespace PokemonAutomation{ @@ -33,64 +34,7 @@ using namespace Pokemon; // Bulbapedia's Ravaged_Path_DP.png (stretched from 528x672 to 528x864), with // '?' where the untraced west chambers continue; nothing we walk is there. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(#################################)", // 0 - R"(#################################)", // 1 - R"(#################################)", // 2 - R"(#################################)", // 3 - R"(#################################)", // 4 - R"(#################################)", // 5 - R"(#################################)", // 6 - R"(#################################)", // 7 - R"(#################################)", // 8 - R"(#################################)", // 9 - R"(#################################)", // 10 - R"(#################################)", // 11 - R"(#################################)", // 12 - R"(#################################)", // 13 - R"(#################################)", // 14 - R"(#################################)", // 15 - R"(#################################)", // 16 - R"(#################################)", // 17 - R"(#################################)", // 18 - R"(#################################)", // 19 - R"(#################################)", // 20 - R"(#################################)", // 21 - R"(#################################)", // 22 - R"(#################################)", // 23 - R"(#################################)", // 24 - R"(#################################)", // 25 - R"(#################################)", // 26 - R"(#################################)", // 27 - R"(#################################)", // 28 - R"(#################################)", // 29 - R"(..#####################.........#)", // 30 - R"(....############................#)", // 31 - R"(....############................#)", // 32 - R"(....############................#)", // 33 - R"(....############................#)", // 34 - R"(....############................#)", // 35 - R"(....##.#####.###................#)", // 36 - R"(....##.#....#.##................#)", // 37 - R"(....##.##.#...#########.........#)", // 38 - R"(....##....#..##########.........#)", // 39 - R"(....##.#.#.......#...############)", // 40 - R"(....###.....######...############)", // 41 - R"(....##############....#.......###)", // 42 - R"(....##############....#.......###)", // 43 - R"(..............####....##......###)", // 44 - R"(..............####...#######D####)", // 45 - R"(..............####...############)", // 46 - R"(..............####...####.......#)", // 47 - R"(..............####...####.......#)", // 48 - R"(..............####...####.......#)", // 49 - R"(..............####...####.......#)", // 50 - R"(..............#####D#####.......#)", // 51 - R"(..............###########.......#)", // 52 - R"(..............###########.......#)", // 53 - }); - return grid; + return story_grid("RavagedPath"); } const std::vector& rocks(){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.cpp index 992cda45d7..2a79840580 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_Route201.h" namespace PokemonAutomation{ @@ -14,74 +15,59 @@ namespace Route201{ using namespace Pokemon; -// Map source: Bulbapedia DP map image, traced by hand (2026-10-28). The -// image has 12 px rows for 16 px columns, so every row is 3/4 of a tile -// (decomp comparison, 2026-10-31). -// Console checks: north-east ledge row, Twinleaf and Sandgem gaps, the -// Potion lady wandering (2026-10-28/29). -// Status: 00.02 to 00.04 pass on it. Next: re-derive from the decomp (cells -// (26,3), (26,4)), keep the console anchors. +// Map source: the decomp (pret/pokediamond land_data narc_0005 and +// narc_0006, 2026-10-31) with the objects from its events file; +// Platinum's map_data_005/006 have the same terrain. +// Console checks: the border sign read from (54,4) facing east, row 3 open +// east of the grass to Sandgem's fence, row 5 to Sandgem without a stop, +// the Potion lady on row 3 (2026-10-28 to 30, CFR "walk"). +// Status: no checkpoint has run on this grid yet. 00.02 to 00.04 and the +// mart_lady checkpoint passed on the image-traced grid it replaces (3/4 +// of a tile per row) and must be re-run. // -// Read from Bulbapedia's DP map of Route 201 (1040 x 320 px). As on the -// Route 202 map, the tile grid starts 8 px in from the left edge: tile -// (x, y) covers pixels [8 + 16x, 24 + 16x) x [16y, 16y + 16). The trees sit -// about 3 px lower on their tiles than on the Route 202 map; tall grass and -// the NPC at the Potion girl fit a grid with no vertical offset. +// Decoded from Pokemon Diamond's collision table: cells (26,3) and (26,4) +// of the Sinnoh matrix, with the objects from its events file. Local (x, y) +// = world (x - 96, z - 839); 64 x 25 tiles, rows 0..2 are padding. The +// columns are the ones the image-traced grid had (its anchors matched the +// decomp exactly); the rows are the game's: the image gave 20 rows for 25. +// Sandgem Town's grid joins at column 64, row -3 (its front row is row 4). // -// Trees follow the Route 202 rules: tiles under trunks or mostly under a -// canopy are blocked. Ledges: row 10 west of the tall grass, and (53..56,7) -// in the north-east. On the console the north-east ledge is one row higher -// than it looks on the DP map, as on Route 202; the west one is unchecked. -// West edge, rows 9..12: towards Lake Verity. South gap (14..17, 19): -// Twinleaf Town. East edge, rows 3..6: Sandgem Town. -// Route 201 has no trainers. Its NPCs wander, so they are left off: a -// planned wall must stay put. The Poke Mart lady, who gives 10 Potions, is -// one of them: she roams the north-east tall grass (42..52, 3) and the open -// ground under the trees above it, and eight runs (r113a..r120a) never got -// her talk, so 00.04 buys its Potions in Sandgem instead. +// Edges: west, rows 6..7 and 11 (Lake Verity, off the map); south, the +// Twinleaf gap (14..17, 21..24); east, rows 3..6, into Sandgem. Ledges: +// row 12 (0..3 and 8..31) and (53..57, 9) in the north-east; both are +// jumped southward only. The north-east grass (42..52, 3..6) is four rows +// deep and its tree stub (51..52) stands on rows 7..12; the middle grass +// (20..29, 13..16) four rows; the south-east grass (42..57, 18) and +// (46..57, 19..20). +// Objects, from the events file: the signs (55,4) to Sandgem (BORDER_SIGN), +// (13,17) to Twinleaf and the Trainer Tips sign (40,12); a School Kid who +// stands at (57,8) looking west (not yet seen on the console). Route 201 +// has no trainers and no items on the ground. Wanderers, left off the grid: +// a Breeder around (27,15), columns 26..28, rows 14..16; a Lass along row +// 16, columns 44..48. The Poke Mart lady, who gives 10 Potions, stands +// still at (44,3) in Diamond's events file and on the console (the user, +// 2026-11-01): left off the grid, since her talk is walked to, not planned +// (r113a..r120a missed her by the walk, not by her moving). Rowan, Barry +// and the briefcase by the lake are hidden by story flags and left off. const TileGrid& grid(){ - // 0 1 2 3 4 5 6 - // 0123456789012345678901234567890123456789012345678901234567890123 - static const TileGrid grid({ - R"(################################################################)", // 0 - R"(################################################################)", // 1 - R"(################################################################)", // 2 - R"(##########################################"""""""""""...........)", // 3 - R"(##########################################"""""""""""..S........)", // 4 - R"(##########################################"""""""""##...........)", // 5 - R"(##..####..####....######..##....##..####.."""""""""##...........)", // 6 - R"(##..####..####....######..##....##..####.."""""""""##vvvv.######)", // 7 - R"(##........####............................"""""""""##.....######)", // 8 - R"(....####.................................."""""""""##.....######)", // 9 - R"(vvvv####vvvvvvvvvvvvvvvvvvvvvvvv........S."""""""""##.....######)", // 10 - R"(....####............""""""""""............................######)", // 11 - R"(....................""""""""""............................######)", // 12 - R"(########.....S......##########............................######)", // 13 - R"(##############....############################............######)", // 14 - R"(##############....############################""""""""""""######)", // 15 - R"(##############....##############################################)", // 16 - R"(##############....##############################################)", // 17 - R"(##############....##############################################)", // 18 - R"(##############....##############################################)", // 19 - }); - return grid; + return story_grid("Route201"); } -// Pixel (888,64) on the DP map, on the doors' row of Sandgem (world row 4): -// walking east along row 4 from the grass stops at (54,4), and facing east -// from there reads it. -// Checked on the console (2026-10-30, CFR "walk"): a row south of her row -// (row 3), east stops at the sign's west side and A reads "Route 201 -> -// Sandgem Town" (a green box); north from there is one row, to row 3. Row 3 -// runs on east past the sign's north side to the Lab's fence. Row 5, the -// path, runs from the grass's west edge to Sandgem without a stop. +// The arrow sign to Sandgem Town, world (151,843), on the row of Sandgem's +// doors (its row 7). Checked on the console (2026-10-30, CFR "walk"): a row +// south of the lady's row (row 3), east stops at the sign's west side and A +// reads "Route 201 -> Sandgem Town" (a green box); north from there is one +// row, to row 3. Row 3 runs on east past the sign's north side to the Lab's +// fence. Row 5, the path, runs from the grass's west edge to Sandgem without +// a stop. const TilePos BORDER_SIGN{55, 4}; +// Her spawn tile in Diamond is (44,3), the east end of the top grass row. // On the console (by hand, then through the Lab Console; 99715d5d6 and // f823453e9 on bdsp/new-game-intro-v2) she stood at (43,3), and walking // west along row 3 from the trees at its east end stopped at (44,3), facing -// her; her lines need one A each, 1.5 s apart. Later runs (r113a..r120a) -// found her wandering. +// her; her lines need one A each, 1.5 s apart. r113a..r120a +// missed her talk walking to her, not because she moved. // Checked on the console (2026-10-30, CFR "walk"), twice: from the grass's // west edge on row 5, north stops at the trees 2 rows up, and east from // there stops at her. r135a missed her walking west along row 4. diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.h index b9792e3607..24481753bf 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.h @@ -2,8 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * Route 201 (Twinleaf Town to Sandgem Town) as a tile grid, read from - * Bulbapedia's DP map; BDSP keeps DP's tile layout. + * Route 201 (Twinleaf Town to Sandgem Town) as a tile grid, from the + * Diamond decompilation's collision table; BDSP keeps DP's tile layout. */ #ifndef PokemonAutomation_PokemonBDSP_AutoStory_Route201_H diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.cpp index 459d591a65..9bb6b1a2a3 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_Route202.h" namespace PokemonAutomation{ @@ -14,98 +15,82 @@ namespace Route202{ using namespace Pokemon; -// Map source: Bulbapedia DP map image, traced by hand (2026-10-28); rows are -// 3/4 of a tile (34 real rows in 26). -// Console checks: south ledge on row 18, east wall at column 30 on row 16 -// (r75), sign (24,20). -// Status: 00.04 passes on it. Next: re-derive from the decomp (cell (25,5)); -// re-check the column-31 wall. +// Map source: the decomp (pret/pokediamond land_data narc_0014, with the +// margins from narc_0006, 0007 and 0173; 2026-10-31) and the objects +// from its events file; Platinum's map_data_014 has the same terrain. +// Console checks: the player under the south ledge at (22,24) beside the +// trees at (21,24), the sign a row below at (24,25), the save spot +// (30,24) against the east trees, Natalie's challenge at (22,22), east +// along the row above the ledge stops at column 30 and column 30 runs +// north to row 4 (r75), the catch spot's walls (2026-10-29/30); trees, +// not grass, at (15..20, 28..29) below the catch patch (r253: west +// along row 29 stopped at column 21, beside the trees); a tree at +// (21, 30), south of the pocket at (21, 29) where the catch's save +// loads (r254: south from there was blocked at once). +// Status: no checkpoint has run on this grid yet. 00.04 passed on the +// image-traced grid it replaces (26 rows for 32) and must be re-run; +// its legs south of the catch spot are three rows longer here. // -// Read from Bulbapedia's DP map of Route 202 (592 x 416 px). Its tile grid -// starts 8 px in from the left edge, so tile (x, y) covers pixels -// [8 + 16x, 24 + 16x) x [16y, 16y + 16). The half tiles at both side edges -// are trees and are left out. +// Decoded from Pokemon Diamond's collision table: cell (25,5) of the Sinnoh +// matrix, with the objects from its events file. Local (x, y) = world +// (x - 159, z - 800); 36 x 32 tiles, the whole cell, so the grid's edges +// are where the game changes its location banner. The columns are the ones +// the image-traced grid had (its ledges, tree pillars and signs matched the +// decomp exactly); the rows are the game's: the image gave 26 rows for 32. +// Sandgem Town's grid starts on the row below row 31, at column 1. // -// Trees: each tile under a trunk or a canopy that hides most of the ground -// is blocked. The thin top of a canopy that only overhangs the row above a -// tree is not. -// Ledges: rows 9 and 18. On the DP map the south ledge looks like row 19, -// but on the console the player stands at (22,19) right under it, beside -// the trees at (21,19), and the sign at (24,20) is one row below. -// The Poke Ball item at (3,6) is blocked. -// The east tree wall comes in to column 31 at rows 15 to 17: walking east -// along row 16 stops at column 30 on the console (r75), and column 30 is -// open north to row 4. -// NPCs stand on the tile under their feet; the sprites rise into the row -// above. The girl at (22,15), pixel (365,235), is a trainer. +// Exits: north, the gap (11..18, 0) to Jubilife City (EXIT_JUBILIFE in its +// middle); south, (21..30, 31) into Sandgem, where the road narrows to +// 25..30 for two rows. Ledges: row 10 (9..13 and +// 22..27) and row 23 (9..13 and 22..30), jumped southward only. The east +// wall is column 33 from row 10 to 20, column 32 on row 21 and column 31 on +// row 22, the row right above the south ledge: east along that row stops at +// column 30 (r75), and column 30 is open north from there to row 4 under +// Logan's row. +// Objects, from the events file: three trainers who stand still, Youngster +// Tristan (7,13), Lass Natalie (22,18) and Youngster Logan (26,4), all +// facing south, with the sight ranges the events give; a Potion ball (3,6), +// a wall until picked up; the signs (17,4) to Jubilife, (15,16) Trainer Tips +// and (24,25) to Sandgem. BDSP has trees where Diamond's catch patch has +// its two bottom rows, (15..20, 28..29): the console's patch is three rows +// between tree rows, as the image-traced grid had it. A Youngster who is not a trainer wanders along row +// 8, columns 9..11, and is left off the grid (the image-traced grid had him +// as a fourth trainer facing east). Dawn's tile (15,27) is hidden by a +// story flag. const TileGrid& grid(){ - // 0 1 2 3 - // 012345678901234567890123456789012345 - static const TileGrid grid({ - R"(###########........#################)", // 0 - R"(###########........#################)", // 1 - R"(###########........#################)", // 2 - R"(###########........#################)", // 3 - R"(###""""""........S..""""".N....#####)", // 4 - R"(###""""""..........."""""......#####)", // 5 - R"(####"""""..........."""""......#####)", // 6 - R"(###"""""".N...########"""......#####)", // 7 - R"(#########.....########.........#####)", // 8 - R"(#########vvvvv########vvvvvv...""###)", // 9 - R"(#######.......########"""""""""""###)", // 10 - R"(#######N..........####"""""""""""###)", // 11 - R"(###...............####"""""""""""###)", // 12 - R"(###............S..####"""""""""""###)", // 13 - R"(###...............####"""""""""""###)", // 14 - R"(###....##.........####N."""""""#####)", // 15 - R"(###""""##..............."""""""#####)", // 16 - R"(###""""##....................""#####)", // 17 - R"(###""""##vvvvv########vvvvvvvvv#####)", // 18 - R"(###""""##.....########.........#####)", // 19 - R"(###""""""......""""""...S......#####)", // 20 - R"(###""""""......""""""..........#####)", // 21 - R"(###""""""......""""""..........#####)", // 22 - R"(#####################..........#####)", // 23 - R"(#####################..........#####)", // 24 - R"(#########################......#####)", // 25 - }); - return grid; + return story_grid("Route202"); } -// Where 00.03's save after the catch stands: the bottom row of the tall-grass -// patch at (15..20, 20..22), nearest the Sandgem Town entrance at the bottom -// right. On the console the sign at (24,20) is 5 columns right and 2 rows up, -// and walking east stops at the trees after 11 tiles. -const TilePos CATCH_SPOT{19, 22}; +// Where 00.03's save after the catch stands: the bottom row of the +// tall-grass patch at (15..20, 25..27), world (178,827). On the console the +// sign at (24,25) is 5 columns right and 2 rows up, walking east stops at +// the trees after 11 tiles and north at the trees after 2; south are trees +// (the decomp's two more grass rows are trees in BDSP, r253). +const TilePos CATCH_SPOT{19, 27}; // Where 00.04 saves once it has Potions, before Route 202's trainers (the // console's saves from r113a..r117a stand here too): under the south ledge, -// against the east trees. -const TilePos SAVE_SPOT{30, 19}; +// against the east trees, world (189,824). +const TilePos SAVE_SPOT{30, 24}; -// Blue-cap trainer, feet at about (128,186), facing south. -const TilePos TRAINER_A{7, 11}; -// Blue-cap trainer, feet at about (175,125), facing east. -const TilePos TRAINER_B{10, 7}; -// Blue-cap trainer, feet at about (430,77), facing south. -const TilePos TRAINER_C{26, 4}; -// The girl at pixel (365,235), facing south. On the console she challenged -// us at (22,17), walking east along row 17. -const TilePos TRAINER_D{22, 15}; +// From the events file: each trainer's tile, facing and sight range. +// Natalie challenged us at (22,22), walking east along the row above the +// ledge (r75), the fourth tile of her sight. +const TilePos TRAINER_TRISTAN{7, 13}; +const TilePos TRAINER_NATALIE{22, 18}; +const TilePos TRAINER_LOGAN{26, 4}; -// Facing is read from the sprites. The range is a guess; DP trainers on -// early routes see a few tiles. const std::vector& trainer_sights(){ static const std::vector sights{ - {"trainer_a", TRAINER_A, Direction::SOUTH, 4}, - {"trainer_b", TRAINER_B, Direction::EAST, 4}, - {"trainer_c", TRAINER_C, Direction::SOUTH, 4}, - {"trainer_d", TRAINER_D, Direction::SOUTH, 4}, + {"tristan", TRAINER_TRISTAN, Direction::SOUTH, 5}, + {"natalie", TRAINER_NATALIE, Direction::SOUTH, 4}, + {"logan", TRAINER_LOGAN, Direction::SOUTH, 5}, }; return sights; } -// Pixel (256,8): the path in the middle of the 8-tile gap at (11..18, 0). +// The middle of the 8-tile gap at (11..18, 0), world (174,800), below the +// 3-wide neck of Jubilife's south exit (173..175). const TilePos EXIT_JUBILIFE{15, 0}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.h index f4fd37fac3..cee0a1e49a 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.h @@ -2,8 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * Route 202 (Sandgem Town to Jubilife City) as a tile grid. BDSP keeps the - * tile layout of DP, so the grid is read from Bulbapedia's DP map. + * Route 202 (Sandgem Town to Jubilife City) as a tile grid, from the + * Diamond decompilation's collision table; BDSP keeps DP's tile layout. */ #ifndef PokemonAutomation_PokemonBDSP_AutoStory_Route202_H @@ -26,12 +26,12 @@ extern const Pokemon::TilePos CATCH_SPOT; // save stands. Two walls pin it. extern const Pokemon::TilePos SAVE_SPOT; -// The three trainers, south to north. Which one is Tristan, Natalie or -// Logan is not known from the map. -extern const Pokemon::TilePos TRAINER_A; -extern const Pokemon::TilePos TRAINER_B; -extern const Pokemon::TilePos TRAINER_C; -extern const Pokemon::TilePos TRAINER_D; +// The three trainers, from the events file: Youngster Tristan in the west +// field, Lass Natalie above the south ledge, Youngster Logan by the east +// grass. All face south. +extern const Pokemon::TilePos TRAINER_TRISTAN; +extern const Pokemon::TilePos TRAINER_NATALIE; +extern const Pokemon::TilePos TRAINER_LOGAN; // Their sight lines, in this map's tiles. The story wants these battles. const std::vector& trainer_sights(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.cpp index 16e6ff6600..642168d015 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_Route203.h" namespace PokemonAutomation{ @@ -14,64 +15,56 @@ namespace Route203{ using namespace Pokemon; -// Map source: Bulbapedia DP map image, traced by hand, then the east stretch -// corrected on the console (r227 hand pass, 2026-10-31). -// Console checks: gate warp column, ledge row 15, three sand rows, row 17 -// straight to Jubilife (2026-10-31). -// Status: 01.06 passes on it (r230a). Next: re-derive the west and middle -// stretches from the decomp (cells (23,6), (23,7)). +// Map source: the decomp (pret/pokediamond land_data narc_0019 and +// narc_0020, with Jubilife's column 0 from narc_0016; 2026-10-31) and +// the objects from its events file. Platinum adds an X Defense ball at +// (40,14). +// Console checks (r227 hand pass, 2026-10-31): the Gate's warp at column +// 55, the ledge on row 15 (38..48), the beaten girl at column 43 on the +// second sand row, the row below her straight west to Jubilife (35 +// taps, no row change), the blue-haired trainer at the sand's west end. +// Status: no checkpoint has run on this grid yet. 01.06 passed on the +// image-traced grid it replaces (its east stretch corrected on the +// console) and must be re-run: the decomp has four sand rows under the +// ledge where the console counted three (9 taps south from (55,9); the +// decomp has 10 open tiles, so the first tap may only have turned). // -// Traced by hand from Bulbapedia's Sinnoh_Route_203_DP.png (976 x 368 px, -// 16 px tiles from the top-left corner; three panels joined by stairs). -// Checked on the console with D-pad taps (2026-10-31, r227 hand pass); -// the east stretch's ledge and sand sat two rows too high in the trace. -// - West stretch (columns 0..21): the road on rows 17..19 runs to -// Jubilife City at column 0; a fence closes row 16 west of the sign. -// - Middle stretch (24..35): the pond (29..35, 9..12) cuts the strip -// north of it, by the item ball, off from the rest: r222g's walk got -// stuck up there. The way through is along the bottom, rows 16..17. -// - East stretch (38..55): the Gate's mouth is (56, 9). South from -// (55, 9) goes 9 tiles to row 18. The ledge on row 15 (columns 38..48) -// is crossed southward only. The sand below it is three rows: the girl -// (beaten) stands on row 16 at column 43. -// - Row 17 runs in one straight line west from the sand, over both -// stairs, to Jubilife (35 taps, no row change). Row 16 also crosses the -// east stairs (36..37) but ends at the blue-haired trainer (30, 16) -// (r227b, r228a); row 18 ends at the stairs (r225a, r226a). -// The blue-haired man near the Gate and the woman on the road (13, 17) -// wander, so they are not on the map. -// Trainers ('N') stand still; they are walls once beaten. +// Decoded from Pokemon Diamond's collision table: cells (23,6) and (23,7) +// of the Sinnoh matrix, with the objects from its events file. Local +// (x, y) = world (x - 191, z - 740); 61 x 24 tiles. Column 0 is Jubilife's +// east edge. The columns are the ones the image-traced grid had (its gate +// warp, ledge and signs matched the decomp exactly); the rows are the +// game's: the image squeezed the west and middle stretches. +// - West stretch (columns 5..22): the field (5..22, 4..19) with grass at +// 5..8 (8..13), a ledge (18..22, 13), and the road on rows 17..19 that +// runs to Jubilife at column 0. +// - Middle stretch (23..37): the pond (29..34, 7..11) cuts the strip north +// of it, by the Repel ball (31,5), off from the rest: r222g's walk got +// stuck up there. The way through is along the bottom, rows 16..19. +// - East stretch (38..55): the Gate's mouth is (56,9), its warp tile +// (55,9). South from (55,9) is open to row 19. The ledge on row 15 +// (38..48) is crossed southward only. The sand below it is four rows, +// 16..19: the blue-haired trainer (Youngster Dallas, looks south, sees +// 4) at the sand's west end on its first row, the girl (Youngster +// Sebastian in the events file, looks west, sees 5) at (43,17) on its +// second. +// Row 18 runs in one straight line west from the sand to Jubilife; row 17 +// is blocked by the girl and the trainer, row 19 by trees at (36..37, 19). +// Objects, from the events file: trainers who stand still, 'N': Youngster +// Michael (13,10), looks west, sees 2; Dallas (31,16); Sebastian (43,17); +// Lass Madeline (49,8), looks south, sees 5. Items that block their tile +// until picked up, '#': a Poke Ball (20,10) and a Repel (31,5). Signs: to +// Jubilife (9,16), Trainer Tips (26,10) and (47,12), to Oreburgh (53,7); +// Jubilife's own sign to Route 203 stands at (7,16) in its events, not in +// this map's. Left off: a Lass who wanders along row 17 (14..16) and the +// Youngster at (54,16) who stands still in Diamond but wanders in BDSP (the +// blue-haired man near the Gate, on the console); Barry (10,17) is hidden +// by a story flag. const TileGrid& grid(){ - // 0 1 2 3 4 5 6 - // 0123456789012345678901234567890123456789012345678901234567890 - static const TileGrid grid({ - R"(#############################################################)", // 0 - R"(#############################################################)", // 1 - R"(#############################################################)", // 2 - R"(#############################################################)", // 3 - R"(#############################################################)", // 4 - R"(#############################################################)", // 5 - R"(#############################.."""""..""""""""""""""#########)", // 6 - R"(#####..............##########..#""""..""""""""""""""S...#####)", // 7 - R"(#####..............##########.........""""""""""N"......#####)", // 8 - R"(#####....##...####....##.....#########""""""""""""......D####)", // 9 - R"(#####""""##...####....##..S..#########""""""""""""......#####)", // 10 - R"(#####""""##...####....##.....#########"""""""""S""""""..#####)", // 11 - R"(#####""""##.N.####..#.##.....#########"""""""""""##"""..#####)", // 12 - R"(#####""""##...####....##....#####"""##....""...."##"""..#####)", // 13 - R"(#####""""##...####vvvv##....#####"""##....""...."##"""..#####)", // 14 - R"(#####"""".............##....#####"""##vvvvvvvvvvv"""""..#####)", // 15 - R"(#####.S...............##......N..""".......N....""""""..#####)", // 16 - R"(........................."""""..."""....................#####)", // 17 - R"(........................##############..................#####)", // 18 - R"(........................#####################################)", // 19 - R"(#############################################################)", // 20 - R"(#############################################################)", // 21 - R"(#############################################################)", // 22 - }); - return grid; + return story_grid("Route203"); } +// The warp tile the Gate puts us on, and its open neighbours. const std::vector& gate_exit(){ static const std::vector tiles{{55, 9}, {54, 9}, {55, 8}, {55, 10}}; return tiles; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.h index 1aee26300c..9bf526197b 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.h @@ -21,7 +21,7 @@ namespace Route203{ const Pokemon::TileGrid& grid(); // Where stepping out of the Oreburgh Gate may leave us when Route 203's -// banner shows: the tiles west of the cave's mouth. +// banner shows: the warp tile west of the cave's mouth and its neighbours. const std::vector& gate_exit(); diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.cpp index cc15602760..eee289d1ce 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_Route204.h" namespace PokemonAutomation{ @@ -41,42 +42,7 @@ using namespace Pokemon; // Before 2026-10-31 this grid was traced from Bulbapedia's DP map image, // whose rows are 12 px to the columns' 16: every row was 3/4 of a tile. const TileGrid& north_grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(########.#...###################)", // 0 - R"(########.#...###################)", // 1 - R"(####.....#...########.##########)", // 2 - R"(##########...#......#.##########)", // 3 - R"(#####....#...#......#..........N)", // 4 - R"(#####....#"""#......#...######..)", // 5 - R"(#####....#""####################)", // 6 - R"(##########"""..NN.....##########)", // 7 - R"(##........""""".......##########)", // 8 - R"(##..######.""""..S....##########)", // 9 - R"(###.#....#."""........##########)", // 10 - R"(##..#....#."".........##########)", // 11 - R"(##########..........N...########)", // 12 - R"(##########..............########)", // 13 - R"(##########...####"""""""########)", // 14 - R"(##########vvv####"""""""########)", // 15 - R"(##########...######"""""########)", // 16 - R"(##########...######"""""########)", // 17 - R"(##########...######"""""########)", // 18 - R"(##########...######"."""########)", // 19 - R"(##########.......N....""########)", // 20 - R"(##########............##########)", // 21 - R"(##########............##########)", // 22 - R"(##########...##.....#.##########)", // 23 - R"(##########...##.......##########)", // 24 - R"(##########...###################)", // 25 - R"(##########...#######.###########)", // 26 - R"(##########............##########)", // 27 - R"(##########............##########)", // 28 - R"(##########............##########)", // 29 - R"(##########............##########)", // 30 - R"(##########...###################)", // 31 - }); - return grid; + return story_grid("Route204North"); } const TilePos CAVE_EXIT{20, 26}; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204South.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204South.cpp index cef5a1ede8..4f022f4dce 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204South.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204South.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_Route204South.h" namespace PokemonAutomation{ @@ -41,41 +42,7 @@ using namespace Pokemon; // Row 31, columns 12 to 15, joins the top of Jubilife's north street: // walking south there leaves the route. const TileGrid& grid(){ - static const TileGrid grid({ - R"(################################)", // 0 - R"(###########D###.################)", // 1 - R"(########..S.....################)", // 2 - R"(########........################)", // 3 - R"(########........################)", // 4 - R"(##########..."##################)", // 5 - R"(##########..."##################)", // 6 - R"(##########..""##################)", // 7 - R"(##########.N""##################)", // 8 - R"(####""""""""""##################)", // 9 - R"(####""""""""""##################)", // 10 - R"(####""""""""""##################)", // 11 - R"(####""""""""""############...###)", // 12 - R"(####""""""""""############....##)", // 13 - R"(####""""""""""#..###############)", // 14 - R"(##""""""""""""#..###############)", // 15 - R"(##""""""""""""#..###############)", // 16 - R"(##""""""""""""S.################)", // 17 - R"(##"""""N........################)", // 18 - R"(##""""".........#.##############)", // 19 - R"(##""""".........#.##############)", // 20 - R"(##.#########N...#.##############)", // 21 - R"(############....#......"########)", // 22 - R"(############....######""########)", // 23 - R"(############....######""########)", // 24 - R"(############....######""########)", // 25 - R"(############....######""########)", // 26 - R"(############....######""########)", // 27 - R"(###.######.#....#.."""""########)", // 28 - R"(##..######.#....#...""""########)", // 29 - R"(##########.#....#.......########)", // 30 - R"(############....######..########)", // 31 - }); - return grid; + return story_grid("Route204South"); } std::vector jubilife_entry(){ 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 3c1e8c6df4..98fee479b8 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RouteRecords.cpp @@ -44,20 +44,20 @@ const TileGrid* none(){ return nullptr; } // those grids carry no route and no trace. const std::vector& all(){ static const std::vector records{ - {"01.01", "Jubilife Pokemon Center to Barry on Route 203", "Jubilife City", jubilife, false, std::nullopt, { + {"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}, {Direction::NORTH, 16, LegEnd::COUNT, "stick 3960 ms: up to the street east to Route 203", false}, {Direction::SOUTH, 2, LegEnd::COUNT, "stick 600 ms: back onto the street", false}, {Direction::EAST, 0, LegEnd::NPC, "along the street onto Route 203 until Barry stops us; rows retried 0, +1, +1, -3, -1 when a wall comes first"}, - }, "jubilife_to_barry(); stick holds from the console, 2026-10-29; the Jubilife grid's rows are 3/4 of a tile, so the counts are not traceable on it (task #21)"}, - {"01.02", "Barry to Oreburgh City through the Oreburgh Gate", "Route 203", route203, false, std::nullopt, { + }, "jubilife_to_barry(); stick holds from the console, 2026-10-29, counted in tiles on the image grid's 3/4 rows: recount in taps before giving this record a start tile (task #21)"}, + {"01.02", "Barry to Oreburgh City through the Oreburgh Gate", "Route 203", route203, true, std::nullopt, { {Direction::EAST, 0, LegEnd::WALL, "along the row Barry stopped us on"}, {Direction::NORTH, 0, LegEnd::WALL, "to the top wall, then a row south at a time until east goes on (up to ten)"}, {Direction::EAST, 0, LegEnd::NPC, "to the Hiker"}, {Direction::EAST, 0, LegEnd::TRANSITION, "into the Oreburgh Gate"}, {Direction::EAST, 0, LegEnd::TRANSITION, "through the Gate into Oreburgh City"}, - }, "route203_to_oreburgh(); the west and middle of Route 203's grid are image-traced, the east stretch console-corrected (r227)"}, + }, "route203_to_oreburgh(); no start tile: Barry stops us on whichever row we came along"}, {"01.04", "Oreburgh Pokemon Center doorstep to the Gym", "Oreburgh City", oreburgh_city, true, OreburghCity::POKEMON_CENTER_DOORSTEP, { {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)"}, @@ -76,11 +76,11 @@ 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", "Jubilife's east edge to Rowan's scene", "Jubilife City", jubilife, false, std::nullopt, { + {"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"}, - }, "jubilife_to_rowan(); by hand 2026-10-31 (18 presses), r230b; Jubilife grid not traceable (rows 3/4)"}, - {"01.08", "Jubilife's north street onto Route 204", "Jubilife City", jubilife, false, std::nullopt, { + }, "jubilife_to_rowan(); by hand 2026-10-31 (18 presses), r230b; the stick hold's count was taken on the image grid's 3/4 rows, so no start tile yet"}, + {"01.08", "Jubilife's north street onto Route 204", "Jubilife City", jubilife, true, std::nullopt, { {Direction::NORTH, 0, LegEnd::BANNER, "up the street until Route 204's banner; the planned walk to the Ravaged Path door follows"}, }, "jubilife_to_ravaged_path() step 1"}, {"01.09", "Ravaged Path's east end out onto Route 204 North", "Ravaged Path", ravaged_path, true, RavagedPath::EAST_END, { diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp index a9ff89b042..84afae03f1 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_SandgemTown.h" namespace PokemonAutomation{ @@ -14,94 +15,77 @@ namespace SandgemTown{ using namespace Pokemon; -// Map source: rows 0 to 6 from Bulbapedia's DP map image; rows 7 and on from -// the decomp (map_data_007), signs and doors from its events. -// Console checks: all three doors, five signs, the north road stop at (29,2) -// (2026-10-29). -// Status: 00.04 and 00.05 pass on it. Next: open the Lab-Center gap on row 6 -// ((11,6), (14,6)); re-check where the north road narrows (row 2 or 3). +// Map source: the decomp (pret/pokediamond land_data narc_0007, 2026-10-31) +// with the signs and doors from its events file; Platinum's map_data_007 +// is the same. The rows from the doors down have been the decomp's since +// 2026-10-29; the four rows above the doors were the image's, and the +// grid now starts where the game's map does, four rows higher. +// Console checks: all three doors, five signs, the row below the doors east +// to the trees and north from it, the Lab's sign read facing west, the +// walk south from Route 202 stopping above the Mart (2026-10-29/30). +// Status: no checkpoint has run on this grid yet. 00.04, 00.05 and the +// Sandgem Center and Mart lady checkpoints passed with the image's rows +// above the doors; changed since: every tile is 4 rows lower (the grid +// begins at the map's edge), the road from Route 202 narrows on row 6 +// (the walk south from Route 202 stops at (29,5)), and the gap between +// the Lab's fence and the Center on the doors' row is four wide (11..14). +// Re-run them all. // -// Read from Bulbapedia's DP map of Sandgem Town (Sandgem_Town_DP.png, -// 560 x 368 px). The tile grid starts 8 px in from the left edge, as on the -// route maps: tile (x, y) covers pixels [8 + 16x, 24 + 16x) x [16y, 16y + 16). +// Decoded from Pokemon Diamond's collision table: cell (26,5) of the Sinnoh +// matrix, with the signs and doors from its events file. Local (x, y) = +// world (x - 160, z - 832); 34 x 32 tiles, the whole cell, so the grid's +// edges are where the game changes its location banner. Route 201 joins at +// column -64, row 7 (its row 4 is this grid's row 11); Route 202's road +// comes down onto row 0 at columns 24..29. // // Buildings are blocked; each door is the tile the player walks into, on -// the building's front row. Top left: Professor Rowan's lab, with a fence -// running west along row 6 to the map edge. Top middle: Pokemon Center. -// Top right: Poke Mart. Exits: west, rows 7..11 (Route 201); north, -// (20..29, 0) (Route 202); south, (20..25, 27) (the beach). +// the building's front row (row 10). Top left: Professor Rowan's lab, with a +// fence running west along row 10 to the map edge. Top middle: Pokemon +// Center. Top right: Poke Mart. Exits: west, rows 11..15 (Route 201); north, +// (24..29, 0) (Route 202: the road is 6 wide on rows 0..1, 10 wide on rows +// 2..5 and 6 wide again, columns 20..25, on rows 6..9); south, (20..25, 31) +// (the beach). // -// Rows 7 and on are the game's own collision, not the map image: Platinum's -// land data for Sandgem (pret/pokeplatinum res/field/maps/data/ -// map_data_007.bin, its permissions' collision bit; grid row = the map's -// row - 4, column = the map's column), with the signs and doors from -// res/field/events/events_sandgem_town.json. The image squeezed rows 7..18 -// into 7..15: it put both houses' doors on row 15, where the game has them -// on row 18, and the east house's wall at rows 10..14 where the game has -// open ground. r123a planned a west leg to that wall on row ~11, ran on -// past it and entered the west house's door going north. The townspeople -// south of the Mart (a youngster and two breeders) wander: not marked. +// The image squeezed the rows below the doors: it put both houses' doors +// three rows too high and the east house's wall where the game has open +// ground; r123a planned a west leg to that wall, ran on past it and entered +// the west house's door going north. The townspeople south of the Mart (a +// youngster and two breeders, who stand still in Diamond at (11,22) and +// (23,20)) wander on the console: not marked. Rowan, Barry and Dawn are +// hidden by story flags. // -// Checked on the console: walking south from Route 202 (30,22) stops at -// (29,2) above the Poke Mart, and walking west from there stops at (20,2). -// The lab's sign stands on row 7, in front of the fence: walking west along -// row 7 stops at it. +// Checked on the console: walking south from Route 202 along its column 30 +// stops above the Poke Mart, where the road narrows (counted as two rows +// above the signs' row on the image grid; the decomp has the wall at (29,6), +// so the stop is (29,5)), and walking west from there stops at (20,5). The +// lab's sign stands on row 11, in front of the fence: walking west along +// row 11 stops at it. const TileGrid& grid(){ - // 0 1 2 3 - // 0123456789012345678901234567890123 - static const TileGrid grid({ - R"(####################..........####)", // 0 - R"(####################..........####)", // 1 - R"(####################..........####)", // 2 - R"(####################......########)", // 3 - R"(####################......########)", // 4 - R"(####################......########)", // 5 - R"(########D###..###D##S....S#D######)", // 6 - R"(.....S........................####)", // 7 - R"(..............................####)", // 8 - R"(..............................####)", // 9 - R"(..............................####)", // 10 - R"(..............................####)", // 11 - R"(######........................####)", // 12 - R"(######........................####)", // 13 - R"(######.........#####..........####)", // 14 - R"(##########.....#####..........####)", // 15 - R"(##########.....#####..........####)", // 16 - R"(##########.....#####..........####)", // 17 - R"(#######D##....S#D###..S.......####)", // 18 - R"(######........................####)", // 19 - R"(######........................####)", // 20 - R"(######........................####)", // 21 - R"(######....................########)", // 22 - R"(####################......########)", // 23 - R"(####################......########)", // 24 - R"(####################......########)", // 25 - R"(####################......########)", // 26 - R"(####################......########)", // 27 - }); - return grid; + return story_grid("SandgemTown"); } -// Pixel (144,110): the lab's door, between its two front windows. -const TilePos LAB_DOOR{8, 6}; -// Pixel (288,104): the Pokemon Center's glass door. -const TilePos POKEMON_CENTER_DOOR{17, 6}; -// On the console, walking south from (20,2) stops at (20,5), above it. -const TilePos POKEMON_CENTER_SIGN{20, 6}; -// Pixel (448,104): the Poke Mart's door. -const TilePos POKE_MART_DOOR{27, 6}; +const TilePos ROUTE_202_ENTRY_STOP{29, 5}; +// The lab's door, between its two front windows. +const TilePos LAB_DOOR{8, 10}; +// The Pokemon Center's glass door. +const TilePos POKEMON_CENTER_DOOR{17, 10}; +// On the console, walking south along the road's west edge above it stops +// at (20,9), above it. +const TilePos POKEMON_CENTER_SIGN{20, 10}; +// The Poke Mart's door. +const TilePos POKE_MART_DOOR{27, 10}; // Walking east along the doors' front row stops here, against the trees. -// Checked on the console (2026-10-30, CFR "walk"): east along row 8 (the -// path under the Lab's sign) from Route 201 stops at (29,8), and north from -// there stops here. From below the Center's sign (20,7), west stops at the +// Checked on the console (2026-10-30, CFR "walk"): east along row 12 (the +// path under the Lab's sign) from Route 201 stops at (29,12), and north from +// there stops here. From below the Center's sign (20,11), west stops at the // Lab's sign, which reads facing west; south from there stops at the house // 4 rows down, and north back at the sign's row; west of the house's north // side is trees. A 200 ms hold south took one row; 300 ms took one or two. -const TilePos FRONT_ROW_EAST_END{29, 7}; +const TilePos FRONT_ROW_EAST_END{29, 11}; std::vector below_sign_gap(){ - return {{21, 7}, {22, 7}, {23, 7}, {24, 7}}; + return {{21, 11}, {22, 11}, {23, 11}, {24, 11}}; } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h index 7d34f0b783..cb5d223828 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h @@ -2,8 +2,8 @@ * * From: https://github.com/PokemonAutomation/ * - * Sandgem Town as a tile grid, read from Bulbapedia's DP map; BDSP keeps - * DP's tile layout. + * Sandgem Town as a tile grid, from the Diamond decompilation's collision + * table; BDSP keeps DP's tile layout. */ #ifndef PokemonAutomation_PokemonBDSP_AutoStory_SandgemTown_H @@ -20,9 +20,12 @@ namespace SandgemTown{ const Pokemon::TileGrid& grid(); +// Where the walk south from Route 202 down the road's east side stops, +// above the Poke Mart where the road narrows. +extern const Pokemon::TilePos ROUTE_202_ENTRY_STOP; extern const Pokemon::TilePos LAB_DOOR; extern const Pokemon::TilePos POKEMON_CENTER_DOOR; -// The sign east of the Pokemon Center's door. Walking north from row 10 in +// The sign east of the Pokemon Center's door. Walking north from row 14 in // its column stops on the tile below it. extern const Pokemon::TilePos POKEMON_CENTER_SIGN; extern const Pokemon::TilePos POKE_MART_DOOR; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.cpp index 6441fd17a0..25f7180d5f 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.cpp @@ -37,25 +37,16 @@ const char* const MAP_ROUTE_204_SOUTH = "Route 204 South"; const char* const MAP_ROUTE_203 = "Route 203"; -// Offsets come from how the Bulbapedia maps join: -// - Route 201 to Sandgem Town: the 16 px strip at the right of the Route -// 201 image matches the left of the Sandgem image, which puts Sandgem's -// tile column 0 on Route 201's column 64. Rows are 3 px apart, so the -// row comes from the edges: Sandgem's lab fence (row 6) lines up with -// the fence post at the right of Route 201's row 3, and Route 201's -// open rows 4..6 meet Sandgem's open rows 7..9. -// - Sandgem Town to Route 202: the 8 px strip at the bottom of the Route -// 202 image matches the top of the Sandgem image 16 px to the right, so -// Route 202's column x + 1 sits above Sandgem's column x. Route 202's -// open bottom row (25..30, 25) then meets Sandgem's (24..29, 0), with -// trees beside both. Sandgem's row 0 is taken as the row below Route -// 202's row 25; the 8 px overlap leaves a half-row doubt. +// Offsets are the maps' places in the game's world grid (the decomp's +// cells): Route 201 at world (96,839), Sandgem Town at (160,832), Route 202 +// at (159,800). Route 201's row 4 is Sandgem's row 11, below the doors, and +// Route 202's road comes down off its row 31 onto Sandgem's row 0. const MapSet& story_maps(){ static const MapSet maps = []{ MapSet maps; maps.add(MAP_ROUTE_201, Route201::grid(), {0, 0}); - maps.add(MAP_SANDGEM_TOWN, SandgemTown::grid(), {64, -3}); - maps.add(MAP_ROUTE_202, Route202::grid(), {63, -29}); + maps.add(MAP_SANDGEM_TOWN, SandgemTown::grid(), {64, -7}); + maps.add(MAP_ROUTE_202, Route202::grid(), {63, -39}); return maps; }(); return maps; @@ -82,29 +73,25 @@ const MapSet& route203_maps(){ } bool on_route203_west_line(const TilePos& pos){ - return pos.y == 17 && pos.x >= 24 && pos.x <= 42; + return pos.y == 18 && pos.x >= 24 && pos.x <= 42; } -// Columns 40..63, rows 8..20 of the Jubilife grid, as a map of its own: -// the cut is the map's edge, which no leg may -// cross or stop on, not a wall a plan could walk "to". In this corner the -// white curbs either side of the north road (columns 42 and 47) are opened: -// the console showed the main road's curbs are not walls (2026-10-30), and -// these look the same; not walked yet. +// Columns 42..63, rows 12..25 of the Jubilife grid (world x 170..191, +// z 748..761), as a map of its own: the cut is the map's edge, which no leg +// may cross or stop on, not a wall a plan could walk "to". namespace{ -const TilePos JUBILIFE_EAST_CORNER{40, 8}; +const TilePos JUBILIFE_EAST_CORNER{42, 12}; +const int JUBILIFE_EAST_BOTTOM = 25; } const MapSet& jubilife_east_maps(){ static const MapSet maps = []{ const TileGrid& city = JubilifeCity::grid(); const TilePos corner = JUBILIFE_EAST_CORNER; std::vector rows; - for (int y = corner.y; y <= 20; y++){ + for (int y = corner.y; y <= JUBILIFE_EAST_BOTTOM; y++){ std::string row; for (int x = corner.x; x < city.width(); x++){ - const TileType type = city.at({x, y}); - const bool curb = (x == 42 || x == 47) && y <= 16 && type == TileType::BLOCKED; - row += tile_char(curb ? TileType::WALKABLE : type); + row += tile_char(city.at({x, y})); } rows.push_back(row); } @@ -115,13 +102,13 @@ const MapSet& jubilife_east_maps(){ return maps; } -// Route 203's road (rows 17..19) meets Jubilife's east stairs, rows 16..17 -// of its grid, at its east edge; the banner shows a tile or two in. Both -// in the corner map's tiles, from the Jubilife grid's. +// Route 203's road (rows 17..19 of its grid) meets Jubilife's east street, +// rows 21..24 of its grid, at its east edge; the banner shows a tile or two +// in. Both in the corner map's tiles, from the Jubilife grid's. const std::vector& jubilife_east_entrance(){ static const std::vector tiles = []{ std::vector tiles; - for (int y = 16; y <= 17; y++){ + for (int y = 21; y <= 24; y++){ for (int x = 61; x <= 63; x++){ tiles.push_back({x - JUBILIFE_EAST_CORNER.x, y - JUBILIFE_EAST_CORNER.y}); } @@ -131,10 +118,11 @@ const std::vector& jubilife_east_entrance(){ return tiles; } +// The north road where it leaves the plaza, columns 44..48 of rows 16..20. bool on_jubilife_north_road(const TilePos& pos){ const int x = pos.x + JUBILIFE_EAST_CORNER.x; const int y = pos.y + JUBILIFE_EAST_CORNER.y; - return x >= 43 && x <= 46 && y >= 12 && y <= 14; + return x >= 44 && x <= 48 && y >= 16 && y <= 20; } const MapSet& oreburgh_mine_maps(){ @@ -214,12 +202,30 @@ std::vector story_door_front(const char* map, const TilePos& door){ return {below.next(Direction::WEST), below, below.next(Direction::EAST)}; } +std::vector story_catch_save_area(){ + const MapSet& maps = story_maps(); + std::vector area; + for (int y = 25; y <= 29; y++){ + for (int x = 15; x <= 21; x++){ + const TilePos pos = maps.to_world(MAP_ROUTE_202, {x, y}); + if (maps.world().standable(pos)){ + area.push_back(pos); + } + } + } + return area; +} + std::vector story_after_training_area(){ - const TilePos catch_spot = story_maps().to_world(MAP_ROUTE_202, Route202::CATCH_SPOT); + const MapSet& maps = story_maps(); + const TilePos catch_spot = maps.to_world(MAP_ROUTE_202, Route202::CATCH_SPOT); std::vector area; - for (int y = catch_spot.y - 2; y <= catch_spot.y; y++){ + for (int y = catch_spot.y - 2; y <= catch_spot.y + 2; y++){ for (int x = catch_spot.x - 1; x <= catch_spot.x + 1; x++){ - area.push_back({x, y}); + // The rows below the catch spot are trees in BDSP. + if (maps.world().standable({x, y})){ + area.push_back({x, y}); + } } } return area; diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.h index 38dc9de4e3..3e27b3dc7a 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.h @@ -31,8 +31,8 @@ const Pokemon::MapSet& story_maps(); // Jubilife City on its own: 00.05 starts there after Dawn's scene, so it is // not joined to Route 202. const Pokemon::MapSet& jubilife_maps(); -// Route 203 on its own (01.06), and whether a tile is on row 17 between the -// two stairs: row 17 runs straight west from there over the west stairs +// Route 203 on its own (01.06), and whether a tile is on row 18 between the +// two cliffs: row 18 runs straight west from there under the west cliff // into Jubilife, so the plan ends there (no leg may leave the map) and a // walk west until Jubilife's banner shows goes on from there. const Pokemon::MapSet& route203_maps(); @@ -79,6 +79,13 @@ bool story_at_jubilife_exit(const Pokemon::TilePos& world); // ledge (00.04 saves there once it has Potions, before Route 202's trainers). std::vector story_save_spots(); +// Where 00.04b's save after the catch may stand, in world tiles: wherever +// the catch's walks in the grass ended, the patch (15..20, 25..27) and the +// lawn column east of it, (21, 25..29), down to the pocket behind the tree +// row where r252's catch ended and saved (the save loads there: (21, 29) +// by the screen, the 202 sign 3 columns right and 4 rows up). +std::vector story_catch_save_area(); + // Where a walk out of the door `door` of `map` may leave us, in world tiles: // the tile below it and its neighbours either side, since the door opening // is not lined up with one tile (Jubilife's Center, r85). @@ -86,8 +93,8 @@ std::vector story_door_front(const char* map, const Pokemon::T // Where we may stand after training in the catch grass, in world tiles: the // training walks up and down the catch spot's column, between the tree walls -// north and south of the grass, so a battle may stop us on any of its three -// rows. A column either side allows for where the catch left us. +// north and south of the grass, so a battle may stop us on any of its +// three rows. A column either side allows for where the catch left us. std::vector story_after_training_area(); // Route 202's trainers, in world tiles of story_maps(). diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.cpp index ad16d52eef..b7d0f60bb6 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_TwinleafTown.h" namespace PokemonAutomation{ @@ -51,42 +52,7 @@ using namespace Pokemon; // No trainers. Platinum decodes the same terrain and objects; its one extra, // an arrow signpost at world (109, 856), stands in Route 201's cell. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(############........############)", // 0 - R"(#######....#........#....#######)", // 1 - R"(#######....#........#....#######)", // 2 - R"(############........############)", // 3 - R"(######....................######)", // 4 - R"(######......N.............######)", // 5 - R"(######....................######)", // 6 - R"(######..#####.............######)", // 7 - R"(######..#####......####...######)", // 8 - R"(######..#####......####...######)", // 9 - R"(######..######.....####...######)", // 10 - R"(######..#D###S.....#D##...######)", // 11 - R"(######....................######)", // 12 - R"(######....................######)", // 13 - R"(######..........S.........######)", // 14 - R"(######....................######)", // 15 - R"(######....................######)", // 16 - R"(######.............#####..######)", // 17 - R"(######...####......#####..######)", // 18 - R"(######...####......#####..######)", // 19 - R"(######...####.....######..######)", // 20 - R"(######...#D##.....S#D###..######)", // 21 - R"(######....................######)", // 22 - R"(######....................######)", // 23 - R"(######....................######)", // 24 - R"(######......N.............######)", // 25 - R"(######....................######)", // 26 - R"(######......########......######)", // 27 - R"(################################)", // 28 - R"(################################)", // 29 - R"(################################)", // 30 - R"(################################)", // 31 - }); - return grid; + return story_grid("TwinleafTown"); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp index 5d995cf9ea..a696281964 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp @@ -4,6 +4,7 @@ * */ +#include "PokemonBDSP_AutoStory_MapGrids.h" #include "PokemonBDSP_AutoStory_VerityLakefront.h" namespace PokemonAutomation{ @@ -46,42 +47,7 @@ using namespace Pokemon; // Platinum decodes the same terrain; it has no Barry object here and calls // the sign a trainer-tips signpost. const TileGrid& grid(){ - static const TileGrid grid({ - // 0 1 2 3 - R"(....############################)", // 0 - R"(....############################)", // 1 - R"(....############################)", // 2 - R"(....############################)", // 3 - R"(################################)", // 4 - R"(################################)", // 5 - R"(################################)", // 6 - R"(################################)", // 7 - R"(################################)", // 8 - R"(################################)", // 9 - R"(################################)", // 10 - R"(################..##############)", // 11 - R"(################..##############)", // 12 - R"(################..##############)", // 13 - R"(##############.S....#...........)", // 14 - R"(##############......#.....####..)", // 15 - R"(##############......#.....####..)", // 16 - R"(##############......#...........)", // 17 - R"(##############......#...........)", // 18 - R"(##############......#vvvvv##vvvv)", // 19 - R"(################..........##....)", // 20 - R"(################................)", // 21 - R"(##################..............)", // 22 - R"(##################..............)", // 23 - R"(################################)", // 24 - R"(################################)", // 25 - R"(################################)", // 26 - R"(################################)", // 27 - R"(################################)", // 28 - R"(################################)", // 29 - R"(################################)", // 30 - R"(################################)", // 31 - }); - return grid; + return story_grid("VerityLakefront"); } } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/FloaromaTown.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/FloaromaTown.json new file mode 100644 index 0000000000..733c172f5c --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/FloaromaTown.json @@ -0,0 +1,92 @@ +{ + "name": "FloaromaTown", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_FloaromaTown.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "######........................##", + "##..##........................##", + "..............................##", + "..............................##", + "..............................##", + "..............................##", + "..............................##", + "..................#####.......##", + "..................#####.......##", + "..................#####.......##", + "..................#####.......##", + "..........####...S##.##.......##", + "..........####................##", + "..........####................##", + "..........#D##................##", + ".......................####..S##", + ".......................####...##", + ".......................#D##...##", + "..............................##", + ".............S..................", + "................................", + "................................", + "................................", + "..............#####....####...##", + "..............#####....####...##", + "..............#####....####...##", + "..............##D##....#D##...##", + "..............................##", + "..............................##", + "..............................##", + "########.#...###################", + "########.#...###################" + ], + "objects": [ + { + "name": "npc_2_1", + "kind": "npc", + "x": 2, + "y": 1 + }, + { + "name": "npc_3_1", + "kind": "npc", + "x": 3, + "y": 1 + }, + { + "name": "npc_6_10", + "kind": "npc", + "x": 6, + "y": 10 + }, + { + "name": "npc_23_11", + "kind": "npc", + "x": 23, + "y": 11 + }, + { + "name": "npc_19_21", + "kind": "npc", + "x": 19, + "y": 21 + }, + { + "name": "npc_2_23", + "kind": "npc", + "x": 2, + "y": 23 + }, + { + "name": "npc_3_23", + "kind": "npc", + "x": 3, + "y": 23 + }, + { + "name": "npc_11_26", + "kind": "npc", + "x": 11, + "y": 26 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/JubilifeCity.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/JubilifeCity.json new file mode 100644 index 0000000000..7c7c5574c0 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/JubilifeCity.json @@ -0,0 +1,136 @@ +{ + "name": "JubilifeCity", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_JubilifeCity.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "##########################################..............########", + "##########################################..............########", + "############################################.....###############", + "############################################......##############", + "############################################......##############", + "############################################......##############", + "############################################......##############", + "#############################################....###############", + "############################....#########.......S.##############", + "############################....#########.........##############", + "#########..#########..######....#########.........##############", + "#########..#########..######....#########.........##############", + "#########..#########..######....#########.........##############", + "#########..#########..######....#########.........##############", + "#########..#########..######....#########.........##############", + "#########..##D###D##..######....####D####.........##############", + "#########.............######...............#.....#######....####", + "#########.............######......................######....####", + "..#######.............######......................######....####", + "..###########S......########...........S.........S##D###....####", + "..#.S.#.......................#..........................#.S####", + "................................................................", + "D...............................................................", + "D...............................................................", + "................................................................", + "..#...#.......................#..........................#..####", + "..############.............####......####...................####", + "..############.............####......####................#######", + "##############.################...##.####..#.....######..#######", + "##############.################...##.####.........#####..#######", + "##############.################...................#D############", + "################################.........................#######", + "################################.........................##D####", + "################################.........................#######", + "################################.........................#######", + "###############............#####.........................#######", + "###############............#####......#####..............#######", + "###############..#########.#####.##########.......######.#######", + "###############..#########.#####.##########.......######.#######", + "###############..#########.#####.###########.....#######.#######", + "##################################..S.##D##.......##D###########", + "###############..#########.#####.........................#######", + "##############...####D####..###..........................#######", + "##############...........................................#######", + "##############.....S.....................................#######", + "##############...........................................#######", + "##############.............#########.....................#######", + "###############............#########.#####...............#######", + "###############............#########.#####...............#######", + "###############.####..####.###############...............#######", + "###############.####..####.###############...............#######", + "###############.####..####.###############...........###########", + "############D##.####..####.############D##...........###########", + "##########.................#########.......#.....#...########.##", + "##########.................#########.................########.##", + "##########............#..#.#########......S..........########.##", + "##########............#..#.#########.................########.##", + "##########.................#########.................########.##", + "###########################################.......##############", + "###########################################.......##############", + "########################################.##.......##############", + "########################################.####...################", + "########################################..........##############", + "########################################..........##############" + ], + "objects": [ + { + "name": "npc_36_16", + "kind": "npc", + "x": 36, + "y": 16 + }, + { + "name": "npc_15_18", + "kind": "npc", + "x": 15, + "y": 18 + }, + { + "name": "npc_36_25", + "kind": "npc", + "x": 36, + "y": 25 + }, + { + "name": "npc_55_33", + "kind": "npc", + "x": 55, + "y": 33 + }, + { + "name": "npc_46_35", + "kind": "npc", + "x": 46, + "y": 35 + }, + { + "name": "npc_26_42", + "kind": "npc", + "x": 26, + "y": 42 + }, + { + "name": "npc_44_44", + "kind": "npc", + "x": 44, + "y": 44 + }, + { + "name": "npc_52_46", + "kind": "npc", + "x": 52, + "y": 46 + }, + { + "name": "npc_54_46", + "kind": "npc", + "x": 54, + "y": 46 + }, + { + "name": "npc_17_55", + "kind": "npc", + "x": 17, + "y": 55 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/LakeVerity.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/LakeVerity.json new file mode 100644 index 0000000000..74cc0b162e --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/LakeVerity.json @@ -0,0 +1,62 @@ +{ + "name": "LakeVerity", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "################################", + "################################", + "################################", + "################################", + "......############....##########", + "......############....##########", + ".......###########......########", + ".......###########......########", + ".......###########~.....########", + ".......###########~~....########", + "################~~~~....########", + "################..~~....########", + "##############.~~~~~..##########", + "##############.~~~~...##########", + "############...~~~..############", + "############........############", + "##########..........############", + "##########..........############", + "############......##############", + "############......##############", + "############......##############", + "############......##############", + "##############..################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################" + ], + "objects": [ + { + "name": "npc_16_11", + "kind": "npc", + "x": 16, + "y": 11 + }, + { + "name": "npc_17_11", + "kind": "npc", + "x": 17, + "y": 11 + }, + { + "name": "npc_16_19", + "kind": "npc", + "x": 16, + "y": 19 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghCity.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghCity.json new file mode 100644 index 0000000000..2e5dfc89b8 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghCity.json @@ -0,0 +1,88 @@ +{ + "name": "OreburghCity", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghCity.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "#########################################......#################", + "#########################################...S..#################", + "#########################################......#################", + "#########################################......#################", + "#########################################...####################", + "#########################################...####################", + "#########################################....###################", + "############.#####.######.#.############.....###################", + "###########..#####..#####...############.....###################", + "#########....#####..#####...############.....###################", + "##.....########D######D######D##########.....###################", + "##..S..###..........................####........#.#...##########", + "##..................................####.....S........##########", + "#D..................................####..............##########", + "##..................................####..............####.#####", + "##..................................####..............####.#####", + "##.....###.............#######......#D##..............####.#####", + "##.....##.......####...#######...............#####....####.#####", + "#########.......####.#.#######..............######......#.######", + "#########.......####...#######..............######.....#########", + "#########.......#D####S###D###...............##D##.....#########", + "#########........................................#.....#########", + "#########........................................#.....#########", + "#########........................................#....##########", + "#########........................................#....##########", + "#########........................................#....##########", + "##########.#.#..########.........................#....##########", + "########################.######.############.....#....##########", + "########################.######.###........#.....#....##D#######", + "########################.######.###.#..#...#.....#.........#####", + "############################################.....###############", + "############################################.....###############", + "############################################.....###############", + "############################################.....###############", + "############################################.....###############", + "############################################.....###############", + "############################################.....##D############", + "###################################.########.....#...........###", + "###################################.....####.....#...........###", + "###################################.....####.....#...........###", + "###################################....#####.....#...........###", + "#####################################..#.........#...........###", + "#####################################..#..#.#....#....#.#....###", + "#####################################..#..#.#....#....#.#....###", + "###################################....#.....................###", + "###################################....#.....................###", + "###################################....#.....................###", + "###################################....#.....................###", + "###################################....#.....................###", + "###################################..###..#.#................###", + "###################################..###..#.#...#.#########.####", + "###################################..###........#.#########.####", + "###################################....#..........#####.....####", + "###################################...............#####.....####", + "#####################################.............##.........###", + "#####################################..####.#.....###.....######", + "#####################################..####.#S....###.....######", + "###########################################.......####.......###", + "############################################.....#####.......###", + "############################################.....#####.....#####", + "######################################################..#..#####", + "################################################################", + "################################################################", + "################################################################" + ], + "objects": [ + { + "name": "npc_10_16", + "kind": "npc", + "x": 10, + "y": 16 + }, + { + "name": "npc_11_25", + "kind": "npc", + "x": 11, + "y": 25 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGate.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGate.json new file mode 100644 index 0000000000..4d5c076f41 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghGate.json @@ -0,0 +1,62 @@ +{ + "name": "OreburghGate", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghGate.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "################################", + "################################", + "################################", + "################################", + "############..#......###########", + "###########..........###########", + "###########........#.###########", + "###########..###################", + "###########..###################", + "###########..###################", + "###########.####################", + "############.###################", + "###########.####################", + "###########..###################", + "###########..###################", + "###########..###################", + "###########..###################", + "###########..###################", + "############.###################", + "###########..###################", + "#####...##...##########...#.####", + "####....##...##########.....####", + "###D........................D###", + "####...#....................####", + "###########..............#.#####", + "############.......#############", + "###########..#.#...#############", + "################################", + "################################", + "################################", + "################################", + "################################" + ], + "objects": [ + { + "name": "npc_7_20", + "kind": "npc", + "x": 7, + "y": 20 + }, + { + "name": "npc_24_21", + "kind": "npc", + "x": 24, + "y": 21 + }, + { + "name": "npc_17_25", + "kind": "npc", + "x": 17, + "y": 25 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghMine.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghMine.json new file mode 100644 index 0000000000..64d1f82b96 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/OreburghMine.json @@ -0,0 +1,80 @@ +{ + "name": "OreburghMine", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_OreburghMine.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "################################", + "###############D################", + "#############.....##############", + "#############.....##############", + "#############.....##############", + "#############.....##############", + "#############.....##############", + "#############...################", + "#############...################", + "#############.....##############", + "#############..#..##############", + "###############...##############", + "#############...################", + "#############.....##############", + "###############...##############", + "########...####..............###", + "######.....##.................##", + "##.#..........................##", + "##....####################....##", + "##vvv##..................#....##", + "##....#..................#....##", + "##.##.#..................#....##", + "##..###..................###..##", + "##..###..................###..##", + "##....#..................##...##", + "##.##.#..................#....##", + "####..####################....##", + "####..####################....##", + "#####............#.#........####", + "######......................####", + "################################", + "################################" + ], + "objects": [ + { + "name": "npc_20_15", + "kind": "npc", + "x": 20, + "y": 15 + }, + { + "name": "npc_21_15", + "kind": "npc", + "x": 21, + "y": 15 + }, + { + "name": "npc_27_15", + "kind": "npc", + "x": 27, + "y": 15 + }, + { + "name": "npc_26_20", + "kind": "npc", + "x": 26, + "y": 20 + }, + { + "name": "npc_8_28", + "kind": "npc", + "x": 8, + "y": 28 + }, + { + "name": "npc_18_28", + "kind": "npc", + "x": 18, + "y": 28 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/RavagedPath.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/RavagedPath.json new file mode 100644 index 0000000000..3f366c4d02 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/RavagedPath.json @@ -0,0 +1,64 @@ +{ + "name": "RavagedPath", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_RavagedPath.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "#################################", + "..#####################.........#", + "....############................#", + "....############................#", + "....############................#", + "....############................#", + "....############................#", + "....##.#####.###................#", + "....##.#....#.##................#", + "....##.##.#...#########.........#", + "....##....#..##########.........#", + "....##.#.#.......#...############", + "....###.....######...############", + "....##############....#.......###", + "....##############....#.......###", + "..............####....##......###", + "..............####...#######D####", + "..............####...############", + "..............####...####.......#", + "..............####...####.......#", + "..............####...####.......#", + "..............####...####.......#", + "..............#####D#####.......#", + "..............###########.......#", + "..............###########.......#" + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route201.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route201.json new file mode 100644 index 0000000000..e2e53e12d1 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route201.json @@ -0,0 +1,43 @@ +{ + "name": "Route201", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route201.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "################################################################", + "################################################################", + "################################################################", + "##########################################~~~~~~~~~~~...........", + "##########################################~~~~~~~~~~~..S........", + "##########################################~~~~~~~~~~~...........", + "##########################################~~~~~~~~~~~...........", + "....####..........######..##....##..####..~~~~~~~~~##...........", + "....####..........######..##....##..####..~~~~~~~~~##...........", + "##........####............................~~~~~~~~~##vvvvv######", + "##........####............................~~~~~~~~~##.....######", + "..........................................~~~~~~~~~##.....######", + "vvvv####vvvvvvvvvvvvvvvvvvvvvvvv........S.~~~~~~~~~##.....######", + "....####............~~~~~~~~~~............................######", + "....................~~~~~~~~~~............................######", + "....................~~~~~~~~~~............................######", + "....................~~~~~~~~~~............................######", + "########.....S......##########............................######", + "########............##########............~~~~~~~~~~~~~~~~######", + "##############....############################~~~~~~~~~~~~######", + "##############....############################~~~~~~~~~~~~######", + "##############....##############################################", + "##############....##############################################", + "##############....##############################################", + "##############....##############################################" + ], + "objects": [ + { + "name": "npc_57_8", + "kind": "npc", + "x": 57, + "y": 8 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route202.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route202.json new file mode 100644 index 0000000000..362f4e0df8 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route202.json @@ -0,0 +1,62 @@ +{ + "name": "Route202", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route202.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "###########........#################", + "###########........#################", + "###########........#################", + "###########........#################", + "###~~~~~~........S..~~~~~......#####", + "###~~~~~~...........~~~~~......#####", + "####~~~~~...........~~~~~......#####", + "###~~~~~~...........~~~~~......#####", + "###~~~~~~...........~~~~~......#####", + "###~~~~~~.....########.........#####", + "#########vvvvv########vvvvvv...~~###", + "#########.....########~~~~~~~~~~~###", + "#######.......########~~~~~~~~~~~###", + "#######...........####~~~~~~~~~~~###", + "###...............####~~~~~~~~~~~###", + "###...............####~~~~~~~~~~~###", + "###............S..####~~~~~~~~~~~###", + "###...............####~~~~~~~~~~~###", + "###...............####..~~~~~~~~~###", + "###~~~~##...............~~~~~~~~~###", + "###~~~~##.................~~~~~~~###", + "###~~~~##....................~~~~###", + "###~~~~##......................#####", + "###~~~~##vvvvv########vvvvvvvvv#####", + "###~~~~##.....########.........#####", + "###~~~~~~......~~~~~~...S......#####", + "###~~~~~~......~~~~~~..........#####", + "###~~~~~~......~~~~~~..........#####", + "###~~~~~~......######..........#####", + "###~~~~~~......######..........#####", + "######################.........#####", + "#####################..........#####" + ], + "objects": [ + { + "name": "npc_26_4", + "kind": "npc", + "x": 26, + "y": 4 + }, + { + "name": "npc_7_13", + "kind": "npc", + "x": 7, + "y": 13 + }, + { + "name": "npc_22_18", + "kind": "npc", + "x": 22, + "y": 18 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route203.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route203.json new file mode 100644 index 0000000000..b646ec65c9 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route203.json @@ -0,0 +1,60 @@ +{ + "name": "Route203", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route203.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "#############################################################", + "#############################################################", + "#############################################################", + "#############################################################", + "#####..............###########..~~~~#########################", + "#####..............###########.#.~~~..~~~~~~~~~~~~~~#########", + "#####..................#######........~~~~~~~~~~~~~.....#####", + "#####..................###############~~~~~~~~~~~....S..#####", + "#####~~~~##...####.....#......########~~~~~~~~~~~.......#####", + "#####~~~~##...####.....#......########~~~~~~~~~~~.......D####", + "#####~~~~##...####..#..#..S...########~~~~~~~~~~~.......#####", + "#####~~~~##...####.....#......########~~~~~~~~~~~.......#####", + "#####~~~~##...####.....#....~~~~~~~~##~~~~~~~~~S...~~~..#####", + "#####~~~~##...####vvvvv#...~~...~.~~##~~~~~~~~~....~~~..#####", + "#####~~................#....######~~##.....~~....##~~~..#####", + "#####..................#....######~~##vvvvvvvvvvv##~~~..#####", + "#####....S.............#....~~~..~~~.............~~~~~..#####", + "...........................~~~~...~~.............~~~~~..#####", + "...........................~~.....~~.............~~~~~..#####", + "..........................~~~~.....~##..........~~~~~~..#####", + "..........................~~~~~.~~~~#########################", + "#############################################################", + "#############################################################", + "#############################################################" + ], + "objects": [ + { + "name": "npc_49_8", + "kind": "npc", + "x": 49, + "y": 8 + }, + { + "name": "npc_13_10", + "kind": "npc", + "x": 13, + "y": 10 + }, + { + "name": "npc_31_16", + "kind": "npc", + "x": 31, + "y": 16 + }, + { + "name": "npc_43_17", + "kind": "npc", + "x": 43, + "y": 17 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204North.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204North.json new file mode 100644 index 0000000000..6ec036b174 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204North.json @@ -0,0 +1,74 @@ +{ + "name": "Route204North", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "########.#...###################", + "########.#...###################", + "####.....#...########.##########", + "##########...#......#.##########", + "#####....#...#......#...........", + "#####....#~~~#......#...######..", + "#####....#~~####################", + "##########~~~.........##########", + "##........~~~~~.......##########", + "##..######.~~~~..S....##########", + "###.#....#.~~~........##########", + "##..#....#.~~.........##########", + "##########..............########", + "##########..............########", + "##########...####~~~~~~~########", + "##########vvv####~~~~~~~########", + "##########...######~~~~~########", + "##########...######~~~~~########", + "##########...######~~~~~########", + "##########...######~.~~~########", + "##########............~~########", + "##########............##########", + "##########............##########", + "##########...##.....#.##########", + "##########...##.......##########", + "##########...###################", + "##########...#######.###########", + "##########............##########", + "##########............##########", + "##########............##########", + "##########............##########", + "##########...###################" + ], + "objects": [ + { + "name": "npc_31_4", + "kind": "npc", + "x": 31, + "y": 4 + }, + { + "name": "npc_15_7", + "kind": "npc", + "x": 15, + "y": 7 + }, + { + "name": "npc_16_7", + "kind": "npc", + "x": 16, + "y": 7 + }, + { + "name": "npc_20_12", + "kind": "npc", + "x": 20, + "y": 12 + }, + { + "name": "npc_17_20", + "kind": "npc", + "x": 17, + "y": 20 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204South.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204South.json new file mode 100644 index 0000000000..752d5baf82 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/Route204South.json @@ -0,0 +1,62 @@ +{ + "name": "Route204South", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Route204South.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "################################", + "###########D###.################", + "########..S.....################", + "########........################", + "########........################", + "##########...~##################", + "##########...~##################", + "##########..~~##################", + "##########..~~##################", + "####~~~~~~~~~~##################", + "####~~~~~~~~~~##################", + "####~~~~~~~~~~##################", + "####~~~~~~~~~~############...###", + "####~~~~~~~~~~############....##", + "####~~~~~~~~~~#..###############", + "##~~~~~~~~~~~~#..###############", + "##~~~~~~~~~~~~#..###############", + "##~~~~~~~~~~~~S.################", + "##~~~~~.........################", + "##~~~~~.........#.##############", + "##~~~~~.........#.##############", + "##.#########....#.##############", + "############....#......~########", + "############....######~~########", + "############....######~~########", + "############....######~~########", + "############....######~~########", + "############....######~~########", + "###.######.#....#..~~~~~########", + "##..######.#....#...~~~~########", + "##########.#....#.......########", + "############....######..########" + ], + "objects": [ + { + "name": "npc_11_8", + "kind": "npc", + "x": 11, + "y": 8 + }, + { + "name": "npc_7_18", + "kind": "npc", + "x": 7, + "y": 18 + }, + { + "name": "npc_12_21", + "kind": "npc", + "x": 12, + "y": 21 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/SandgemTown.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/SandgemTown.json new file mode 100644 index 0000000000..b7fcdb8c29 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/SandgemTown.json @@ -0,0 +1,42 @@ +{ + "name": "SandgemTown", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "########################......####", + "########################......####", + "####################..........####", + "####################..........####", + "####################..........####", + "####################..........####", + "####################......########", + "####################......########", + "####################......########", + "####################......########", + "########D##....##D##S....S#D######", + ".....S........................####", + "..............................####", + "..............................####", + "..............................####", + "..............................####", + "######........................####", + "######........................####", + "######.........#####..........####", + "##########.....#####..........####", + "##########.....#####..........####", + "##########.....#####..........####", + "#######D##....S#D###..S.......####", + "######........................####", + "######........................####", + "######........................####", + "######....................########", + "####################......########", + "####################......########", + "####################......########", + "####################......########", + "####################......########" + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/TwinleafTown.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/TwinleafTown.json new file mode 100644 index 0000000000..92dfcf72c1 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/TwinleafTown.json @@ -0,0 +1,56 @@ +{ + "name": "TwinleafTown", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "############........############", + "#######....#........#....#######", + "#######....#........#....#######", + "############........############", + "######....................######", + "######....................######", + "######....................######", + "######..#####.............######", + "######..#####......####...######", + "######..#####......####...######", + "######..######.....####...######", + "######..#D###S.....#D##...######", + "######....................######", + "######....................######", + "######..........S.........######", + "######....................######", + "######....................######", + "######.............#####..######", + "######...####......#####..######", + "######...####......#####..######", + "######...####.....######..######", + "######...#D##.....S#D###..######", + "######....................######", + "######....................######", + "######....................######", + "######....................######", + "######....................######", + "######......########......######", + "################################", + "################################", + "################################", + "################################" + ], + "objects": [ + { + "name": "npc_12_5", + "kind": "npc", + "x": 12, + "y": 5 + }, + { + "name": "npc_12_25", + "kind": "npc", + "x": 12, + "y": 25 + } + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/VerityLakefront.json b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/VerityLakefront.json new file mode 100644 index 0000000000..d82818b601 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/VerityLakefront.json @@ -0,0 +1,42 @@ +{ + "name": "VerityLakefront", + "source": { + "decomp_file": "SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_VerityLakefront.cpp", + "revision": "ddcbdb21c1dc", + "date": "2026-11-01" + }, + "tiles": [ + "....############################", + "....############################", + "....############################", + "....############################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################..##############", + "################..##############", + "################..##############", + "##############.S....#...........", + "##############......#.....####..", + "##############......#.....####..", + "##############......#...........", + "##############......#...........", + "##############......#vvvvv##vvvv", + "################..........##....", + "################................", + "##################..............", + "##################..............", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################", + "################################" + ] +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.cpp new file mode 100644 index 0000000000..2e9f7aa7f4 --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.cpp @@ -0,0 +1,256 @@ +/* BDSP AutoStory Map Grid Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "Pokemon/Navigation/Pokemon_MapSet.h" +#include "Pokemon/Navigation/Pokemon_TileGrid.h" +#include "Data/PokemonBDSP_AutoStory_MapGrids.h" +#include "Data/PokemonBDSP_AutoStory_Route202.h" +#include "Data/PokemonBDSP_AutoStory_SandgemTown.h" +#include "Data/PokemonBDSP_AutoStory_StoryMaps.h" +#include "Utils/PokemonBDSP_AutoStory_RouteWalk.h" +#include "PokemonBDSP_AutoStory_MapGrid_Tests.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + +namespace{ + +using Pokemon::Direction; +using Pokemon::MapSet; +using Pokemon::TileGrid; +using Pokemon::TilePos; +using Pokemon::TileType; + +// 00.04's training walks up and down the catch patch, three grass rows +// between tree rows, and needs the walk there to end in its grass: r253 +// and r254 loaded the catch's save in the pocket behind the trees at +// (21, 29), planned from the catch spot instead, and walked up and down +// the lawn east of the grass for three minutes without a battle. +class Test_Route202CatchGrass : public UnitTest{ +public: + Test_Route202CatchGrass() + : UnitTest("PokemonBDSP::AutoStory - Route 202: the catch patch and the walk to it") + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const TileGrid& route = Route202::grid(); + for (int x = 15; x <= 20; x++){ + const Pokemon::WallHit up = Pokemon::walk_to_wall(route, {x, 27}, Direction::NORTH); + const Pokemon::WallHit down = Pokemon::walk_to_wall(route, {x, 25}, Direction::SOUTH); + if (!(up.stop == TilePos{x, 25}) || !(down.stop == TilePos{x, 27})){ + return "Catch patch column " + std::to_string(x) + ": north from row 27 stops at " + + Pokemon::to_string(up.stop) + ", south from row 25 at " + Pokemon::to_string(down.stop) + + "; expected rows 25 and 27, between tree rows."; + } + } + const MapSet& maps = story_maps(); + const std::vector area = story_after_training_area(); + const auto in_grass = [&](const TilePos& pos){ + return maps.world().at(pos) == TileType::TALL_GRASS && std::find(area.begin(), area.end(), pos) != area.end(); + }; + // As walk_route() plans: the route costs, else the default costs. + // From the whole area the catch's save may stand in, and from the + // pocket behind the trees alone, where r252 saved. + const TilePos pocket = maps.to_world(MAP_ROUTE_202, {21, 29}); + const std::vector>> starts{ + {"the catch's save area", story_catch_save_area()}, + {"the pocket behind the trees", {pocket}}, + }; + std::optional> legs; + for (const auto& [name, from] : starts){ + legs = Pokemon::plan_robust_route(maps.world(), from, in_grass, route_plan_costs()); + if (!legs){ + legs = Pokemon::plan_robust_route(maps.world(), from, in_grass, Pokemon::RobustPlanCosts()); + } + if (!legs || legs->empty()){ + return "From " + name + " to the catch grass: no plan."; + } + for (const TilePos& pos : legs->back().after){ + if (!in_grass(pos)){ + return "From " + name + " to the catch grass: the walk may end on " + maps.describe(pos) + ", not in the grass."; + } + } + logger.log("From " + name + " to the catch grass: " + std::to_string(legs->size()) + " legs, ending in the grass."); + } + return true; + } +}; + +// 00.04's way to Sandgem's Pokemon Center ends below the Center's sign, +// walking north into it, then taps west along the doors' row to below the +// door: the row must be open there, the door straight north of where the +// taps end, and nothing else (a sign, the Mart's door) on the way. +class Test_SandgemCenterApproach : public UnitTest{ +public: + Test_SandgemCenterApproach() + : UnitTest("PokemonBDSP::AutoStory - Sandgem Town: below the Center's sign to below its door") + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const TileGrid& town = SandgemTown::grid(); + const TilePos sign = SandgemTown::POKEMON_CENTER_SIGN; + const TilePos door = SandgemTown::POKEMON_CENTER_DOOR; + if (town.at(sign) != TileType::SIGN || town.at(door) != TileType::DOOR || door.y != sign.y || door.x >= sign.x){ + return "The Center's sign " + Pokemon::to_string(sign) + " and door " + Pokemon::to_string(door) + + " are not a sign and a door west of it on one row."; + } + TilePos pos = sign.next(Direction::SOUTH); + for (int tap = 0; tap < sign.x - door.x; tap++){ + const std::optional next = town.step(pos, Direction::WEST); + if (!next){ + return "West from " + Pokemon::to_string(pos) + " is blocked."; + } + if (town.at(next->next(Direction::NORTH)) != TileType::BLOCKED && *next != door.next(Direction::SOUTH)){ + return "Above " + Pokemon::to_string(*next) + " is not the Center's wall."; + } + pos = *next; + } + if (!(pos == door.next(Direction::SOUTH))){ + return "The taps end at " + Pokemon::to_string(pos) + ", not below the door " + Pokemon::to_string(door) + "."; + } + logger.log("Sandgem: below the sign " + Pokemon::to_string(sign.next(Direction::SOUTH)) + ", " + + std::to_string(sign.x - door.x) + " taps west to below the door " + Pokemon::to_string(door) + "."); + return true; + } +}; + +// After training, 00.04 walks from wherever the training left us into +// Sandgem, to where the road stops above the Mart, with the default costs +// (heal_at_sandgem_center()): from the whole area and from each of its +// tiles alone, a plan must exist and end there. +class Test_TrainingToSandgem : public UnitTest{ +public: + Test_TrainingToSandgem() + : UnitTest("PokemonBDSP::AutoStory - Route 202: from every tile of the training area into Sandgem") + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + const MapSet& maps = story_maps(); + const TilePos entry = maps.to_world(MAP_SANDGEM_TOWN, SandgemTown::ROUTE_202_ENTRY_STOP); + const std::vector area = story_after_training_area(); + std::vector> starts{area}; + for (const TilePos& pos : area){ + starts.push_back({pos}); + } + for (const std::vector& from : starts){ + const auto legs = Pokemon::plan_robust_route(maps.world(), from, + [&](const TilePos& pos){ return pos == entry; }, Pokemon::RobustPlanCosts()); + const std::string name = from.size() == 1 ? maps.describe(from[0]) : "the whole training area"; + if (!legs || legs->empty()){ + return "From " + name + " into Sandgem: no plan."; + } + if (legs->back().after.size() != 1 || !(legs->back().after[0] == entry)){ + return "From " + name + " into Sandgem: the plan does not end on " + maps.describe(entry) + "."; + } + logger.log("From " + name + " into Sandgem: " + std::to_string(legs->size()) + " legs."); + } + return true; + } +}; + +// The maps (the JSON files built in, bdsp_map_json()) all parse through +// the shared loader into tile grids, each named as its file. +class Test_BuiltInMaps : public UnitTest{ +public: + Test_BuiltInMaps() + : UnitTest("PokemonBDSP::AutoStory - Map grids: the built-in JSON maps load") + {} + virtual UnitTestResult run(Logger& logger, CancellableScope&) const override{ + if (bdsp_map_json().empty()){ + return std::string("No built-in maps."); + } + for (const auto& [name, json] : bdsp_map_json()){ + try{ + const TileGrid& grid = story_grid(name); + logger.log(std::format("{}: {} x {}", name, grid.width(), grid.height())); + }catch (Exception& e){ + return std::format("{}: {}: {}", name, e.name(), e.message()); + } + } + return true; + } +}; + +// The JSON glyphs as BDSP tiles: every BDSP tile and a person standing; +// water and a wanderer have none. +struct GlyphCase{ + std::string name; + std::string json; + // The grid's rows, or empty when reading it must throw. + std::vector rows; +}; + +class Test_MapGlyphs : public UnitTest{ +public: + Test_MapGlyphs() + : UnitTest("PokemonBDSP::AutoStory - Map grids: JSON glyphs as tile grids") + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const std::vector cases{ + { + .name = "every BDSP tile, and a person standing", + .json = R"({"name": "T", "source": {"decomp_file": "f", "revision": "r", "date": "d"}, + "tiles": ["#.~", "vDS"], + "objects": [{"name": "npc_1_0", "kind": "npc", "x": 1, "y": 0}]})", + .rows = {"#N\"", "vDS"}, + }, + { + .name = "water has no BDSP tile", + .json = R"({"name": "T", "source": {"decomp_file": "f", "revision": "r", "date": "d"}, "tiles": ["#w"]})", + .rows = {}, + }, + { + .name = "a wanderer has no BDSP tile", + .json = R"({"name": "T", "source": {"decomp_file": "f", "revision": "r", "date": "d"}, "tiles": ["#.."], + "objects": [{"name": "lass", "kind": "npc", "x": 1, "y": 0, "wander": {"x0": 1, "y0": 0, "x1": 2, "y1": 0}}]})", + .rows = {}, + }, + }; + for (const GlyphCase& item : cases){ + std::optional grid; + std::string error; + try{ + grid = tile_grid_from_map(Pokemon::parse_map(parse_json(item.json), item.name)); + }catch (ParseException& e){ + error = e.message(); + } + if (item.rows.empty() != !grid){ + return item.name + (grid ? ": read a grid, expected a ParseException." : ": expected a grid, read: " + error); + } + if (grid){ + if (const std::optional difference = grid_difference(*grid, TileGrid(item.rows))){ + return item.name + ": differs from the expected rows at " + *difference + "."; + } + } + } + return true; + } +}; + +} + + +void add_tests_AutoStory_MapGrids(UnitTestDatabase& database){ + database.add(); + database.add(); + database.add(); + database.add(); + database.add(); +} + + +} +} +} diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h new file mode 100644 index 0000000000..a7f7250b2b --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.h @@ -0,0 +1,28 @@ +/* BDSP AutoStory Map Grid Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_MapGrid_Tests_H +#define PokemonAutomation_PokemonBDSP_AutoStory_MapGrid_Tests_H + +#include "Common/Cpp/TestRunners/UnitTest.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + + + +// Offline checks of the decomp grids against what the console showed: +// Route 202's catch patch between tree rows and the walks in and out of +// it, and Sandgem's Pokemon Center door, its sign and the row below them. +void add_tests_AutoStory_MapGrids(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.cpp index f2d65f0141..9c117daa5a 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Tests.cpp @@ -110,9 +110,9 @@ class Test_TileGridParse : public UnitTest{ int height; }; const Map maps[] = { - {MAP_ROUTE_201, Route201::grid(), 64, 20}, - {MAP_SANDGEM_TOWN, SandgemTown::grid(), 34, 28}, - {MAP_ROUTE_202, Route202::grid(), 36, 26}, + {MAP_ROUTE_201, Route201::grid(), 64, 25}, + {MAP_SANDGEM_TOWN, SandgemTown::grid(), 34, 32}, + {MAP_ROUTE_202, Route202::grid(), 36, 32}, }; for (const Map& map : maps){ if (map.grid.width() != map.width || map.grid.height() != map.height){ @@ -133,10 +133,9 @@ class Test_TileGridParse : public UnitTest{ {MAP_SANDGEM_TOWN, SandgemTown::FRONT_ROW_EAST_END, TileType::WALKABLE}, {MAP_ROUTE_202, Route202::CATCH_SPOT, TileType::TALL_GRASS}, {MAP_ROUTE_202, Route202::SAVE_SPOT, TileType::WALKABLE}, - {MAP_ROUTE_202, Route202::TRAINER_A, TileType::NPC}, - {MAP_ROUTE_202, Route202::TRAINER_B, TileType::NPC}, - {MAP_ROUTE_202, Route202::TRAINER_C, TileType::NPC}, - {MAP_ROUTE_202, Route202::TRAINER_D, TileType::NPC}, + {MAP_ROUTE_202, Route202::TRAINER_TRISTAN, TileType::NPC}, + {MAP_ROUTE_202, Route202::TRAINER_NATALIE, TileType::NPC}, + {MAP_ROUTE_202, Route202::TRAINER_LOGAN, TileType::NPC}, {MAP_ROUTE_202, Route202::EXIT_JUBILIFE, TileType::WALKABLE}, }; const Pokemon::MapSet& world = story_maps(); @@ -166,7 +165,7 @@ class Test_TileGridParse : public UnitTest{ } } - // The maps join where their exits meet. + // The maps join where their exits meet: the grids are the game's cells. struct Join{ const char* from_map; TilePos from; @@ -175,10 +174,10 @@ class Test_TileGridParse : public UnitTest{ TilePos to; }; const Join joins[] = { - {MAP_ROUTE_201, {63, 4}, Direction::EAST, MAP_SANDGEM_TOWN, {0, 7}}, - {MAP_ROUTE_201, {63, 6}, Direction::EAST, MAP_SANDGEM_TOWN, {0, 9}}, - {MAP_SANDGEM_TOWN, {24, 0}, Direction::NORTH, MAP_ROUTE_202, {25, 25}}, - {MAP_SANDGEM_TOWN, {29, 0}, Direction::NORTH, MAP_ROUTE_202, {30, 25}}, + {MAP_ROUTE_201, {63, 4}, Direction::EAST, MAP_SANDGEM_TOWN, {0, 11}}, + {MAP_ROUTE_201, {63, 6}, Direction::EAST, MAP_SANDGEM_TOWN, {0, 13}}, + {MAP_SANDGEM_TOWN, {24, 0}, Direction::NORTH, MAP_ROUTE_202, {25, 31}}, + {MAP_SANDGEM_TOWN, {29, 0}, Direction::NORTH, MAP_ROUTE_202, {30, 31}}, }; for (const Join& join : joins){ const TilePos from = world.to_world(join.from_map, join.from); @@ -224,22 +223,21 @@ class Test_TileGridWallHit : public UnitTest{ {small, {4, 3}, Direction::EAST, {5, 3}, 1, true}, {small, {4, 4}, Direction::EAST, {4, 4}, 0, false}, // into the door {small, {2, 0}, Direction::EAST, {2, 0}, 0, false}, // off the map - {route, Route202::CATCH_SPOT, Direction::WEST, {3, 22}, 16, true}, - {route, Route202::CATCH_SPOT, Direction::NORTH, {19, 20}, 2, true}, - {route, Route202::CATCH_SPOT, Direction::EAST, {30, 22}, 11, true}, + {route, Route202::CATCH_SPOT, Direction::WEST, {3, 27}, 16, true}, + {route, Route202::CATCH_SPOT, Direction::NORTH, {19, 25}, 2, true}, + {route, Route202::CATCH_SPOT, Direction::EAST, {30, 27}, 11, true}, // Measured on the console from the post-catch save. - {route, {30, 22}, Direction::NORTH, {30, 19}, 3, true}, - {route, {30, 19}, Direction::WEST, {22, 19}, 8, true}, - {route, {22, 19}, Direction::SOUTH, {22, 24}, 5, true}, - {route, {7, 12}, Direction::NORTH, {7, 12}, 0, true}, // trainer_a holds the player - // After trainer_d, as measured in r75: the east wall is at column 31 - // on row 16, and column 30 is open up to the trees above row 4. - {route, {22, 16}, Direction::EAST, {30, 16}, 8, true}, - {route, {30, 16}, Direction::NORTH, {30, 4}, 12, true}, + {route, {30, 27}, Direction::NORTH, {30, 24}, 3, true}, + {route, {30, 24}, Direction::WEST, {22, 24}, 8, true}, + {route, Route202::TRAINER_TRISTAN.next(Direction::SOUTH), Direction::NORTH, {7, 14}, 0, true}, // Tristan holds the player + // After Natalie, as measured in r75: on the row right above the south + // ledge the east wall is at column 31; column 30 is open up to row 4. + {route, {22, 22}, Direction::EAST, {30, 22}, 8, true}, + {route, {30, 22}, Direction::NORTH, {30, 4}, 18, true}, // Through the gap east of the north ledge, over the south ledge // and off the bottom edge to Sandgem Town. - {route, {29, 4}, Direction::SOUTH, {29, 25}, 21, false}, - {route, {12, 8}, Direction::SOUTH, {12, 22}, 14, true}, // hops both ledges + {route, {29, 4}, Direction::SOUTH, {29, 31}, 27, false}, + {route, {12, 8}, Direction::SOUTH, {12, 29}, 21, true}, // hops both ledges {route, Route202::EXIT_JUBILIFE, Direction::NORTH, Route202::EXIT_JUBILIFE, 0, false}, }; auto check = [](const Case& c) -> std::string{ @@ -267,6 +265,7 @@ class Test_TileGridWallHit : public UnitTest{ const TilePos below_mart = town(SandgemTown::POKE_MART_DOOR.next(Direction::SOUTH)); const TilePos row_end = town(SandgemTown::FRONT_ROW_EAST_END); const Case sandgem[] = { + {world, maps.to_world(MAP_ROUTE_202, {22, 24}), Direction::SOUTH, maps.to_world(MAP_ROUTE_202, {22, 31}), 7, true}, // under the ledge, down to Sandgem's trees (a timed count said 5) {world, town(SandgemTown::POKEMON_CENTER_DOOR.next(Direction::SOUTH)), Direction::EAST, row_end, 12, true}, {world, below_mart, Direction::EAST, row_end, 2, true}, {world, below_mart, Direction::NORTH, below_mart, 0, false}, @@ -515,9 +514,10 @@ class Test_TileGridPlans : public UnitTest{ // the costs the program plans it with: walk_route()'s route costs // for 00.04's walks, the Sandgem Center events' default costs for // walk() and town costs for walk_in_town(). The planner gives up - // after costs.max_searched sets, and the costs decide how many a - // walk needs: after training to the Center the route costs find a - // plan within 17000 sets, the default costs none within the cap. + // after costs.max_searched sets, and the costs decide whether a + // walk gets a plan: after training, 00.04 walks to Sandgem's entry + // with the default costs (the route costs find none within the cap), + // then to the Center with the town costs, checked leg by leg below. const struct{ const char* name; std::vector from; @@ -527,8 +527,8 @@ class Test_TileGridPlans : public UnitTest{ } walks[] = { {"Save spots to the catch grass", story_save_spots(), [&](const TilePos& pos){ return std::find(grass.begin(), grass.end(), pos) != grass.end(); }, false, route_plan_costs()}, - {"After training to the Pokemon Center", story_after_training_area(), - [&](const TilePos& pos){ return pos == below_sign; }, false, route_plan_costs()}, + {"After training to Sandgem's entry", story_after_training_area(), + [&](const TilePos& pos){ return pos == sandgem_entry_stop(); }, false, Pokemon::RobustPlanCosts()}, // The Mart's door takes a tile either side: enter_lit_door() lines up by sight. {"Pokemon Center to the Poke Mart", story_door_front(MAP_SANDGEM_TOWN, SandgemTown::POKEMON_CENTER_DOOR), [&](const TilePos& pos){ return pos.y == below_mart.y && std::abs(pos.x - below_mart.x) <= 1; }, true, route_plan_costs()}, @@ -546,30 +546,31 @@ class Test_TileGridPlans : public UnitTest{ {"Sandgem's entry to the Pokemon Center", {sandgem_entry_stop()}, [&](const TilePos& pos){ return pos == below_sign; }, true, town_plan_costs()}, // The Mart lady test checkpoint: out of the Center to the tile west - // of Route 201's border sign, from the lady back to it, and back. - // Those to the sign end with a leg south to the trees in the grass - // west of the sign, which cannot be read; reading the sign after it says - // where we are, and a tile short is walked east to it. + // of Route 201's border sign, from the lady back to it, and back. The + // sign's row has no wall west of it: a step onto it, then east to it. + // These legs are walked by hand (walk_until_stopped), so the plan is + // only a check of the grid; the one-tile steps need the town costs, + // the default costs find no plan. {"Pokemon Center to west of the Route 201 sign", story_door_front(MAP_SANDGEM_TOWN, SandgemTown::POKEMON_CENTER_DOOR), - [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, Pokemon::RobustPlanCosts()}, + [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, town_plan_costs()}, {"Poke Mart lady to west of the Route 201 sign", {maps.to_world(MAP_ROUTE_201, Route201::POTION_GIVER_TALK_FROM)}, - [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, Pokemon::RobustPlanCosts()}, + [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, town_plan_costs()}, {"Route 201 sign to the Pokemon Center", {route201_sign_west()}, [&](const TilePos& pos){ return pos == below_sign; }, true, Pokemon::RobustPlanCosts()}, // The Center walk's re-anchor at the trees east of the Mart. {"Trees east of the Mart to the Pokemon Center", {maps.to_world(MAP_SANDGEM_TOWN, SandgemTown::FRONT_ROW_EAST_END)}, [&](const TilePos& pos){ return pos == below_sign; }, true, Pokemon::RobustPlanCosts()}, // From and back to where the Route 202 checkpoint ends: the doors' - // row by the signs' gap. - {"Below the Center's sign to west of the Route 201 sign", {below_sandgem_center_sign()}, - [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, Pokemon::RobustPlanCosts()}, + // row by the signs' gap; westward it first walks to the Lab's sign. + {"East of the Lab's sign to west of the Route 201 sign", {east_of_lab_sign()}, + [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, town_plan_costs()}, {"Below the Center's sign to the trees east of the Mart", {below_sandgem_center_sign()}, [&](const TilePos& pos){ return pos == row_end; }, true, Pokemon::RobustPlanCosts()}, {"East of the Lab's sign to the trees east of the Mart", {east_of_lab_sign()}, [&](const TilePos& pos){ return pos == row_end; }, true, Pokemon::RobustPlanCosts()}, // Its re-anchor after a wild battle in the lady's grass. {"East end of the lady's row to the Route 201 sign", {route201_row_3_east_end()}, - [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, Pokemon::RobustPlanCosts()}, + [&](const TilePos& pos){ return pos == route201_sign_west(); }, false, town_plan_costs()}, }; for (const auto& walk : walks){ error = check_robust_plan(logger, walk.name, maps, walk.from, walk.goal, walk.costs); @@ -592,7 +593,7 @@ class Test_TileGridPlans : public UnitTest{ // the plan is the user's (2026-10-30): west to the wall, a tile east // into the gap's column, straight south through the gap between the // signs, a tile west, then north until the Center's sign stops us - // (r134a: "south 5" went 6). Not round the town. + // (r134a: "south 5" went 6; seven rows on the game's grid). Not round the town. { const auto legs = Pokemon::plan_robust_route(maps.world(), {sandgem_entry_stop()}, [&](const TilePos& pos){ return pos == below_sign; }, town_plan_costs()); @@ -601,14 +602,14 @@ class Test_TileGridPlans : public UnitTest{ read += " [" + Pokemon::to_string(planned.leg) + "]"; } const std::vector> expected{ - {Direction::WEST, 9}, {Direction::EAST, 1}, {Direction::SOUTH, 6}, {Direction::WEST, 1}, {Direction::NORTH, 2}, + {Direction::WEST, 9}, {Direction::EAST, 1}, {Direction::SOUTH, 7}, {Direction::WEST, 1}, {Direction::NORTH, 2}, }; bool same = legs && legs->size() == expected.size(); for (size_t i = 0; same && i < expected.size(); i++){ same = (*legs)[i].leg.direction == expected[i].first && (*legs)[i].leg.tiles == expected[i].second; } if (!same){ - return "Sandgem's entry to below the Center's sign, town costs: expected west 9, east 1, south 6, west 1, north 2; planned" + + return "Sandgem's entry to below the Center's sign, town costs: expected west 9, east 1, south 7, west 1, north 2; planned" + (read.empty() ? std::string(" nothing") : read) + "."; } logger.log("Sandgem's entry to below the Center's sign, town costs:" + read); @@ -641,7 +642,7 @@ class Test_TileGridPlans : public UnitTest{ } // 00.05 in Jubilife: every leg the segment walks, from where the one - // before it may have left us. + // before it may have left us, with route_plan_costs() as talk_to_npc() plans. { using namespace JubilifeCity; const Pokemon::MapSet& town = jubilife_maps(); @@ -733,7 +734,7 @@ class Test_TileGridPlans : public UnitTest{ // Oreburgh Gate's west exit to its road near Jubilife, and from // Jubilife's east stairs to the foot of its north road. { - std::string leg_error = check_robust_plan(logger, "Route 203: Oreburgh Gate to row 17", route203_maps(), + std::string leg_error = check_robust_plan(logger, "Route 203: Oreburgh Gate to row 18", route203_maps(), Route203::gate_exit(), on_route203_west_line); failed += leg_error.empty() ? "" : leg_error + " "; leg_error = check_robust_plan(logger, "Jubilife: east stairs to the north road", jubilife_east_maps(), diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.cpp index 69995643c1..b3974652cd 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.cpp @@ -65,7 +65,7 @@ using Pokemon::pose_known; const char* const ROUTE202_TO_SANDGEM_CENTER_NAME = "Route 202 to Sandgem's Pokemon Center (events)"; TilePos sandgem_entry_stop(){ - return story_maps().to_world(MAP_SANDGEM_TOWN, {29, 2}); + return story_maps().to_world(MAP_SANDGEM_TOWN, SandgemTown::ROUTE_202_ENTRY_STOP); } TilePos below_sandgem_center_sign(){ @@ -73,7 +73,7 @@ TilePos below_sandgem_center_sign(){ } TilePos east_of_lab_sign(){ - return story_maps().to_world(MAP_SANDGEM_TOWN, {6, 7}); + return story_maps().to_world(MAP_SANDGEM_TOWN, {6, 11}); } bool sign_text_matches(const std::string& text, const std::string& key){ diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.h index 6108408750..00d4eb0658 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.h +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_SandgemCenterEvents.h @@ -95,7 +95,9 @@ class SandgemCenterActions{ // Where the walk south stops in Sandgem Town, in world tiles of // story_maps(): Route 202's column 30 runs into Sandgem's column 29, and -// walking south from Route 202 stops at (29,2), above the Poke Mart. +// walking south from Route 202 stops at (29,5), above the Poke Mart, where +// the road narrows (the console counted it as two rows above the signs' row +// on the image grid; the decomp has three, with (29,6) a wall). Pokemon::TilePos sandgem_entry_stop(); // Below the Center's sign, three tiles east of its door: where 00.04's 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 2103422258..30b19917dd 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 @@ -693,17 +693,17 @@ namespace PokemonAutomation { } } - // South into Sandgem Town, to the tile below the Pokemon Center's sign, - // which the house west of its column and the sign pin (r75 walked this - // and healed). The Center's door is three tiles west; the heal lines up - // with it by sight. Returns where we stand after: below the door. + // Into Sandgem down the road, then the town plan into the Center's sign (one walk + // found no plan, r252 ended two tiles short), and in by sight. Returns: below the door. static std::vector heal_at_sandgem_center( VideoStream& stream, ProControllerContext& context, const MapSet& maps, std::vector& trainers, const RouteTrainerFight& fight ) { + const TilePos entry = maps.to_world(MAP_SANDGEM_TOWN, SandgemTown::ROUTE_202_ENTRY_STOP); const TilePos below_sign = maps.to_world(MAP_SANDGEM_TOWN, SandgemTown::POKEMON_CENTER_SIGN.next(Pokemon::Direction::SOUTH)); - walk_route(stream, context, maps, story_after_training_area(), - [&](const TilePos& pos) { return pos == below_sign; }, trainers, fight, "To the Pokemon Center"); + walk_route(stream, context, maps, walk_route(stream, context, maps, story_after_training_area(), + [&](const TilePos& pos) { return pos == entry; }, trainers, fight, "Into Sandgem Town", {}, Pokemon::RobustPlanCosts()), + [&](const TilePos& pos) { return pos == below_sign; }, trainers, fight, "To the Pokemon Center", {}, town_plan_costs()); heal_at_pokemon_center(stream, context, "Sandgem Town Pokemon Center"); return story_door_front(MAP_SANDGEM_TOWN, SandgemTown::POKEMON_CENTER_DOOR); } diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_01.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_01.cpp index 0911d5396f..fb94058964 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_01.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StorySegments/PokemonBDSP_AutoStory_Segment_01.cpp @@ -729,7 +729,7 @@ void oreburgh_to_roark(VideoStream& stream, ProControllerContext& context){ // Back up the corridor, then north out through the hall. A route leg // north to the top's wall walks on through it into the hall (r99), and // no wall stops us a row short of it, so the route ends on the corner - // at (14,11), where that leg started, and the walk does the rest. + // at (14,10), where that leg started, and the walk does the rest. const Pokemon::TilePos exit = world(OreburghMine::CORRIDOR_EXIT_START); at = walk_route(stream, context, maps, at, [&](const Pokemon::TilePos& pos){ return pos == exit; }, @@ -1157,31 +1157,31 @@ void oreburgh_to_route203(VideoStream& stream, ProControllerContext& context){ void route203_to_jubilife(VideoStream& stream, ProControllerContext& context){ StepLog step(stream, "01.06", "From the Oreburgh Gate's west exit into Jubilife City", { - "Route 203 on its grid to row 17, below the blue-haired trainer", - "West along row 17 into Jubilife, counting tiles", + "Route 203 on its grid to row 18, below the girl", + "West along row 18 into Jubilife, counting tiles", }); step(1); - // On the grid (Data/PokemonBDSP_AutoStory_Route203, checked by hand): - // south from the Gate, west under the beaten girl to the stairs, north - // to the ledge, west to the blue-haired trainer, and a row down onto row - // 17, which runs straight to Jubilife. Trainers the map does not list + // On the grid (Data/PokemonBDSP_AutoStory_Route203, from the decomp, + // its east stretch checked by hand): south from the Gate down the sand, + // west along the sand's bottom row and on under the girl's row, which + // runs straight to Jubilife as row 18. Trainers the map does not list // are fought where they stop us. std::vector trainers; auto fight = [&](const std::string& who){ talk_or_fight(stream, context, "Route 203: " + who); }; const std::vector at = walk_route(stream, context, route203_maps(), Route203::gate_exit(), - on_route203_west_line, trainers, fight, "Route 203 to row 17"); + on_route203_west_line, trainers, fight, "Route 203 to row 18"); if (at.size() != 1){ - fail(stream, "Route 203: the walk to row 17 did not end on a known tile."); + fail(stream, "Route 203: the walk to row 18 did not end on a known tile."); } step(2); - // Row 17 has no wall before Jubilife, so count the tiles: from column - // `x` it is x + 1 taps to Jubilife's first tile (by hand from (31, 17): + // Row 18 has no wall before Jubilife, so count the tiles: from column + // `x` it is x + 1 taps to Jubilife's first tile (by hand from column 31: // 32 taps, Jubilife's banner on the last one). 01.07 starts there. - dpad_tiles(stream, context, DPAD_LEFT, (size_t)at[0].x + 1, "west along row 17 into Jubilife"); + dpad_tiles(stream, context, DPAD_LEFT, (size_t)at[0].x + 1, "west along row 18 into Jubilife"); context.wait_for_all_requests(); if (!location_banner_showing(*stream.video().snapshot().frame)){ fail(stream, "Route 203: no Jubilife banner after counting the tiles west."); @@ -1195,7 +1195,7 @@ void jubilife_to_rowan(VideoStream& stream, ProControllerContext& context){ }); step(1); - // Route 203's row 17 carries on as Jubilife's long road. From the first + // Route 203's row 18 carries on as Jubilife's long road. From the first // tile the crossroads with the street north to Route 204 is 14 tiles // west; the street is about 4 tiles wide, so a stick hold does (by hand, // 2026-10-31: 2 x 1120 ms landed mid-street; 7 D-pad taps stopped below diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Battle.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Battle.cpp index 14c1ac23bf..883fa21a6c 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Battle.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_Battle.cpp @@ -631,7 +631,8 @@ static BattlePlan build_expert_plan(Logger& logger, // Iterate through all listed trainers in sequence order. // For current_trainer, populate move_for_species. for (Trainer t : all_trainers){ - const BDSPTrainerData& tdata = bdsp_trainer(trainer_slug(t)); + const std::string slug = trainer_slug(t); + const BDSPTrainerData& tdata = bdsp_trainer(slug); bool is_current = (t == current_trainer); bool doubles = (tdata.battle_type == BDSPBattleType::DOUBLES); @@ -758,7 +759,8 @@ void handle_expert_battle(const ProgramInfo& /*info*/, using namespace Pokemon; Logger& logger = stream.logger(); - const BDSPTrainerData& trainer_data = bdsp_trainer(trainer_slug(current_trainer)); + const std::string current_slug = trainer_slug(current_trainer); + const BDSPTrainerData& trainer_data = bdsp_trainer(current_slug); const OutsideHelpConfig& help = options.outside_help; bool doubles = (trainer_data.battle_type == BDSPBattleType::DOUBLES); @@ -769,7 +771,8 @@ void handle_expert_battle(const ProgramInfo& /*info*/, } // Helper stats — 0IV/0EV at level 100, neutral nature - const BDSPPokemonData& helper_base = bdsp_pokemon("torterra"); + const std::string helper_base_slug = "torterra"; + const BDSPPokemonData& helper_base = bdsp_pokemon(helper_base_slug); int base_atk = (int)calc_stats_nonhp(helper_base.attack, 100, 0, 0, NatureAdjustment::NEUTRAL); int base_spatk = (int)calc_stats_nonhp(helper_base.spatk, 100, 0, 0, NatureAdjustment::NEUTRAL); diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index b59547da29..a3d27d04d5 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1563,6 +1563,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_TwinleafTown.h Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.cpp Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_LakeVerity.h + Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_MapGrids.cpp + 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_Route204.h @@ -1570,6 +1572,8 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_SandgemTown.h Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.cpp Source/PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_StoryMaps.h + Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_MapGrid_Tests.cpp + 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/Utils/PokemonBDSP_AutoStory_Location.cpp diff --git a/devtools/maps/bdsp_maps.py b/devtools/maps/bdsp_maps.py new file mode 100644 index 0000000000..51e8e3c2e0 --- /dev/null +++ b/devtools/maps/bdsp_maps.py @@ -0,0 +1,53 @@ +"""Checks that Packages' BDSP AutoStory maps are the ones in this repository. + +Usage: + python3 devtools/maps/bdsp_maps.py --check --json-dir Packages/Resources/PokemonBDSP/Maps + +The maps are JSON files in the shared map schema +(SerialPrograms/Source/Pokemon/Navigation/Pokemon_MapData.h). They live in +SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps, where CMake builds +them into the program (pa_embed_text_files()). Once Packages has copies in +Resources/PokemonBDSP/Maps, the two must be the same files: --check exits +1, naming the first that differs, if they are not. + +TODO: move the maps to PokemonAutomation/Packages (Resources/PokemonBDSP/Maps) when ready. +Until then the program reads only the repository's copies, and this check +is for that move. + +The files were converted once (at ddcbdb21c) from the C++ tables that +pret/pokediamond's maps had been decoded into; nothing builds them now. +""" +import argparse +import os +import sys + +REPO_MAPS = 'SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps' + + +def json_files(folder): + return sorted(name for name in os.listdir(folder) if name.endswith('.json')) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__.split('\n')[0]) + parser.add_argument('--check', action='store_true', required=True, + help='compare the repository\'s maps with --json-dir\'s, byte for byte') + parser.add_argument('--json-dir', required=True, help='Packages\' Resources/PokemonBDSP/Maps') + parser.add_argument('--repo', default='.', help='Arduino-Source checkout') + args = parser.parse_args() + repo_maps = os.path.join(args.repo, REPO_MAPS) + ours, theirs = json_files(repo_maps), json_files(args.json_dir) + if ours != theirs: + print('The map files differ: only here ' + str(sorted(set(ours) - set(theirs))) + + ', only in ' + args.json_dir + ' ' + str(sorted(set(theirs) - set(ours))) + '.') + sys.exit(1) + for name in ours: + with open(os.path.join(repo_maps, name), 'rb') as a, open(os.path.join(args.json_dir, name), 'rb') as b: + if a.read() != b.read(): + print(name + ': differs from ' + os.path.join(args.json_dir, name) + '.') + sys.exit(1) + print(str(len(ours)) + ' maps: the same files.') + + +if __name__ == '__main__': + main()