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
Expand Up @@ -342,10 +342,9 @@ bool OverworldSim::trainer_sees(Milliseconds pressed){
trainer.x = stop.x;
trainer.y = stop.y;
trainer.wander.reset();
// The player turns to face the trainer.
for (Direction direction : {Direction::NORTH, Direction::EAST, Direction::SOUTH, Direction::WEST}){
m_state.facing = m_player.position.next(direction) == stop ? direction : m_state.facing;
}
// The player keeps their facing: the game doesn't turn them to the
// trainer (pokefirered TrainerSeeFunc_PrepareToEngage(), the turn
// commented out).
m_trainer_speaking = c;
m_frozen = true;
schedule(pressed + m_script.timing.tile * (1 + approach) + m_script.timing.trainer_notice, SimScreen::MESSAGE, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Endpoint Tests

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=699 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -339,6 +339,12 @@
.input = {.checkpoint = "06.01"},
.expectation = {.map = "VermilionCity_PokemonCenter_1F", .tile = {7, 4}, .facing = Direction::NORTH},
},
{
.name = "06.03 Route 6's grass until the lead is Lv31, then through the open beams to Lt. Surge",
// 06.02 fights Dwayne, Baily and Tucker.
.input = {.checkpoint = "06.03", .trainers_beaten_on = "VermilionCity_Gym"},
.expectation = {.map = "VermilionCity_Gym", .tile = {5, 3}, .facing = Direction::NORTH},
},
{
.name = "06.04 Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center",
.input = {.checkpoint = "06.04"},
Expand Down Expand Up @@ -399,6 +405,11 @@
.input = {.checkpoint = "10.03"},
.expectation = {.map = "PokemonTower_2F", .tile = {16, 6}, .facing = Direction::NORTH},
},
{
.name = "10.04 Pokemon Tower 3F to 5F: a Super Repel, Ruth and Tammy",
.input = {.checkpoint = "10.04"},
.expectation = {.map = "PokemonTower_5F", .tile = {18, 7}, .facing = Direction::SOUTH},
},
{
.name = "10.05 Pokemon Tower 6F: Jennifer, Emilia, the Rare Candy and the Marowak ghost",
.input = {.checkpoint = "10.05"},
Expand Down Expand Up @@ -439,6 +450,11 @@
.input = {.checkpoint = "12.02b"},
.expectation = {.map = "FuchsiaCity_PokemonCenter_1F", .tile = {7, 4}, .facing = Direction::NORTH},
},
{
.name = "13.01 Cinnabar to the Pokemon Mansion: 1F and 2F up to 3F's room of holes, the statue switch pressed on the way",
.input = {.checkpoint = "13.01"},
.expectation = {.map = "PokemonMansion_3F", .tile = {19, 13}, .facing = Direction::SOUTH},
},
{
.name = "13.02 Pokemon Mansion 3F's hole to 1F, 1F's stairs to B1F",
.input = {.checkpoint = "13.02"},
Expand Down Expand Up @@ -489,6 +505,16 @@
.input = {.checkpoint = "16.04"},
.expectation = {.map = "SilphCo_7F", .tile = {1, 7}, .facing = Direction::WEST},
},
{
.name = "17.02 Saffron to Viridian Gym: Fly, Warren",
.input = {.checkpoint = "17.02"},
.expectation = {.map = "ViridianCity_Gym", .tile = {15, 7}, .facing = Direction::NORTH},
},
{
.name = "17.03 Viridian Gym: Takashi, to Giovanni",
.input = {.checkpoint = "17.03"},
.expectation = {.map = "ViridianCity_Gym", .tile = {2, 3}, .facing = Direction::NORTH},
},
{
.name = "17.04 Viridian Gym: Giovanni and the EARTHBADGE",
.input = {.checkpoint = "17.04"},
Expand Down Expand Up @@ -576,20 +602,15 @@
{.checkpoint = "04.05", .reason = "its helix_gap step is a plain step the sim reads as a trainer's line, and no trainer is there"},
{.checkpoint = "05.01", .reason = "ends on LEGS taps (Cerulean Gym): no declared end (checkpoint_end_pose())"},
{.checkpoint = "06.02", .reason = "Vermilion Gym's Cut tree and trash cans: PokemonFRLG_AutoStoryVermilionGym_Tests.cpp"},
{.checkpoint = "06.03", .reason = "red: the walk to Lt. Surge ends on (5, 4), one tile short of the declared (5, 3)"},
{.checkpoint = "09.01", .reason = "the poster guard's step ends on (11, 3), not (11, 2): PokemonFRLG_AutoStoryHideout_Tests.cpp"},
{.checkpoint = "10.04", .reason = "red: the sim turns the player to the trainer who walks up (OverworldSim::trainer_sees), so Tammy leaves them facing east; pokefirered's TrainerSeeFunc_PrepareToEngage does not turn the player, the plan's south stands"},
{.checkpoint = "12.03", .reason = "Route 21's Surf landing on the sand bar needs the Surf state the generic walk lacks: PokemonFRLG_AutoStorySurf_Tests.cpp"},
{.checkpoint = "13.01", .reason = "red: the Mansion's holes leave the sim facing north, the plan declares south"},
{.checkpoint = "14.01", .reason = "ends on LEGS taps (the quiz machines): no declared end (checkpoint_end_pose())"},
{.checkpoint = "14.02b", .reason = "the quiz doors' gates are shut on a fresh sim: PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp"},
{.checkpoint = "14.04b", .reason = "Celadon Gym's legs need the cut tree: PokemonFRLG_AutoStoryCeladonGym_Tests.cpp"},
{.checkpoint = "16.02", .reason = "ends on LEGS taps (the pad pair): no declared end (checkpoint_end_pose())"},
{.checkpoint = "16.03", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"},
{.checkpoint = "16.05", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"},
{.checkpoint = "16.06", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"},
{.checkpoint = "17.02", .reason = "red: the sim turns the player to Warren as he walks up (OverworldSim::trainer_sees), so the row ends on (15, 7) facing west; pokefirered's TrainerSeeFunc_PrepareToEngage does not turn the player, the plan's north stands. The tile is checked by PokemonFRLG_AutoStoryViridian_Tests.cpp"},
{.checkpoint = "17.03", .reason = "red, known: Takashi stands in the way after his battle, and below_giovanni stops on (10, 5) (the fault sweep's known-failing clean run)"},
{.checkpoint = "19.03", .reason = "the soul guard's gate scene moves the player: PokemonFRLG_AutoStoryGates_Tests.cpp"},
{.checkpoint = "19.04b", .reason = "Victory Road's boulders and floor switches: PokemonFRLG_AutoStoryBoulders_Tests.cpp"},
{.checkpoint = "19.04c", .reason = "Victory Road's boulders and floor switches: PokemonFRLG_AutoStoryBoulders_Tests.cpp"},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Fault Sweep Tests

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=885 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -76,6 +76,7 @@
#include "PokemonFRLG_AutoStoryFieldMoves.h"
#include "PokemonFRLG_AutoStoryHideoutLift.h"
#include "PokemonFRLG_AutoStoryItemUse.h"
#include "PokemonFRLG_AutoStoryMovedTrainers.h"
#include "PokemonFRLG_AutoStoryPacedRoute.h"
#include "PokemonFRLG_AutoStoryRowSim.h"
#include "PokemonFRLG_AutoStoryTable.h"
Expand Down Expand Up @@ -107,8 +108,6 @@
"below_gym_tree walks onto the gym's door warp and sees no fade (VermilionCity_Gym (4, 12)): the door's warp on the sim after trash_cans, which the sim stubs, not yet looked at"},
{"PokemonFRLG::AutoStory - Fault sweep: 09.02, clean run",
"b2f_arrows_to_lift_room moves nothing twice from RocketHideout_B2F (1, 4) after moon_stone, a talk the sim stubs: the arrow tiles' spin from that tile on the sim, not yet looked at"},
{"PokemonFRLG::AutoStory - Fault sweep: 17.03, clean run",
"Takashi (10, 2) walks up to (10, 4) when he sees the player on (10, 5) and stays there after the battle, so below_giovanni's way north up column 10 is blocked (moved nothing twice); on the console too: the route after a line battle planned with the trainer who walked up as a wall (with_trainers()), or a way to Takashi from row 3"},
{"PokemonFRLG::AutoStory - Fault sweep: 08.03, mount lost",
"riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"},
};
Expand Down Expand Up @@ -199,11 +198,12 @@
// sweep_maps() as row `row` starts: the gyms cleared before it with no
// trainer left to see the player, nor the trainers its start_flags have
// beaten (16.03: the Rocket by 5F's corridor, whom 16.02's walk fights),
// and no Rocket left once its start_flags have Silph Co. cleared.
// each standing where its start_flags say he walked up to (17.03: Warren
// on (14, 7)), and no Rocket left once its start_flags have Silph Co. cleared.
std::vector<MapData> row_maps(const StoryCheckpoint& row){
const std::set<std::string> start_flags = start_flag_set(row);
const std::vector<MapData>& base = start_flags.contains(std::string(SILPH_CLEARED_FLAG)) ? cleared_sweep_maps() : sweep_maps();
std::vector<MapData> maps = with_trainers_beaten(base, beaten_trainers(start_flags));
const std::set<std::string> flags = start_flag_set(row);
const std::vector<MapData>& base = flags.contains(std::string(SILPH_CLEARED_FLAG)) ? cleared_sweep_maps() : sweep_maps();
std::vector<MapData> maps = with_trainers_beaten(with_trainers_moved(base, moved_trainers(flags)), beaten_trainers(flags));
const std::set<std::string> cleared = gyms_cleared_before(row);
for (MapData& map : maps){
if (!cleared.contains(map.name)){
Expand Down Expand Up @@ -308,17 +308,18 @@
return true;
}

// Row `row`'s step `c` on `sim` from `at`, recorded in `out`. Returns
// whether it failed as unscripted() and was let pass (run_row()).
// Row `row`'s step `c` on `sim` from `at`, with the run flags the steps
// before it left (`run_flags`), recorded in `out`. Returns whether it
// failed as unscripted() and was let pass (run_row()).
bool run_row_step(
RowRun& out, OverworldSim& sim, StoryPose& at, const StoryCheckpoint& row, size_t c,
const std::optional<std::set<size_t>>& scripted
const std::set<std::string>& run_flags, const std::optional<std::set<size_t>>& scripted
){
out.before.emplace(c, sim.state().position);
out.facing_before.emplace(c, sim.state().facing);
out.gates_before.emplace(c, sim.state().gates);
const size_t warps_before = sim.state().warped_from.size();
out.failure = row_step_on_sim(sim, at, row.steps[c], row.id, start_flag_set(row));
out.failure = row_step_on_sim(sim, at, row.steps[c], row.id, run_flags);
const std::vector<std::string>& warped = sim.state().warped_from;
out.warped_from[c].assign(warped.begin() + warps_before, warped.end());
const bool let_pass = unscripted(out.failure) && (!scripted || scripted->contains(c));
Expand Down Expand Up @@ -364,7 +365,7 @@
// step that fails as unscripted() is let pass as one the sim does not
// play: in a clean run (`scripted` unset) at any step, else only at the
// steps in `scripted`, where the clean run let it pass.
RowRun run_row(

Check warning on line 368 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::run_row( const StoryCheckpoint & row , const SimScript & row_script , const Landings & landings = { } , const std :: optional<std::set<size_t>> & scripted = std :: nullopt): function_lines=50 (advisory above 25, limit 50)
const StoryCheckpoint& row, const SimScript& row_script, const Landings& landings = {},
const std::optional<std::set<size_t>>& scripted = std::nullopt
){
Expand All @@ -374,6 +375,8 @@
StoryPose at = *story_pose(Pokemon::pose_of(*row.start));
std::vector<MapData> maps = row_maps(row);
auto sim = std::make_unique<OverworldSim>(maps, MapPosition{at.map, at.tile}, at.facing.value_or(Direction::SOUTH), script);
// The run's flags: the start's, then each step's flags_after (trainer_at).
std::set<std::string> flags = start_flag_set(row);
const auto add = [&out](const SimState& state){
out.time += state.time;
out.steps += state.steps;
Expand All @@ -384,8 +387,9 @@
};
for (size_t c = 0; c < row.steps.size() && out.failure.empty(); c++){
const StoryStep& step = row.steps[c];
const bool let_pass = run_row_step(out, *sim, at, row, c, scripted);
const bool let_pass = run_row_step(out, *sim, at, row, c, flags, scripted);
play_ride_bike(*sim, script, step);
flags.insert(step.flags_after.begin(), step.flags_after.end());
if (!out.failure.empty() || (sim_plays(step) && !let_pass) || !step.pose_after){
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_17_GYM[] = {
"17.03 walk west 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]",
"17.03 walk north 1 -> ViridianCity_Gym (10, 6) [walk only]",
"17.03 below_giovanni from ViridianCity_Gym (10, 5) facing north to ViridianCity_Gym (2, 3) facing north",
"17.03 walk north 2 -> ViridianCity_Gym (10, 3) [walk only]",
"17.03 walk west 3 -> ViridianCity_Gym (7, 3) [walk only]",
"17.03 walk south 3 (to wall) -> ViridianCity_Gym (7, 6) [walk only]",
"17.03 walk south 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]",
"17.03 walk east 3 -> ViridianCity_Gym (13, 7) [walk only]",
"17.03 walk north 1 (to wall) -> ViridianCity_Gym (13, 6) [walk only]",
"17.03 walk east 3 (to wall) -> ViridianCity_Gym (16, 6) [walk only]",
"17.03 walk south 7 (spins 2) -> ViridianCity_Gym (16, 15) [walk only]",
"17.03 walk east 3 (to wall) -> ViridianCity_Gym (19, 15) [walk only]",
"17.03 walk north 1 (spins 11) -> ViridianCity_Gym (19, 3) [walk only]",
"17.03 walk north 1 (spins 8) -> ViridianCity_Gym (11, 2) [walk only]",
"17.03 walk west 4 -> ViridianCity_Gym (7, 2) [walk only]",
"17.03 walk south 4 (to wall) -> ViridianCity_Gym (7, 6) [walk only]",
"17.03 walk west 5 -> ViridianCity_Gym (2, 6) [walk only]",
"17.03 walk north 3 -> ViridianCity_Gym (2, 3) [walk only]",
"17.04b gym_exit from ViridianCity_Gym (2, 3) facing north to ViridianCity (36, 11) facing south",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@
],
"facing": "north"
},
"why": "Warren (TRAINER_COOLTRAINER_WARREN): Marowak Lv37, Marowak Lv37, Rhyhorn Lv38, Nidorina Lv39, Nidoqueen Lv39"
"why": "Warren (TRAINER_COOLTRAINER_WARREN): Marowak Lv37, Marowak Lv37, Rhyhorn Lv38, Nidorina Lv39, Nidoqueen Lv39; he walked up from (13, 7) to (14, 7) when he saw the player on (15, 7) (pokefirered TrainerApproachPlayer: approach distance 2, one tile short) and stands there from now on (trainer_at), west of the player on row 7",
"flags_after": [
"trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7",
"trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7"
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
],
"facing": "north"
},
"start_flags": [
"trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7",
"trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7"
],
"events": [
{
"id": "below_takashi_line",
Expand Down Expand Up @@ -64,7 +68,11 @@
],
"facing": "north"
},
"why": "Takashi (TRAINER_BLACK_BELT_TAKASHI): Machoke Lv38, Machop Lv38, Machoke Lv38, Machoke Lv43"
"why": "Takashi (TRAINER_BLACK_BELT_TAKASHI): Machoke Lv38, Machop Lv38, Machoke Lv38, Machoke Lv43; he walked up from (10, 2) to (10, 4) when he saw the player on (10, 5) (pokefirered TrainerApproachPlayer: approach distance 3, one tile short) and stands there from now on (trainer_at; TrainerSeeFunc_PrepareToEngage: OverrideTemplateCoordsForObjectEvent), across column 10 north of the player",
"flags_after": [
"trainer_beaten:ViridianCity_Gym/black_belt@10,2",
"trainer_at:ViridianCity_Gym/black_belt@10,2=10,4"
]
},
{
"id": "below_giovanni",
Expand All @@ -82,7 +90,7 @@
"facing": "north"
}
},
"why": "west along row 3 and down to (2, 3), facing Giovanni (2, 2)"
"why": "round Takashi, who stands on (10, 4) since his battle, to (2, 3), facing Giovanni (2, 2)"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
],
"facing": "north"
},
"start_flags": [
"trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7",
"trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7",
"trainer_beaten:ViridianCity_Gym/black_belt@10,2",
"trainer_at:ViridianCity_Gym/black_belt@10,2=10,4"
],
"events": [
{
"id": "lead_lv50_for_giovanni",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
],
"facing": "north"
},
"start_flags": [
"trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7",
"trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7",
"trainer_beaten:ViridianCity_Gym/black_belt@10,2",
"trainer_at:ViridianCity_Gym/black_belt@10,2=10,4"
],
"events": [
{
"id": "gym_exit",
Expand Down
Loading