Skip to content

BDSP AutoStory: grid simulation of walks and scenes for unit tests - #167

Closed
dayfine wants to merge 57 commits into
bdsp/autostory-v4from
bdsp/sim
Closed

dayfine wants to merge 57 commits into
bdsp/autostory-v4from
bdsp/sim

Conversation

@dayfine

@dayfine dayfine commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Depends on #128 (base bdsp/autostory-v4); the diff shows only this PR's change.

A grid simulation of the player so walking and scene bugs in BDSP AutoStory show up in unit tests, not only on the Switch.

  • GridSim moves like the console measured: 40–80 ms D-pad taps only turn, 160 ms steps a tile, holds walk to the wall, a 100 ms stick tap moves about 0.6 tile and later D-pad moves keep that offset, doors warp only from their exact column, people block, and trainers' sight lines and coord events stop the walk. The route walker runs on it through GridSimRouteIO.
  • The executor's walking steps (ROUTE, LEGS, STEP, TALK, MASH) move into StoryWalkSteps on a StoryStepIO, so the whole table, 00.00 to 01.11, runs with the program's own steps on the sim, in one run and row by row. Events, battles and shops are stubbed and end where the table says; each row must start where the one before left the player.
  • Scenes start from the maps' coord_events, now BDSP AutoStory maps: the story maps as generated JSON, read through MapData #134's generator output (decomp triggers plus Mom's call), read by story_coord_events(); nothing is hand-added to the JSON here.
  • Detector-miss test (AutoStory simulation: inject timing and placement variance #162): for each door fade and map banner the run looks for (20 fades, 8 banners), reruns its row and the next with it missed; every miss must stop the run in its own step or be got over, never fail later.
  • Exit tests for r75 and r81: a hold that misses the fade goes on past the door, and a banner reads a few tiles into its map. The old walk west out of the Oreburgh Gate ends in Route 203's pond pocket and the old timed walk out of the Ravaged Path on Route 204's cliff, both caught by the end-tile check; the table's tap-to-banner never ends there.

Testing

  • Suites: GridSim and StorySim pass locally, as do the existing AutoStory suites. Reverting earlier fixes fails the new tests: turning with a 100 ms stick tap (r49) misses the Sandgem Center and Jubilife School doors and most of the table's routes, and a talk that does not first turn to the pose's facing (r40) finds nobody beside Mom or the TV station clown.
  • Console: not run; the sim's moves are the ones measured on console B.

Core stage 5: GridSimRouteIO's taps record an encounter's screen events as the console's walk does (record_tap_battle()), at the tap that set it off.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

dayfine and others added 7 commits November 2, 2026 02:03
…n it

GridSim moves a player on the story maps as measured on the console: short
D-pad taps only turn, 160 ms steps a tile, holds walk to the wall, a stick
tap moves part of a tile and the D-pad keeps that offset, doors warp only
from their column, people block and trainers' sight lines stop the walk.
GridSimRouteIO runs the route walker on it.

The executor's walking steps (ROUTE, LEGS, STEP, TALK, MASH) move into
StoryWalkSteps on a StoryStepIO, so the story sim tests run rows 00.04 to
00.05c with the program's own steps on the simulation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The story maps list their coord events ("coord_events": the decomp's
zone_event triggers, from pret/pokeplatinum's events files, and Mom's call
as measured on the console). story_coord_events() reads them, and the
story sim arms each while its story variable holds, so a step onto a
trigger tile starts its scene in the simulation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
v4's change to settle() (15 s of calm overworld when the screen keeps
moving) goes into StoryStepIO.cpp, where #167 moved settle(). v4's battle,
save (saves_in) and make_story_segment changes stay in the executor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
PlayerHouse1F.json: take autostory-v4's decomp tiles and "patches",
keep sim's "coord_events".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The story sim's StoryStepIO can now miss the Nth door fade (run_into_door
reports no fade though the player warped; the settle after it sees none
either, as on the console once the fade is over) or the Nth map banner
(run_until_map). A new test runs 00.04 to 00.05c once per fade and banner
the clean run makes, and requires each miss to be got over or to stop the
run in the step that missed: a later failure means the miss went unseen.

