Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=904 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -122,10 +122,10 @@

const std::string TAKE_MASTER_BALL_TEXT =
"<b>Take the Master Ball:</b><br>On by default. After Giovanni on Silph Co.'s 11F, talk to the president for the "
"Master Ball (16.05). Off, or with the checks on SPEEDRUN, skips it.";
"Master Ball (16.05b). Off, or with the checks on SPEEDRUN, skips it.";

// code-health: allow function_lines -- a flat list of the program's options, each one line of its own; splitting it hides which belong
AutoStory::AutoStory()

Check warning on line 128 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (bypass)

PokemonAutomation::NintendoSwitch::PokemonFRLG::AutoStory::AutoStory(): function_lines=59 over limit 50, bypassed by the tag at line 127: "a flat list of the program's options, each one line of its own; splitting it hides which belong"
: RUN(checkpoint_database(), Pokemon::FireRedLeafGreenLanguages_Database())
, NEW_GAME_FROM_TITLE(
"<b>New game from the title screen:</b><br>The game is on its title screen with no save data. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class AutoStory : public SingleSwitchProgramInstance{
// Runs Gift RNG's attempts in the program after 04.02 (the Magikarp)
// and 09.03 (the Eevee).
BooleanCheckBoxOption RUN_GIFT_RNG;
// Takes the Master Ball from Silph Co.'s president (16.05), unless the
// Takes the Master Ball from Silph Co.'s president (16.05b), unless the
// run is a SPEEDRUN.
BooleanCheckBoxOption TAKE_MASTER_BALL;
StarterRngPlanOptions RNG_PLAN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Battle Policy Tests

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattlePolicy_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=747 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -525,6 +525,80 @@
return true;
}

// What a boss's step resolves to: the policy, the doc's setup goals and
// the generator's foe rows (PokemonSimulation planning_risk() for each foe
// leading against the fight's pokeguy entry, as the League's).
struct ResolvedPolicy{
BattlePolicyKind kind = BattlePolicyKind::NONE;
SetupGoals goals = {};
std::vector<std::vector<int64_t>> rows = {};
};

UnitTestResult check_resolved_policy(std::string_view id, std::string_view name, const ResolvedPolicy& expected){
const StoryStep& step = battle_step(id, name);
const BattlePolicy policy = battle_policy_of(step.args);
if (policy.kind != expected.kind){
return std::format("{} {}: the step does not resolve to the doc's policy.", id, name);
}
const SetupGoals& goals = policy.goals;
const SetupGoals& want = expected.goals;
if (goals.spa != want.spa || goals.accuracy != want.accuracy || goals.outspeed != want.outspeed
|| goals.guard_accuracy != want.guard_accuracy || goals.torrent_power != want.torrent_power
|| goals.target_torrent != want.target_torrent
){
return std::format("{} {}: the setup goals differ from the doc's.", id, name);
}
if (arg_of<std::vector<std::vector<int64_t>>>(step, "foe_threats") != expected.rows || policy.foes.size() != expected.rows.size()){
return std::format("{} {}: foe_threats are not the generator's rows.", id, name);
}
return true;
}

// Silph Co.'s Giovanni (doc: silph-giovanni, C). Without a policy the step
// fought potions-only: console B's lead attacked from turn 1, poisoned,
// never used an X item, and lost twice (2026-11-15, 16.05).
UnitTestResult test_plan_silph_giovanni(){
return check_resolved_policy("16.05", "giovanni", {
.kind = BattlePolicyKind::GOAL_BASED_SETUP,
.goals = {.spa = 1, .outspeed = true, .guard_accuracy = true},
.rows = {
{64, 15, 11, 45, 21, 0, 0}, // Nidorino
{70, 26, 12, 63, 31, 0, 0}, // Kangaskhan
{34, 18, 13, 112, 55, 0, 0}, // Rhyhorn
{79, 19, 12, 52, 26, 0, 0}, // Nidoqueen
},
});
}

// Sabrina (doc: sabrina, C): no Sp. Atk goal, X Speed to outspeed Alakazam.
UnitTestResult test_plan_sabrina(){
return check_resolved_policy("18.02", "sabrina", {
.kind = BattlePolicyKind::GOAL_BASED_SETUP,
.goals = {.outspeed = true, .guard_accuracy = true},
.rows = {
{84, 0, 5, 57, 28, 0, 0}, // Kadabra
{71, 0, 3, 45, 22, 0, 0}, // Mr. Mime
{73, 12, 12, 26, 13, 0, 0}, // Venomoth
{108, 47, 47, 96, 48, 0, 0}, // Alakazam
},
});
}

// Viridian's Giovanni (doc: giovanni-gym, A): A fights run B, the doc's
// default runtime, so solo-recovery; Dugtrio's Mud-Slap lowers accuracy.
UnitTestResult test_plan_giovanni_gym(){
return check_resolved_policy("17.04", "giovanni", {
.kind = BattlePolicyKind::SOLO_RECOVERY,
.rows = {
{27, 45, 36, 126, 59, 0, 0}, // Rhyhorn
{105, 36, 36, 75, 37, 1, 0}, // Dugtrio
{71, 41, 41, 84, 42, 0, 0}, // Nidoqueen
{81, 48, 45, 99, 49, 0, 0}, // Nidoking
{27, 52, 41, 140, 69, 0, 0}, // Rhydon (the doc's Lv50 Rhyhorn)
},
});
}


struct AutoStoryBattlePolicyInput{
std::string name;
Expand Down Expand Up @@ -643,6 +717,18 @@
.input = {.name = "plan: 10.03 rival_tower names the policy, goals and foes", .body = test_plan_tower_rival},
.expectation = {.description = "the policy, goals and 5 foe rows"},
},
{
.input = {.name = "plan: 16.05 giovanni resolves to the doc's C2", .body = test_plan_silph_giovanni},
.expectation = {.description = "goal-based-setup, Sp. Atk +1, outspeed, Guard Spec first, 4 generator rows"},
},
{
.input = {.name = "plan: 18.02 sabrina resolves to the doc's C2", .body = test_plan_sabrina},
.expectation = {.description = "goal-based-setup, outspeed, Guard Spec first, 4 generator rows"},
},
{
.input = {.name = "plan: 17.04 giovanni resolves to the doc's B", .body = test_plan_giovanni_gym},
.expectation = {.description = "solo-recovery, 5 generator rows"},
},
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct StoryEnv{
// restores into `party.users`. The program starts it from its settings
// and keeps it there.
SavedFieldMoveUsers saved_field_moves = {};
// The program's "Take the Master Ball" option: 16.05's talk with Silph
// The program's "Take the Master Ball" option: 16.05b's talk with Silph
// Co.'s president (skip_if master_ball_skipped).
bool take_master_ball = true;
// The run's breakpoints (the BREAKPOINTS option): StoryExecutor pauses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_16[] = {
"16.05 walk east 3 -> SilphCo_11F (5, 18)",
"16.05 open gate north -> SilphCo_11F (5, 18)",
"16.05 walk north 2 -> SilphCo_11F (5, 16)",
"16.05 below_president from SilphCo_11F (5, 15) facing east to SilphCo_11F (9, 10) facing north",
"16.05 walk north 5 -> SilphCo_11F (5, 10)",
"16.05 walk east 4 -> SilphCo_11F (9, 10)",
"16.05 face north -> SilphCo_11F (9, 10)",
"16.05b below_president from SilphCo_11F (5, 15) facing east to SilphCo_11F (9, 10) facing north",
"16.05b walk north 5 -> SilphCo_11F (5, 10)",
"16.05b walk east 4 -> SilphCo_11F (9, 10)",
"16.05b face north -> SilphCo_11F (9, 10)",
"16.06 below_center_door from SilphCo_11F (9, 10) facing north to SaffronCity (24, 39) facing north",
"16.06 walk west 4 (to wall) -> SilphCo_11F (5, 10)",
"16.06 walk south 9 (to wall) -> SilphCo_11F (5, 19)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* From: https://github.com/PokemonAutomation/
*
* The golden's lines for 18.01 and 18.02, Saffron Gym (after
* The golden's lines for 18.01 to 18.02b, Saffron Gym (after
* PokemonFRLG_AutoStoryPlanGolden16.h's, before PokemonFRLG_AutoStoryPlanGolden17.h's
* 17.01), in the story's order.
*
Expand All @@ -17,7 +17,7 @@ namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{

// The stored plan lines of 18.01 and 18.02, Saffron Gym.
// The stored plan lines of 18.01 to 18.02b, Saffron Gym.
inline constexpr std::string_view FRLG_PLAN_GOLDEN_18[] = {
"18.01 by_pad_to_bottom_right from SaffronCity_Gym (14, 23) facing north to SaffronCity_Gym (17, 20) facing east",
"18.01 walk east 3 -> SaffronCity_Gym (17, 23) [walk only]",
Expand All @@ -37,29 +37,29 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_18[] = {
"18.01 below_sabrina from SaffronCity_Gym (18, 15) facing south to SaffronCity_Gym (14, 12) facing north",
"18.01 walk west 4 -> SaffronCity_Gym (14, 15) [walk only]",
"18.01 walk north 3 -> SaffronCity_Gym (14, 12) [walk only]",
"18.02 by_pad_out_of_sabrina from SaffronCity_Gym (14, 12) facing north to SaffronCity_Gym (17, 15) facing east",
"18.02 walk south 3 (to wall) -> SaffronCity_Gym (14, 15) [walk only]",
"18.02 walk east 3 -> SaffronCity_Gym (17, 15) [walk only]",
"18.02 by_pad_from_top_left from SaffronCity_Gym (0, 7) facing east to SaffronCity_Gym (0, 5) facing north",
"18.02 walk north 2 -> SaffronCity_Gym (0, 5) [walk only]",
"18.02 along_row_6 from SaffronCity_Gym (20, 7) facing north to SaffronCity_Gym (28, 6) facing east",
"18.02 walk north 1 -> SaffronCity_Gym (20, 6) [walk only]",
"18.02 walk east 8 (to wall) -> SaffronCity_Gym (28, 6) [walk only]",
"18.02 below_pad_from_top_right from SaffronCity_Gym (28, 6) facing east to SaffronCity_Gym (28, 5) facing north",
"18.02 walk north 1 -> SaffronCity_Gym (28, 5) [walk only]",
"18.02 by_pad_from_bottom_right from SaffronCity_Gym (20, 20) facing north to SaffronCity_Gym (28, 22) facing south",
"18.02 walk south 2 -> SaffronCity_Gym (20, 22) [walk only]",
"18.02 walk east 8 (to wall) -> SaffronCity_Gym (28, 22) [walk only]",
"18.02 face south -> SaffronCity_Gym (28, 22) [walk only]",
"18.02 below_center_door from SaffronCity_Gym (18, 20) facing south to SaffronCity (24, 39) facing north",
"18.02 walk south 3 (to wall) -> SaffronCity_Gym (18, 23) [walk only]",
"18.02 walk west 4 -> SaffronCity_Gym (14, 23) [walk only] [tapped]",
"18.02 walk south 1 (warp) -> SaffronCity (46, 13) [walk only]",
"18.02 walk south 4 (to wall) -> SaffronCity (46, 17)",
"18.02 walk east 4 -> SaffronCity (50, 17)",
"18.02 walk south 24 (to wall) -> SaffronCity (50, 41)",
"18.02 walk west 26 -> SaffronCity (24, 41)",
"18.02 walk north 2 -> SaffronCity (24, 39)",
"18.02b by_pad_out_of_sabrina from SaffronCity_Gym (14, 12) facing north to SaffronCity_Gym (17, 15) facing east",
"18.02b walk south 3 (to wall) -> SaffronCity_Gym (14, 15) [walk only]",
"18.02b walk east 3 -> SaffronCity_Gym (17, 15) [walk only]",
"18.02b by_pad_from_top_left from SaffronCity_Gym (0, 7) facing east to SaffronCity_Gym (0, 5) facing north",
"18.02b walk north 2 -> SaffronCity_Gym (0, 5) [walk only]",
"18.02b along_row_6 from SaffronCity_Gym (20, 7) facing north to SaffronCity_Gym (28, 6) facing east",
"18.02b walk north 1 -> SaffronCity_Gym (20, 6) [walk only]",
"18.02b walk east 8 (to wall) -> SaffronCity_Gym (28, 6) [walk only]",
"18.02b below_pad_from_top_right from SaffronCity_Gym (28, 6) facing east to SaffronCity_Gym (28, 5) facing north",
"18.02b walk north 1 -> SaffronCity_Gym (28, 5) [walk only]",
"18.02b by_pad_from_bottom_right from SaffronCity_Gym (20, 20) facing north to SaffronCity_Gym (28, 22) facing south",
"18.02b walk south 2 -> SaffronCity_Gym (20, 22) [walk only]",
"18.02b walk east 8 (to wall) -> SaffronCity_Gym (28, 22) [walk only]",
"18.02b face south -> SaffronCity_Gym (28, 22) [walk only]",
"18.02b below_center_door from SaffronCity_Gym (18, 20) facing south to SaffronCity (24, 39) facing north",
"18.02b walk south 3 (to wall) -> SaffronCity_Gym (18, 23) [walk only]",
"18.02b walk west 4 -> SaffronCity_Gym (14, 23) [walk only] [tapped]",
"18.02b walk south 1 (warp) -> SaffronCity (46, 13) [walk only]",
"18.02b walk south 4 (to wall) -> SaffronCity (46, 17)",
"18.02b walk east 4 -> SaffronCity (50, 17)",
"18.02b walk south 24 (to wall) -> SaffronCity (50, 41)",
"18.02b walk west 26 -> SaffronCity (24, 41)",
"18.02b walk north 2 -> SaffronCity (24, 39)",
};

} // namespace PokemonFRLG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace NintendoSwitch{
namespace PokemonFRLG{


// Rows 18.01 and 18.02, Saffron Gym's pads, on the overworld sim
// Rows 18.01 to 18.02b, Saffron Gym's pads, on the overworld sim
// (PokemonFRLG_AutoStorySaffronGym_Tests.cpp).
void add_tests_AutoStorySaffronGym(UnitTestDatabase& database);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Run Plan Tests

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=662 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -145,7 +145,7 @@
const RunPlanScenario m_scenario;
};

const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.06 18.01 18.02 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05";
const std::string TODAY = "01.01 01.03 01.04 01.05 02.01 02.02 02.03 03.01 03.02 03.03 04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 18.01 18.02 18.02b 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05";

const RunPlanScenario RUN_PLAN_CASES[] = {
{
Expand Down Expand Up @@ -236,11 +236,11 @@
},
{
.input = {.name = "Gift RNG off: 04.03 is passed over", .first = "04.01"},
.expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.06 18.01 18.02 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
.expectation = {.expected_ids = "04.01 04.02 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 18.01 18.02 18.02b 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
},
{
.input = {.name = "Gift RNG off: 04.03 runs when started at", .first = "04.03"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.06 18.01 18.02 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 18.01 18.02 18.02b 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
},
{
.input = { .name = "Gift RNG: started at 04.03, from the save beside the salesman",
Expand Down Expand Up @@ -279,7 +279,7 @@
},
{
.input = {.name = "Starter RNG alone: 04.03 runs when started at", .first = "04.03", .handoffs = {.starter_rng = true}},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.06 18.01 18.02 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
.expectation = {.expected_ids = "04.03 04.04 04.05 04.06 05.01 05.02 05.03 05.04 05.05 05.06 05.07 05.08 05.09 05.10 06.01 06.02 06.03 06.04 07.01 07.02 08.01 08.02 08.03 09.01 09.02 09.03 10.01 10.02 10.03 10.04 10.05 10.06 11.01 11.02 11.03 12.01 12.02 12.02b 12.03 13.01 13.02 13.03 13.04 14.01 14.02 14.02b 14.03 14.04 14.04b 15.01 16.01 16.02 16.03 16.03b 16.05 16.05b 16.06 18.01 18.02 18.02b 17.02 17.03 17.04 17.04b 19.01a 19.01 19.02 19.03 19.04 19.04b 19.04c 19.04d 19.05 20.01a 20.01 20.02 20.03 20.04 20.05"},
},
{
.input = { .name = "Starter RNG first, with both on",
Expand Down
Loading
Loading