diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h new file mode 100644 index 0000000000..e63fe2d69b --- /dev/null +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h @@ -0,0 +1,281 @@ +/* BDSP AutoStory Plan Golden + * + * From: https://github.com/PokemonAutomation/ + * + * The legs the planner plans for every ROUTE of the story simulation + * (PokemonBDSP_AutoStory_StorySimulation_Tests.cpp, "plans match the + * golden"): per route a header " costs= from + * to ", then one line per leg with the tiles it may end on. + * One string per line: MSVC caps a single literal at 16 KB. + * Regenerate from the test's failure log; see test_golden_plans(). + * + */ + +#ifndef PokemonAutomation_PokemonBDSP_AutoStory_PlanGolden_H +#define PokemonAutomation_PokemonBDSP_AutoStory_PlanGolden_H + +#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonBDSP{ + +// The stored plan lines, in the order the simulation plans them. +inline constexpr std::string_view BDSP_PLAN_GOLDEN[] = { + "00.01 below_the_flute costs=default from PlayerHouse2F (4, 6) to PlayerHouse2F (7, 5)", + "00.01 north 1 (to wall) -> PlayerHouse2F (4, 5)", + "00.01 east 3 (open) -> PlayerHouse2F (7, 5)", + "00.01 onto_the_flute_tile costs=default from PlayerHouse2F (7, 5) to PlayerHouse2F (8, 4)", + "00.01 north 1 (to wall) -> PlayerHouse2F (7, 4)", + "00.01 east 1 (to wall) -> PlayerHouse2F (8, 4)", + "00.01 above_the_door costs=default from PlayerHouse1F (10, 3) (10, 4) to PlayerHouse1F (6, 9)", + "00.01 south 7 (to wall) -> PlayerHouse1F (10, 10)", + "00.01 north 1 (open) -> PlayerHouse1F (10, 9)", + "00.01 west 4 (open) -> PlayerHouse1F (6, 9)", + "00.01 short_of_barrys_door costs=default from TwinleafTown (20, 22) to TwinleafTown (10, 12)", + "00.01 west 7 (open) -> Twinleaf Town (13, 22)", + "00.01 north 10 (to wall) -> Twinleaf Town (13, 12)", + "00.01 west 3 (open) -> Twinleaf Town (10, 12)", + "00.01 back_onto_barrys_doorstep costs=default from TwinleafTown (9, 13) to TwinleafTown (9, 12)", + "00.01 north 1 (open) -> Twinleaf Town (9, 12)", + "00.01 below_barrys_stairs costs=default from RivalHouse1F (6, 9) to RivalHouse1F (2, 3)", + "00.01 west 4 (to wall) -> RivalHouse1F (2, 9)", + "00.01 north 6 (to wall) -> RivalHouse1F (2, 3)", + "00.01 above_barrys_stairs costs=default from RivalHouse2F (3, 5) to RivalHouse2F (3, 4)", + "00.01 north 1 (to wall) -> RivalHouse2F (3, 4)", + "00.01 above_barrys_door costs=default from RivalHouse1F (2, 3) to RivalHouse1F (6, 9)", + "00.01 south 6 (open) -> RivalHouse1F (2, 9)", + "00.01 east 4 (open) -> RivalHouse1F (6, 9)", + "00.01 below_barrys_warning costs=default from TwinleafTown (9, 12) to Route201 (15, 19)", + "00.01 east 6 (open) -> Twinleaf Town (15, 12)", + "00.01 north 24 (to wall) -> Route 201 (15, 13)", + "00.01 south 6 (open) -> Route 201 (15, 19)", + "00.01 away_from_barry costs=default from Route201 (15, 18) to Route201 (12, 17)", + "00.01 north 1 (open) -> Route 201 (15, 17)", + "00.01 west 3 (open) -> Route 201 (12, 17)", + "00.01 below_the_lake_entrance costs=default from Route201 (12, 17) to VerityLakefront (17, 14)", + "00.01 north 1 (open) -> Route 201 (12, 16)", + "00.01 west 26 (to wall) -> Verity Lakefront (18, 23)", + "00.01 north 9 (to wall) -> Verity Lakefront (18, 14)", + "00.01 west 1 (open) -> Verity Lakefront (17, 14)", + "00.02 to_the_lake_entrance costs=default from VerityLakefront (17, 14) to VerityLakefront (17, 13)", + "00.02 north 1 (open) -> Verity Lakefront (17, 13)", + "00.03 short_of_rowan costs=default from VerityLakefront (17, 14) (17, 15) to Route201 (4, 14)", + "00.03 south 7 (to wall) -> Verity Lakefront (17, 21)", + "00.03 east 19 (open) -> Route 201 (4, 14)", + "00.03 by_the_counter costs=default from PlayerHouse1F (5, 8) (6, 8) to PlayerHouse1F (4, 8)", + "00.03 west 2 (to wall) -> PlayerHouse1F (4, 8)", + "00.03 above_the_door_again costs=default from PlayerHouse1F (4, 8) to PlayerHouse1F (6, 9)", + "00.03 east 2 (open) -> PlayerHouse1F (6, 8)", + "00.03 south 1 (open) -> PlayerHouse1F (6, 9)", + "00.03 short_of_dawn costs=default from TwinleafTown (20, 22) to Route201 (63, 5)", + "00.03 west 3 (open) -> Twinleaf Town (17, 22)", + "00.03 north 34 (to wall) -> Route 201 (17, 13)", + "00.03 east 40 (to wall) -> Route 201 (57, 13)", + "00.03 west 7 (open) -> Route 201 (50, 13)", + "00.03 north 10 (to wall) -> Route 201 (50, 3)", + "00.03 east 13 (to wall) -> Route 201 (63, 3)", + "00.03 south 2 (open) -> Route 201 (63, 5)", + "00.04 onto_the_path costs=town from SandgemTown (26, 11) (27, 11) (28, 11) (26, 12) (27, 12) (28, 12) to SandgemTown (29, 12)", + "00.04 east 3 (to wall) -> Sandgem Town (29, 11) Sandgem Town (29, 12)", + "00.04 north 1 (to wall) -> Sandgem Town (29, 11)", + "00.04 south 1 (open) -> Sandgem Town (29, 12)", + "00.04 home costs=default from Route201 (57, 5) (58, 5) (59, 5) (60, 5) (61, 5) (62, 5) (63, 5) to TwinleafTown (20, 22) (20, 23) (20, 24) (20, 25) (20, 26)", + "00.04 west 21 (to wall) -> Route 201 (42, 5)", + "00.04 south 4 (open) -> Route 201 (42, 9)", + "00.04 west 28 (to wall) -> Route 201 (14, 9)", + "00.04 south 42 (to wall) -> Twinleaf Town (14, 26)", + "00.04 east 6 (open) -> Twinleaf Town (20, 26)", + "00.04 beside_mom costs=default from PlayerHouse1F (6, 9) to PlayerHouse1F (6, 7)", + "00.04 north 2 (open) -> PlayerHouse1F (6, 7)", + "00.04 around_mom costs=default from PlayerHouse1F (6, 7) to PlayerHouse1F (5, 9)", + "00.04 south 2 (open) -> PlayerHouse1F (6, 9)", + "00.04 west 1 (to wall) -> PlayerHouse1F (5, 9)", + "00.04 short_of_the_catch_tutorial costs=default from TwinleafTown (19, 22) to Route202 (22, 27)", + "00.04 west 2 (open) -> Twinleaf Town (17, 22)", + "00.04 north 34 (to wall) -> Route 201 (17, 13)", + "00.04 east 40 (to wall) -> Route 201 (57, 13)", + "00.04 west 7 (open) -> Route 201 (50, 13)", + "00.04 north 7 (open) -> Route 201 (50, 6)", + "00.04 east 43 (to wall) -> Sandgem Town (29, 13)", + "00.04 west 5 (open) -> Sandgem Town (24, 13)", + "00.04 north 21 (to wall) -> Route 202 (25, 24)", + "00.04 west 3 (to wall) -> Route 202 (22, 24)", + "00.04 south 3 (open) -> Route 202 (22, 27)", + "00.04b to_catch_grass costs=default from Route202 (15, 25) (16, 25) (17, 25) (18, 25) (19, 25) (20, 25) (21, 25) (15, 26) (16, 26) (17, 26) (18, 26) (19, 26) (20, 26) (21, 26) (15, 27) (16, 27) (17, 27) (18, 27) (19, 27) (20, 27) (21, 27) (21, 28) (21, 29) to Route202 (18, 25) (19, 25) (20, 25) (18, 26) (19, 26) (20, 26) (18, 27) (19, 27) (20, 27)", + "00.04b east 15 (to wall) -> Route 202 (23, 25) Route 202 (30, 26) Route 202 (30, 27) Route 202 (30, 28) Route 202 (30, 29)", + "00.04b north 5 (to wall) -> Route 202 (23, 24) Route 202 (30, 24)", + "00.04b west 8 (to wall) -> Route 202 (22, 24)", + "00.04b south 1 (open) -> Route 202 (22, 25)", + "00.04b west 2 (open) -> Route 202 (20, 25)", + "00.04b into_sandgem costs=robust from Route202 (18, 25) (19, 25) (20, 25) (18, 26) (19, 26) (20, 26) (18, 27) (19, 27) (20, 27) to SandgemTown (29, 5)", + "00.04b south 2 (to wall) -> Route 202 (18, 27) Route 202 (19, 27) Route 202 (20, 27)", + "00.04b east 12 (to wall) -> Route 202 (30, 27)", + "00.04b south 10 (to wall) -> Sandgem Town (29, 5)", + "00.04b below_center_door costs=town from SandgemTown (29, 5) to SandgemTown (17, 11)", + "00.04b west 5 (open) -> Sandgem Town (24, 5)", + "00.04b south 6 (open) -> Sandgem Town (24, 11)", + "00.04b west 7 (open) -> Sandgem Town (17, 11)", + "00.04d north_to_jubilife costs=default from Route202 (30, 24) to Route202 (11, 0) (12, 0) (13, 0) (14, 0) (15, 0) (16, 0) (17, 0) (18, 0) (11, 1) (12, 1) (13, 1) (14, 1) (15, 1) (16, 1) (17, 1) (18, 1) (11, 2) (12, 2) (13, 2) (14, 2) (15, 2) (16, 2) (17, 2) (18, 2) (11, 3) (12, 3) (13, 3) (14, 3) (15, 3) (16, 3) (17, 3) (18, 3)", + "00.04d south 2 (open) -> Route 202 (30, 26)", + "00.04d west 27 (to wall) -> Route 202 (3, 26)", + "00.04d north 12 (to wall) -> Route 202 (3, 14)", + "00.04d east 14 (to wall) -> Route 202 (17, 14)", + "00.04d south 8 (to wall) -> Route 202 (17, 22)", + "00.04d east 13 (to wall) -> Route 202 (30, 22)", + "00.04d north 18 (to wall) -> Route 202 (30, 4)", + "00.04d south 1 (open) -> Route 202 (30, 5)", + "00.04d west 12 (open) -> Route 202 (18, 5)", + "00.04d north 2 (open) -> Route 202 (18, 3)", + "00.05 to_the_center costs=town from JubilifeCity (48, 62) to JubilifeCity (52, 41)", + "00.05 west 1 (open) -> Jubilife City (47, 62)", + "00.05 north 21 (open) -> Jubilife City (47, 41)", + "00.05 east 5 (open) -> Jubilife City (52, 41)", + "00.05 to_the_school costs=town from JubilifeCity (52, 41) to JubilifeCity (40, 41)", + "00.05 west 12 (open) -> Jubilife City (40, 41)", + "00.05b below_the_presidents_trigger costs=town from JubilifeCity (40, 41) to JubilifeCity (46, 41)", + "00.05b east 6 (open) -> Jubilife City (46, 41)", + "00.05b past_the_president costs=default from JubilifeCity (46, 40) to JubilifeCity (48, 40)", + "00.05b east 2 (open) -> Jubilife City (48, 40)", + "00.05b below_the_mart_clown costs=town from JubilifeCity (48, 40) to JubilifeCity (55, 34)", + "00.05b north 6 (open) -> Jubilife City (48, 34)", + "00.05b east 7 (open) -> Jubilife City (55, 34)", + "00.05b below_the_tv_clown costs=town from JubilifeCity (55, 34) to JubilifeCity (36, 17)", + "00.05b west 23 (to wall) -> Jubilife City (32, 34)", + "00.05b north 10 (open) -> Jubilife City (32, 24)", + "00.05b east 4 (open) -> Jubilife City (36, 24)", + "00.05b north 7 (open) -> Jubilife City (36, 17)", + "00.05b below_the_company_clown costs=town from JubilifeCity (36, 17) to JubilifeCity (15, 19)", + "00.05b south 4 (open) -> Jubilife City (36, 21)", + "00.05b west 21 (open) -> Jubilife City (15, 21)", + "00.05b north 2 (open) -> Jubilife City (15, 19)", + "00.05c below_the_president costs=town from JubilifeCity (15, 19) to JubilifeCity (46, 36)", + "00.05c south 5 (open) -> Jubilife City (15, 24)", + "00.05c east 29 (open) -> Jubilife City (44, 24)", + "00.05c south 12 (open) -> Jubilife City (44, 36)", + "00.05c east 2 (open) -> Jubilife City (46, 36)", + "00.05c to_the_route_203_street costs=town from JubilifeCity (46, 36) to JubilifeCity (58, 22)", + "00.05c east 1 (open) -> Jubilife City (47, 36)", + "00.05c north 14 (open) -> Jubilife City (47, 22)", + "00.05c east 11 (open) -> Jubilife City (58, 22)", + "01.01 west_of_barrys_trigger costs=town from JubilifeCity (58, 22) to Route203 (4, 18)", + "01.01 east 9 (open) -> Route 203 (4, 18)", + "01.02 south_to_the_cliff costs=default from Route203 (5, 17) (5, 18) (5, 19) (5, 20) to Route203 (5, 20)", + "01.02 south 3 (to wall) -> Route 203 (5, 20)", + "01.02 by_the_gate costs=default from Route203 (5, 20) to Route203 (55, 9)", + "01.02 north 2 (open) -> Route 203 (5, 18)", + "01.02 east 50 (to wall) -> Route 203 (55, 18)", + "01.02 north 9 (open) -> Route 203 (55, 9)", + "01.02 west_of_the_hikers_trigger costs=default from OreburghGate (4, 22) (5, 22) to OreburghGate (6, 22)", + "01.02 south 1 (to wall) -> OreburghGate (4, 23) OreburghGate (5, 23)", + "01.02 east 2 (to wall) -> OreburghGate (6, 23)", + "01.02 north 1 (open) -> OreburghGate (6, 22)", + "01.02 past_curtis costs=default from OreburghGate (7, 22) to OreburghGate (20, 22)", + "01.02 east 13 (open) -> OreburghGate (20, 22)", + "01.02 by_the_east_mouth costs=default from OreburghGate (20, 22) to OreburghGate (27, 22)", + "01.02 east 7 (open) -> OreburghGate (27, 22)", + "01.02 west_of_the_welcome costs=default from OreburghCity (2, 13) (3, 13) to OreburghCity (9, 13)", + "01.02 north 3 (to wall) -> Oreburgh City (2, 10) Oreburgh City (3, 10)", + "01.02 east 4 (to wall) -> Oreburgh City (6, 10)", + "01.02 south 3 (open) -> Oreburgh City (6, 13)", + "01.02 east 3 (open) -> Oreburgh City (9, 13)", + "01.03 below_the_centers_door costs=town from OreburghCity (43, 21) (44, 21) (45, 21) (43, 22) (44, 22) (45, 22) to OreburghCity (47, 21)", + "01.03 east 5 (to wall) -> Oreburgh City (48, 21) Oreburgh City (48, 22)", + "01.03 north 1 (to wall) -> Oreburgh City (48, 21)", + "01.03 west 1 (open) -> Oreburgh City (47, 21)", + "01.03 above_the_mine costs=town from OreburghCity (47, 21) to OreburghCity (46, 58)", + "01.03 west 3 (open) -> Oreburgh City (44, 21)", + "01.03 south 20 (to wall) -> Oreburgh City (44, 41)", + "01.03 east 2 (open) -> Oreburgh City (46, 41)", + "01.03 south 17 (open) -> Oreburgh City (46, 58)", + "01.03 below_roark costs=default from OreburghMine (15, 9) to OreburghMine (18, 29)", + "01.03 east 2 (to wall) -> OreburghMine (17, 9)", + "01.03 south 2 (to wall) -> OreburghMine (17, 11)", + "01.03 west 2 (to wall) -> OreburghMine (15, 11)", + "01.03 south 6 (to wall) -> OreburghMine (15, 17)", + "01.03 east 14 (to wall) -> OreburghMine (29, 17)", + "01.03 south 10 (to wall) -> OreburghMine (29, 27)", + "01.03 west 3 (to wall) -> OreburghMine (26, 27)", + "01.03 south 2 (to wall) -> OreburghMine (26, 29)", + "01.03 west 8 (open) -> OreburghMine (18, 29)", + "01.03 below_the_coal_rooms_warp costs=default from OreburghMine (18, 29) to OreburghMine (15, 2)", + "01.03 east 9 (to wall) -> OreburghMine (27, 29)", + "01.03 north 5 (to wall) -> OreburghMine (27, 24)", + "01.03 east 2 (to wall) -> OreburghMine (29, 24)", + "01.03 north 8 (to wall) -> OreburghMine (29, 16)", + "01.03 west 16 (to wall) -> OreburghMine (13, 16)", + "01.03 east 2 (open) -> OreburghMine (15, 16)", + "01.03 north 5 (to wall) -> OreburghMine (15, 11)", + "01.03 east 2 (to wall) -> OreburghMine (17, 11)", + "01.03 north 2 (to wall) -> OreburghMine (17, 9)", + "01.03 west 4 (to wall) -> OreburghMine (13, 9)", + "01.03 north 7 (to wall) -> OreburghMine (13, 2)", + "01.03 east 2 (open) -> OreburghMine (15, 2)", + "01.03 below_the_centers_door_again costs=town from OreburghCity (45, 57) to OreburghCity (47, 21)", + "01.03 west 2 (to wall) -> Oreburgh City (43, 57)", + "01.03 north 16 (to wall) -> Oreburgh City (43, 41)", + "01.03 east 1 (open) -> Oreburgh City (44, 41)", + "01.03 north 21 (to wall) -> Oreburgh City (44, 20)", + "01.03 south 1 (open) -> Oreburgh City (44, 21)", + "01.03 east 3 (open) -> Oreburgh City (47, 21)", + "01.05 east_of_barrys_trigger costs=town from OreburghCity (26, 21) (26, 22) to OreburghCity (7, 13)", + "01.05 west 17 (to wall) -> Oreburgh City (9, 21) Oreburgh City (9, 22)", + "01.05 north 5 (to wall) -> Oreburgh City (9, 17)", + "01.05 east 2 (open) -> Oreburgh City (11, 17)", + "01.05 north 4 (open) -> Oreburgh City (11, 13)", + "01.05 west 4 (open) -> Oreburgh City (7, 13)", + "01.05 by_the_gate costs=default from OreburghCity (5, 13) to OreburghCity (2, 13)", + "01.05 west 3 (open) -> Oreburgh City (2, 13)", + "01.05 through_the_gate costs=default from OreburghGate (27, 22) (26, 22) to OreburghGate (4, 22)", + "01.05 south 1 (open) -> OreburghGate (26, 23) OreburghGate (27, 23)", + "01.05 west 19 (to wall) -> OreburghGate (8, 23)", + "01.05 north 1 (to wall) -> OreburghGate (8, 22)", + "01.05 west 4 (open) -> OreburghGate (4, 22)", + "01.06 below_rowans_trigger costs=town from Route203 (55, 9) to JubilifeCity (47, 8)", + "01.06 south 10 (to wall) -> Route 203 (55, 19)", + "01.06 west 17 (to wall) -> Route 203 (38, 19)", + "01.06 north 1 (open) -> Route 203 (38, 18)", + "01.06 west 57 (open) -> Jubilife City (44, 22)", + "01.06 north 14 (to wall) -> Jubilife City (44, 8)", + "01.06 east 3 (to wall) -> Jubilife City (47, 8)", + "01.08 west_to_the_wall costs=default from JubilifeCity (46, 5) (47, 5) to JubilifeCity (44, 5)", + "01.08 west 3 (to wall) -> Jubilife City (44, 5)", + "01.08 below_the_ravaged_path costs=town from JubilifeCity (44, 5) to Route204South (11, 2)", + "01.08 east 2 (open) -> Jubilife City (46, 5)", + "01.08 north 19 (to wall) -> Route 204 (14, 18)", + "01.08 west 2 (open) -> Route 204 (12, 18)", + "01.08 north 16 (to wall) -> Route 204 (12, 2)", + "01.08 west 1 (to wall) -> Route 204 (11, 2)", + "01.09 west_of_the_rock costs=default from RavagedPath (19, 50) to RavagedPath (21, 43)", + "01.09 north 7 (open) -> RavagedPath (19, 43)", + "01.09 east 2 (open) -> RavagedPath (21, 43)", + "01.09 above_the_way_out costs=default from RavagedPath (21, 43) to RavagedPath (28, 44)", + "01.09 east 8 (to wall) -> RavagedPath (29, 43)", + "01.09 south 1 (to wall) -> RavagedPath (29, 44)", + "01.09 west 1 (open) -> RavagedPath (28, 44)", + "01.10 line_1 costs=line from Route204North (20, 26) to Route204North (20, 27)", + "01.10 south 1 (open) -> Route 204 (20, 27)", + "01.10 line_2 costs=line from Route204North (20, 27) to Route204North (11, 27)", + "01.10 west 9 (open) -> Route 204 (11, 27)", + "01.10 line_3 costs=line from Route204North (11, 27) to Route204North (11, 22)", + "01.10 north 5 (open) -> Route 204 (11, 22)", + "01.10 line_4 costs=line from Route204North (11, 22) to Route204North (19, 22)", + "01.10 east 8 (open) -> Route 204 (19, 22)", + "01.10 line_5 costs=line from Route204North (19, 22) to Route204North (19, 12)", + "01.10 north 10 (open) -> Route 204 (19, 12)", + "01.10 line_6 costs=line from Route204North (19, 12) to Route204North (11, 12)", + "01.10 west 8 (open) -> Route 204 (11, 12)", + "01.10 line_7 costs=line from Route204North (11, 12) to Route204North (11, 5)", + "01.10 north 7 (open) -> Route 204 (11, 5)", + "01.10 into_floaroma costs=line from Route204North (11, 5) to FloaromaTown (11, 29)", + "01.10 north 8 (open) -> Floaroma Town (11, 29)", + "01.11 west_along_the_field costs=default from FloaromaTown (11, 29) to FloaromaTown (3, 29)", + "01.11 west 8 (open) -> Floaroma Town (3, 29)", + "01.11 below_the_old_man costs=default from FloaromaTown (4, 26) to FloaromaTown (3, 26)", + "01.11 west 1 (open) -> Floaroma Town (3, 26)", +}; + +} // namespace PokemonBDSP +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp index e9f15c0632..79bab21f0a 100644 --- a/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp +++ b/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StorySimulation_Tests.cpp @@ -27,6 +27,7 @@ #include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "Data/PokemonBDSP_AutoStory_RobustRoute.h" +#include "PokemonBDSP_AutoStory_PlanGolden.h" #include "Data/PokemonBDSP_AutoStory_WalkRules.h" #include "Utils/PokemonBDSP_AutoStory_Location.h" #include "Data/PokemonBDSP_AutoStory_PlanCosts.h" @@ -78,6 +79,7 @@ struct Walked{ std::optional at; std::string error; std::string plan; + std::vector golden = {}; }; // The tiles a plan walks. @@ -132,6 +134,15 @@ Walked plan_route(const Pose& from, const StoryStep& step){ for (const PlannedLeg& leg : *plan){ walked.plan += " " + to_string(leg.leg); } + walked.golden.push_back(std::format("{} costs={} from{} to{}", step.name, step.action.empty() ? "default" : step.action, + describe(from.map, Pokemon::tiles_of(from)), describe(goal.map, Pokemon::tiles_of(goal)))); + for (const PlannedLeg& leg : *plan){ + std::string line = std::format(" {} ->", to_string(leg.leg)); + for (const TilePos& pos : leg.after){ + line += std::format(" {}", describe(*world, pos)); + } + walked.golden.push_back(line); + } const std::string detour = detour_error(*world, start, at_goal, *plan); if (!detour.empty()){ return {std::nullopt, step.name + ": " + detour, walked.plan}; @@ -233,6 +244,8 @@ class FakeGame : public Pokemon::StoryStepExecutor{ std::vector& trace; std::map failures; std::vector plans; + // Every ROUTE's legs, one header line per route, for the golden test. + std::vector golden; explicit FakeGame(std::vector& trace) : trace(trace) @@ -291,6 +304,9 @@ class FakeGame : public Pokemon::StoryStepExecutor{ if (!walked.plan.empty()){ plans.push_back(walked.plan); } + for (const std::string& line : walked.golden){ + golden.push_back(std::format("{} {}", m_row, line)); + } return walked.at ? Pokemon::outcome_ok(*walked.at) : Pokemon::outcome_ok(Pose{}); } @@ -381,6 +397,35 @@ UnitTestResult test_whole_table(Logger& logger){ return true; } +// The legs planned for every ROUTE of the whole story, against the stored +// copy in PokemonBDSP_AutoStory_PlanGolden.h. A change that should not +// alter any plan must leave this byte-identical. To regenerate after an +// intended plan change: run this suite, and replace the lines of +// BDSP_PLAN_GOLDEN with the lines the failure logs after "GOLDEN|". +UnitTestResult test_golden_plans(Logger& logger){ + Simulation sim; + const Pokemon::SegmentReport report = sim.run({}, Language::English); + if (!report.completed){ + return "expected the whole story through:" + joined(sim.lines); + } + const std::vector& actual = sim.game.golden; + const size_t stored = sizeof(BDSP_PLAN_GOLDEN) / sizeof(BDSP_PLAN_GOLDEN[0]); + size_t first_diff = 0; + while (first_diff < actual.size() && first_diff < stored && actual[first_diff] == BDSP_PLAN_GOLDEN[first_diff]){ + first_diff++; + } + if (first_diff == actual.size() && first_diff == stored){ + return true; + } + for (const std::string& line : actual){ + logger.log(std::format("GOLDEN|{}", line)); + } + return std::format("plans differ from the golden at line {} ({} lines now, {} stored): now \"{}\", stored \"{}\".", + first_diff + 1, actual.size(), stored, + first_diff < actual.size() ? std::string_view(actual[first_diff]) : std::string_view(), + first_diff < stored ? BDSP_PLAN_GOLDEN[first_diff] : std::string_view()); +} + UnitTestResult test_start_and_end(Logger&){ Simulation sim; Pokemon::SegmentReport report = sim.run({.from = "00.04b", .to = "00.04d"}); @@ -623,6 +668,10 @@ const AutoStoryStorySimulationCase AUTO_STORY_STORY_SIMULATION_CASES[] = { .input = {"no hand-written legs but the listed ones", test_no_hand_written_legs}, .expectation = {}, }, + { + .input = {"plans match the golden", test_golden_plans}, + .expectation = {}, + }, }; void add_tests_AutoStory_StorySimulation(UnitTestDatabase& database){ diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index acf34b6d01..74160b3be6 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1743,6 +1743,7 @@ file(GLOB LIBRARY_SOURCES Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Maps_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Maps_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.cpp + Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlanGolden.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.h Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.cpp Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.h