Today all four (3 fades, 1 banner) stop in their own step. A missed fade
costs settle()'s 120 s and a failed attempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
# Conflicts:
#	SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/JubilifeCity.json
#	SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Maps/SandgemTown.json
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 3 commits November 3, 2026 00:06
#128 now has seg01's planned 01.05 to 01.10 (#175) and the shared steps
(#173). Their executor changes go where this branch moved the walking
steps: per-world trainers, the Twins as a pair (ConsoleStoryStepIO::fight),
the "to_banner" tap (StoryStepIO::tap_to_banner), and the 8 s wait for an
answer to a talk (StoryWalkSteps::talk). The story sim taps to the banner
too, and walks a route on the joined world it plans on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The story sim ran only 00.04 to 00.05c. It now runs 00.00 to 01.11, the
whole table and each row alone, with the program's own walking steps;
scenes, events, battles and shops end where the table says. Each row must
start where the row before left the player, and every walking step with a
declared or worked-out end is checked against it in world tiles (a leg out
of Twinleaf ends on Route 201's tiles).

What it needed: the story variables of the coord events the table walks
onto (00.01 to 00.03, 01.01 to 01.07), the houses' stairs as doors, Barry
in Oreburgh's Center door until his lines (01.03), and B running only once
the shoes' scene has given them (Route 201 timed a walk as a run).

A tap or hold through a door or cave mouth that misses the fade now goes
on onto the step's far side, and a banner reads three tiles into its map
("a tile or a few past the border"). The exit tests run r75's and r81's
old open-ended walks that way: they end in Route 203's pond pocket (52, 9)
and on Route 204's cliff (20, 30), and the end-tile check fails them;
the table's taps to the banner never end there, whatever is missed. The
detector-miss test covers the whole table (20 fades, 8 banners), each miss
on its own row and the next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 14 commits November 9, 2026 03:21
GridSimRouteIO's taps now fill WalkResult::events from the leg's first
tap: an encounter is recorded with record_tap_battle() at the tap that
set it off (the one before, for a battle before its tap moved), and the
taps that moved after it are counted, as the console's walk counts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… pose

walk_legs() dereferenced story_to_local() for the leg's end tiles; 00.03's
into_sandgem runs from Route 201 into Sandgem, so the lookup was empty
(libstdc++ assertion on Ubuntu CI, silent UB on macOS libc++). A walk that
ends off its start map now ends where nothing is known, like a walk to a wall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Brings in the nav, walk and action header splits and the core's
outputs-last call sites. Conflicts: StoryExecutor.h and the moved
StorySimulation_Tests.cpp keep this branch's includes, then include
the split headers they use; SourceFiles.cmake lists each file once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine removed this pull request from stack #230 November 11, 2026 03:20
dayfine and others added 2 commits November 11, 2026 07:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Brings #128's 125 commits (StoryRun shell, start gate, sweeps, golden
plans, connected-map legs, read-only story core) under the sim.

Conflicts:
- StoryExecutor.cpp: kept the sim's structure (legs/step/mash delegate to
  m_walks). #128's only change there, reading pose_after's map through
  Pokemon::grid_pose_of() after the core made pose_after a DeclaredPose,
  is applied to the moved code in StoryWalkSteps.cpp.
- Simulation/StorySimulation_Tests.cpp (moved by the sim): the sim's
  include paths plus #128's PlanGolden.h; walk_legs takes #128's
  cross-map version (story_to_local returning a MapTile).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
…floaroma-wip

Plan files: lab/dev-bdsp (8415116, console B's branch) already holds
#128's 2fe00a0, the only #128 commit on these files, and runs this
branch's versions of the five that conflict. That commit is content
(legs rewritten as routes), not a format change, so each takes this
branch's version, byte-identical to lab/dev-bdsp:
- bdsp-00.01, 00.04, 00.04b, 01.11, mine-01.03 .plan.json: ours.
The auto-merged plan changes (00.02, 00.05, 00.05b, 01.02, 01.08: legs
to routes) are the same ones lab/dev-bdsp runs.

Code:
- StoryExecutor.cpp: ours; this branch dispatches walks through
  story_action_table(m_walks, ...), so the sim's forwarders are gone.
- StoryWalkSteps.cpp: ours (already reads pose_after via grid_pose_of,
  plus taps_to_banner, through_already, door_run and one_step).
- PlannedRoute.cpp blocked_open_leg: both, as lab/dev-bdsp has it:
  mark_tiles_past() when nothing moved, then blocked_stop_tiles().
- Simulation/StorySimulation_Tests.cpp: Walked keeps both fields
  (measured, golden).
- PlannedRoute_Tests.cpp: union. Includes merged; #128's SimulatedRouteIO
  and its tests (blocked from several tiles, Jubilife kids, the story
  route fault sweep) added beside this branch's tests. Both branches wrote
  a Jubilife held-overshoot test; this branch's (OvershootingRouteIO,
  running) keeps its name, #128's walking one becomes
  test_jubilife_center_walk_overshoot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
…te-carlo

Brings #128's seam work down through #167 and #226. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
…ro-picks

Brings #128's seam work down through #167 and #226.
Conflict: PokemonBDSP_AutoStory.cpp includes, both NewGame.h (this
branch's IntroPicks) and Actions.h, as lab/dev-bdsp has them.
Semantic: ScreenState gained a field in the base; the language-select
and look-select states pass nullptr for it, as lab/dev-bdsp does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
…tings-lang-free

Brings #128's seam work down through #167 and #226. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
…ttle

Brings #128's seam work down through #167 and #226. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine added a commit that referenced this pull request Nov 12, 2026
Brings #128's seam work down through #167, #226 and #364. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine

dayfine commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Folded into #375, the consolidated BDSP console stage (#167 + #226 + #364 + #375, base bdsp/autostory-v4); this branch stays as its history.

@dayfine dayfine closed this Nov 12, 2026
dayfine added a commit that referenced this pull request Nov 12, 2026
…with #128) into lab/dev-bdsp

Brings #128's seam work (StoryRun shell, start gate, golden plans, fault
sweeps) to console B's branch through #167/#226/#364/#375 and #400.
No plan file changes: every BDSP plan JSON stays as lab/dev-bdsp had it.
Conflicts:
- PlannedRoute_Tests.cpp: theirs. This branch's extra lines were the
  cherry-picked SimulatedRouteIO and its blocked-from-several-tiles case,
  now in SimulatedRoute_Tests.cpp on #375.
- CommonFramework/Main.cpp: keep this branch's cleanup after the
  command-line test mode return (headless runner), with main's PA_SDL
  gamepad tracker stop added to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine deleted the bdsp/sim branch November 13, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant