Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
95a273e
BDSP AutoStory: steps declare the pose certainty they need; 00.05 sta…
dayfine Nov 11, 2026
16e3ed3
BDSP AutoStory: 00.05 starts on (46, 58) and taps 4 north onto the plaza
dayfine Nov 12, 2026
9ced829
BDSP AutoStory: stop the wanderer talk when a row step leaves the row
dayfine Nov 12, 2026
cf0df96
BDSP AutoStory: wander_row_step in Events.h, not Talks.h (header symb…
dayfine Nov 12, 2026
1345efc
Pokemon Navigation: one movement mechanics table per game
dayfine Nov 12, 2026
d1359c7
Pokemon Navigation: MoveMechanics tests from a table of cases
dayfine Nov 12, 2026
fa4c284
BDSP AutoStory: 00.05b ends against the Poketch Company sign, 00.05c …
dayfine Nov 12, 2026
dbe09a7
Pokemon Navigation: connected maps, one world type for BDSP and FRLG
dayfine Nov 12, 2026
b64cd70
Pokemon Navigation: connected maps tests take an expectation struct; …
dayfine Nov 12, 2026
26e503d
Merge remote-tracking branch 'origin/nav/connected-maps' into bdsp/co…
dayfine Nov 12, 2026
a0991bc
Pokemon Navigation: ConnectedMaps::size()
dayfine Nov 12, 2026
2eeee6e
Merge branch 'nav/connected-maps' into bdsp/connected-maps
dayfine Nov 12, 2026
780b97b
PokemonBDSP AutoStory: story worlds also as connected maps
dayfine Nov 12, 2026
40f1547
PokemonBDSP AutoStory: connected_maps() as a free function; flatter e…
dayfine Nov 12, 2026
a24eaee
Pokemon Navigation: robust leg planner, shared by the tile games
dayfine Nov 12, 2026
a2013c8
Merge branch 'nav/robust-leg-planner' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
6d1adb0
PokemonBDSP AutoStory: plan robust routes with the shared robust leg …
dayfine Nov 12, 2026
7c954ac
Pokemon Navigation: robust leg planner: document helpers; tests as in…
dayfine Nov 12, 2026
6f088c1
Merge branch 'nav/robust-leg-planner' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
f471625
BDSP AutoStory: 00.05c collects missing coupons and checks the Poketc…
dayfine Nov 12, 2026
0cfc9c1
BDSP AutoStory: shorter make_bdsp_actions and SimExecutor::run (code …
dayfine Nov 12, 2026
a17a983
Merge origin/nav/grid-story-steps into nav/move-mechanics
dayfine Nov 12, 2026
e5e09c2
Merge origin/nav/grid-story-steps into nav/connected-maps
dayfine Nov 12, 2026
4206f33
Merge origin/nav/connected-maps into nav/robust-leg-planner
dayfine Nov 12, 2026
27e7ac5
Merge origin/bdsp/autostory-v4 into bdsp/connected-maps
dayfine Nov 12, 2026
057a7ee
Merge origin/bdsp/connected-maps into bdsp/robust-leg-planner
dayfine Nov 12, 2026
c567cbb
BDSP AutoStory: Jubilife routes keep out of wander zones; a held-up w…
dayfine Nov 12, 2026
5975bb0
BDSP AutoStory: wait for the Mart clown on column 56; 01.08's last le…
dayfine Nov 12, 2026
4ad67e3
BDSP AutoStory: talk_to_npc() moves to PlannedTalk.cpp (code health)
dayfine Nov 12, 2026
0136575
Merge origin/bdsp/center-run-settle (#375, consolidated stage) into b…
dayfine Nov 12, 2026
d2d3467
BDSP AutoStory: the story sim plays wait_for_wanderer; Jubilife's clo…
dayfine Nov 12, 2026
e48e834
BDSP AutoStory: the sim's wander wait talks to a clown on his spawn; …
dayfine Nov 12, 2026
dfe064a
Merge branch 'nav/grid-story-steps' into nav/move-mechanics
dayfine Nov 12, 2026
78abee2
Pokemon Navigation: step taps per gait; default member values; failur…
dayfine Nov 12, 2026
91ea114
Merge branch 'nav/grid-story-steps' into nav/connected-maps
dayfine Nov 12, 2026
7f63e8b
Merge branch 'nav/grid-story-steps' into nav/move-mechanics
dayfine Nov 12, 2026
ed5f36e
Merge branch 'nav/connected-maps' into nav/robust-leg-planner
dayfine Nov 12, 2026
371bd8d
Pokemon Navigation: ConnectedMaps refuses temporaries, checks map ind…
dayfine Nov 12, 2026
1ca9ec4
Pokemon Navigation: robust leg planner tests as data; open_error_per …
dayfine Nov 12, 2026
bb345f7
Merge branch 'bdsp/autostory-v4' into bdsp/connected-maps
dayfine Nov 12, 2026
0ec0e42
Merge branch 'nav/connected-maps' into bdsp/connected-maps
dayfine Nov 12, 2026
d76aa60
BDSP AutoStory: connected-world test checks for a missing plan world;…
dayfine Nov 12, 2026
ae4f0de
Merge branch 'bdsp/connected-maps' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
bae6892
Merge branch 'nav/robust-leg-planner' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
96f8ad7
BDSP AutoStory: a field-count guard on the copy into the shared robus…
dayfine Nov 12, 2026
213ceb7
Pokemon Navigation: stale-place cases carry their expectation (code h…
dayfine Nov 12, 2026
ffdf9ae
Merge branch 'nav/connected-maps' into nav/robust-leg-planner
dayfine Nov 12, 2026
9f6cf8e
BDSP maps: pin PokemonSimulation 438b672; the Poketch Company clown w…
dayfine Nov 12, 2026
c6eaa10
Merge branch 'bdsp/connected-maps' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
1ef39dc
Merge branch 'nav/robust-leg-planner' into bdsp/robust-leg-planner
dayfine Nov 12, 2026
60a1a5b
Merge branch 'nav/connected-maps' into bdsp/connected-maps
dayfine Nov 12, 2026
aad90b2
BDSP AutoStory: the route sweep walks at the player's pace
dayfine Nov 12, 2026
9038665
BDSP AutoStory: in the route sweep a walk to a wall never overshoots
dayfine Nov 12, 2026
2df832f
BDSP AutoStory: the route sweep's console fake has four test knobs (c…
dayfine Nov 12, 2026
2e9774d
Merge origin/bdsp/center-run-settle (#375: sim_ms_per_tile; LEGS step…
dayfine Nov 12, 2026
9b22df6
BDSP AutoStory walk: someone in the way who talks is the blocker (red)
dayfine Nov 12, 2026
a4daa26
BDSP AutoStory walk: mark someone in the way who talks, and go round
dayfine Nov 12, 2026
497bc02
Merge origin/bdsp/center-run-settle (#375) into bdsp/start-certainty
dayfine Nov 12, 2026
0ac724b
Merge #402 nav/move-mechanics into nav/grid-story-steps
dayfine Nov 12, 2026
29841ed
Merge origin/nav/grid-story-steps into nav/connected-maps
dayfine Nov 12, 2026
138d27f
Merge branch 'nav/connected-maps' into nav/robust-leg-planner
dayfine Nov 12, 2026
8d9b47f
BDSP AutoStory walk: a marked talker is no wall for the replan (red)
dayfine Nov 12, 2026
14b2b77
BDSP AutoStory walk: someone who talked is marked as no wall
dayfine Nov 12, 2026
694414f
BDSP AutoStory walk: the marked-talker fix within the file's line budget
dayfine Nov 12, 2026
7e357d0
Merge #412 nav/robust-leg-planner into nav/connected-maps
dayfine Nov 12, 2026
31df61e
Merge #413 bdsp/robust-leg-planner into bdsp/connected-maps
dayfine Nov 12, 2026
7e9cd2a
BDSP AutoStory 00.05c: the walk from the street keeps off the Wonder …
dayfine Nov 12, 2026
6feb3d1
BDSP AutoStory: a route step's "avoid" keeps the walk off ground the …
dayfine Nov 12, 2026
8d8a3ee
Merge origin/bdsp/connected-maps (#411, #413: shared robust leg plann…
dayfine Nov 12, 2026
e2f4e3a
Robust leg planner: held open legs and per_open_wild_tile (off by def…
dayfine Nov 12, 2026
6bf2fec
Robust leg planner tests: held legs refused at grass, wander and ledg…
dayfine Nov 12, 2026
b258693
Merge #428 nav/robust-held-legs into bdsp/start-certainty
dayfine Nov 12, 2026
441b063
BDSP maps: pin PokemonSimulation 4b886bb; Route 203's youngster stays…
dayfine Nov 13, 2026
b32b47a
BDSP maps: back to PokemonSimulation 438b672 for now; 4b886bb strands…
dayfine Nov 13, 2026
24b7d74
Revert "BDSP maps: back to PokemonSimulation 438b672 for now; 4b886bb…
dayfine Nov 13, 2026
c90722d
BDSP walk: someone who never moves is a wall anchor for holds and rec…
dayfine Nov 13, 2026
09040f5
BDSP walk: a still person who talks when bumped (Mom) is no wall anchor
dayfine Nov 13, 2026
9c92982
BDSP AutoStory: 00.04 into_moms_call back to 2550 ms (Mom is no ancho…
dayfine Nov 13, 2026
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 @@ -33,9 +33,12 @@
#include "NintendoSwitch/Programs/Typewriter/NintendoSwitch_Typewriter_Tests.h"
#include "NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.h"

#include "Pokemon/Navigation/Pokemon_ConnectedMaps_Tests.h"
#include "Pokemon/Navigation/Pokemon_LegPlanner_Tests.h"
#include "Pokemon/Navigation/Pokemon_RobustLegPlanner_Tests.h"
#include "Pokemon/Navigation/Pokemon_LegWalker_Tests.h"
#include "Pokemon/Navigation/Pokemon_MapData_Tests.h"
#include "Pokemon/Navigation/Pokemon_MoveMechanics_Tests.h"
#include "Pokemon/Navigation/Pokemon_RouteLog_Tests.h"
#include "Pokemon/Navigation/Pokemon_RouteScorer_Tests.h"
#include "Pokemon/Navigation/Pokemon_RuntimeMap_Tests.h"
Expand Down Expand Up @@ -79,9 +82,12 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){
OCR::add_tests(ret);
Kernels::add_tests(ret);
Pokemon::add_tests_LegPlanner(ret);
Pokemon::add_tests_RobustLegPlanner(ret);
Pokemon::add_tests_LegWalker(ret);
Pokemon::add_tests_WallRecovery(ret);
Pokemon::add_tests_MapData(ret);
Pokemon::add_tests_ConnectedMaps(ret);
Pokemon::add_tests_MoveMechanics(ret);
Pokemon::add_tests_RuntimeMap(ret);
Pokemon::add_tests_RouteLog(ret);
Pokemon::add_tests_RouteScorer(ret);
Expand Down
86 changes: 86 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryCertainty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* Story Certainty
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <format>
#include "Pokemon_BuiltinStoryActions.h"
#include "Pokemon_StoryStepExecutor.h"
#include "Pokemon_StoryCertainty.h"

namespace PokemonAutomation{
namespace Pokemon{


namespace{

StoryCertainty kind_certainty(StoryStepKind kind){
switch (kind){
case StoryStepKind::ROUTE:
return {PoseCertainty::TILE, PoseEnd::WALKED};
case StoryStepKind::LEGS:
return {PoseCertainty::SET, PoseEnd::KEEPS};
case StoryStepKind::STEP:
case StoryStepKind::HEAL:
return {PoseCertainty::TILE, PoseEnd::DECLARED};
case StoryStepKind::TALK:
return {PoseCertainty::TILE, PoseEnd::KEEPS};
case StoryStepKind::NEW_GAME:
return {PoseCertainty::UNKNOWN, PoseEnd::DECLARED};
default:
return {PoseCertainty::UNKNOWN, PoseEnd::KEEPS};
}
}

} // namespace


StoryCertainty story_step_certainty(const StoryStep& step, std::span<const StoryActionSpec> specs){
StoryCertainty out = kind_certainty(step.kind);
if (const StoryActionSpec* spec = find_story_action(specs, step.kind, step.action)){
out.needs = spec->certainty.value_or(out).needs;
out.leaves = spec->certainty.value_or(out).leaves;
}
return out;
}

PoseCertainty certainty_after(const StoryStep& step, PoseEnd leaves, PoseCertainty before){
switch (leaves){
case PoseEnd::WALKED:
return PoseCertainty::TILE;
case PoseEnd::DECLARED:
return step.pose_after ? pose_of(*step.pose_after).certainty : before;
case PoseEnd::GAME_SET:
return step.pose_after ? PoseCertainty::SET : before;
case PoseEnd::KEEPS:
// A declared end the step does not walk onto is where the game
// leaves us, unseen.
return step.pose_after ? PoseCertainty::SET : before;
}
return before;
}

PoseCertainty start_certainty(const StoryCheckpoint& data){
return data.start ? PoseCertainty::SET : PoseCertainty::UNKNOWN;
}

std::vector<std::string> certainty_gaps(const StoryCheckpoint& data, std::span<const StoryActionSpec> specs){
std::vector<std::string> gaps;
PoseCertainty have = start_certainty(data);
for (size_t c = 0; c < data.steps.size(); c++){
const StoryStep& step = data.steps[c];
const StoryCertainty certainty = story_step_certainty(step, specs);
if (!certainty_covers(have, certainty.needs)){
gaps.push_back(std::format("{} step {} {}: needs {}, has {}",
data.id, c + 1, step.name, certainty_name(certainty.needs), certainty_name(have)));
}
have = certainty_after(step, certainty.leaves, have);
}
return gaps;
}



} // namespace Pokemon
} // namespace PokemonAutomation
46 changes: 46 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryCertainty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* Story Certainty
*
* From: https://github.com/PokemonAutomation/
*
* How sure of the player's tile each step must be when it starts, and how
* sure it leaves the run. A step that needs more than the steps before it
* guarantee walks from a guess: 00.05's route planned open legs from its
* save's declared start, a tile the save was never seen on, and walked
* into a building (lab-B 2026-11-11 15:22).
*
*/

#ifndef PokemonAutomation_Pokemon_StoryCertainty_H
#define PokemonAutomation_Pokemon_StoryCertainty_H

#include <span>
#include <string>
#include <vector>
#include "Pokemon/AutoStory/Types/Pokemon_StoryActionSpec.h"
#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckpoint.h"

namespace PokemonAutomation{
namespace Pokemon{


// What a step needs at its start and leaves at its end: the action's spec
// where it says, else its kind's default (a route needs one tile and
// leaves one; a scene needs nothing and leaves its declared end unseen).
StoryCertainty story_step_certainty(const StoryStep& step, std::span<const StoryActionSpec> specs);

// How sure the run is after `step` succeeds from `before`.
PoseCertainty certainty_after(const StoryStep& step, PoseEnd leaves, PoseCertainty before);

// How sure a checkpoint is at its start: SET from its save (its declared
// start was never seen on the screen), UNKNOWN without one.
PoseCertainty start_certainty(const StoryCheckpoint& data);

// Each step of `data` that needs a surer pose than the steps before it
// leave, as "00.05 step 1 to_the_center: needs TILE, has SET".
std::vector<std::string> certainty_gaps(const StoryCheckpoint& data, std::span<const StoryActionSpec> specs);



} // namespace Pokemon
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>
#include "Pokemon_StoryActionArg.h"
#include "Pokemon_StoryStepKind.h"
#include "Pokemon/AutoStory/Pokemon_StoryPose.h"

namespace PokemonAutomation{
namespace Pokemon{
Expand All @@ -31,6 +32,21 @@ struct StoryArgSpec{
std::string why;
};

// What an action leaves the pose as.
enum class PoseEnd{
KEEPS, // as sure as before (a talk; taps counted from where we were)
WALKED, // walked onto its target and checked there: one tile
DECLARED, // its declared end, reached on walls or through a door
GAME_SET, // where a scene or battle leaves us: declared, not seen
};

// How sure of the player's tile an action must be at its start, and what
// it leaves (Pokemon_StoryCertainty.h).
struct StoryCertainty{
PoseCertainty needs = PoseCertainty::UNKNOWN;
PoseEnd leaves = PoseEnd::KEEPS;
};

// An action: the kind of step it does, its name and the args it takes.
struct StoryActionSpec{
StoryStepKind kind = StoryStepKind::GAME;
Expand All @@ -40,6 +56,8 @@ struct StoryActionSpec{
// keyboard, a battle AI): the engine refuses it on any other backend
// (StoryBackendKind) with the failure "console_only".
bool console_only = false;
// None: its kind's default (story_step_certainty()).
std::optional<StoryCertainty> certainty = std::nullopt;
};

// Each way `args` don't fit `spec`: a key it doesn't name, a value of
Expand Down
153 changes: 153 additions & 0 deletions SerialPrograms/Source/Pokemon/Navigation/Pokemon_ConnectedMaps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/* Connected Maps
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <algorithm>
#include <format>
#include "Common/Cpp/Exceptions.h"
#include "Pokemon_ConnectedMaps.h"

namespace PokemonAutomation{
namespace Pokemon{
namespace{

// The tile of `to` that `connection` on `side` leads onto from `here`:
// the edge row or column, shifted by the connection's offset.
TilePos edge_entry(const TilePos& here, Direction side, const MapConnection& connection, const Grid<TileKind>& to){
TilePos point{here.x - connection.offset, here.y - connection.offset};
switch (side){
case Direction::NORTH:
point.y = to.height - 1;
break;
case Direction::SOUTH:
point.y = 0;
break;
case Direction::WEST:
point.x = to.width - 1;
break;
case Direction::EAST:
point.x = 0;
break;
}
return point;
}

} // namespace


const MapData& ConnectedMaps::map(size_t index) const{
if (index >= m_maps->size()){
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION,
std::format("Map index {} is past the {} connected maps.", index, m_maps->size()));
}
return (*m_maps)[index];
}

std::optional<size_t> ConnectedMaps::find(std::string_view name) const{
for (size_t index = 0; index < m_maps->size(); index++){
if ((*m_maps)[index].name == name){
return index;
}
}
return std::nullopt;
}

std::optional<MapPlace> ConnectedMaps::warp_arrival(const MapWarp& warp) const{
if (!warp.to){
return std::nullopt;
}
const std::optional<size_t> destination = find(warp.to->map);
if (!destination){
return std::nullopt;
}
const MapData& to = map(*destination);
const auto arrival = to.points.find(warp.to->point);
if (arrival == to.points.end()){
return std::nullopt;
}
return MapPlace{*destination, arrival->second};
}

std::optional<MapPlace> ConnectedMaps::across_edge(const MapPlace& from, Direction side) const{
for (const MapConnection& connection : map(from.map).connections){
if (connection.side != side){
continue;
}
const std::optional<size_t> destination = find(connection.to_map);
if (!destination){
continue;
}
const Grid<TileKind>& to = map(*destination).tiles;
const TilePos point = edge_entry(from.tile, side, connection, to);
if (to.contains(point)){
return MapPlace{*destination, point};
}
}
return std::nullopt;
}

std::optional<MapPlace> ConnectedMaps::neighbour(const MapPlace& from, Direction direction) const{
const TilePos ahead = from.tile.next(direction);
if (map(from.map).tiles.contains(ahead)){
return MapPlace{from.map, ahead};
}
return across_edge(from, direction);
}


namespace{

// The side of `a` that `b` touches, and the offset of `b`'s tiles along it,
// if their rectangles on the world grid meet along a side.
std::optional<MapConnection> touching(const MapData& a, const MapData& b){
const TilePos pa = a.world->offset;
const TilePos pb = b.world->offset;
const int aw = a.tiles.width;
const int ah = a.tiles.height;
const int bw = b.tiles.width;
const int bh = b.tiles.height;
const bool columns_overlap = pa.x < pb.x + bw && pb.x < pa.x + aw;
const bool rows_overlap = pa.y < pb.y + bh && pb.y < pa.y + ah;
if (columns_overlap && pb.y + bh == pa.y){
return MapConnection{Direction::NORTH, b.name, pb.x - pa.x};
}
if (columns_overlap && pb.y == pa.y + ah){
return MapConnection{Direction::SOUTH, b.name, pb.x - pa.x};
}
if (rows_overlap && pb.x + bw == pa.x){
return MapConnection{Direction::WEST, b.name, pb.y - pa.y};
}
if (rows_overlap && pb.x == pa.x + aw){
return MapConnection{Direction::EAST, b.name, pb.y - pa.y};
}
return std::nullopt;
}

} // namespace

void connect_by_world(std::vector<MapData>& maps){
for (MapData& a : maps){
for (const MapData& b : maps){
if (&a == &b || !a.world || !b.world || a.world->name != b.world->name){
continue;
}
const std::optional<MapConnection> connection = touching(a, b);
if (!connection){
continue;
}
const bool joined = std::ranges::any_of(a.connections, [&](const MapConnection& existing){
return existing.to_map == b.name;
});
if (!joined){
a.connections.push_back(*connection);
}
}
}
}



} // namespace Pokemon
} // namespace PokemonAutomation
Loading