Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
ac1ef0b
BDSP AutoStory: align Oreburgh Mine maps, corridor legs, and Floaroma…
dayfine Nov 7, 2026
fc56a72
BDSP AutoStory: test real Oreburgh Mine corridor runs to and back in …
dayfine Nov 7, 2026
201bd0e
BDSP AutoStory: bound hallway mine exit run and support daylight tran…
dayfine Nov 7, 2026
4943731
BDSP AutoStory: derive door run duration dynamically from map tile di…
dayfine Nov 8, 2026
7b81971
Merge origin/bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 8, 2026
6610645
Merge remote-tracking branch 'origin/bdsp/sim' into bdsp/autostory-mi…
dayfine Nov 8, 2026
9b1832c
Align SourceFiles.cmake with origin/bdsp/sim
dayfine Nov 8, 2026
9cbf90a
Adopt origin/bdsp/sim StoryWalkSteps
dayfine Nov 8, 2026
1c6f6a7
Merge remote-tracking branch 'origin/bdsp/sim' into bdsp/autostory-mi…
dayfine Nov 8, 2026
e6209f2
BDSP AutoStory: update 01.03 coal room leg counts for new map alignment
dayfine Nov 8, 2026
99fa090
Merge remote-tracking branch 'origin/bdsp/sim' into bdsp/autostory-mi…
dayfine Nov 8, 2026
3d1b067
Merge remote-tracking branch 'origin/bdsp/sim' into bdsp/autostory-mi…
dayfine Nov 8, 2026
9a2eb0a
BDSP AutoStory: avoid wandering NPC hazards and simulate wandering NPCs
dayfine Nov 8, 2026
941de60
Merge remote-tracking branch 'origin/bdsp/sim' into bdsp/autostory-mi…
dayfine Nov 8, 2026
5a16268
BDSP AutoStory: soft cost penalty for wandering hazards and wall chec…
dayfine Nov 8, 2026
f9d253b
BDSP AutoStory: tag late encounter origin unknown only when chunks mo…
dayfine Nov 8, 2026
a0d2204
BDSP walk: do not mark origin as preceding leg when movement moved ch…
dayfine Nov 8, 2026
e50873f
BDSP AutoStory: enter Oreburgh's Pokemon Center reliably
dayfine Nov 8, 2026
051d6c3
BDSP AutoStory: heal at Oreburgh's Center before the mine (01.02b)
dayfine Nov 8, 2026
1566313
Merge origin/bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 8, 2026
f30a03b
BDSP AutoStory: route to below the Center's door, not the doorstep
dayfine Nov 8, 2026
0062d0b
BDSP AutoStory: clip the walk to Roark against his rock and the wall
dayfine Nov 8, 2026
27b12d9
BDSP AutoStory: keep the recovery-walk tests on their own mine walk
dayfine Nov 8, 2026
76635b9
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 8, 2026
540642f
BDSP AutoStory: Barry stands on Oreburgh's Gym doorstep from the welc…
dayfine Nov 8, 2026
4abd21d
BDSP AutoStory: plan Oreburgh's routes round Barry on the Gym's doorstep
dayfine Nov 8, 2026
be3ea5a
BDSP AutoStory: keep the story sim tests under the file-length limit
dayfine Nov 8, 2026
d3dc2f9
Revert "BDSP AutoStory: plan Oreburgh's routes round Barry on the Gym…
dayfine Nov 8, 2026
b8f7b1e
BDSP AutoStory: 01.02b talks to Barry before the Center, as 01.03 did…
dayfine Nov 8, 2026
c66cb55
BDSP AutoStory: story sim test for a dark frame early in the mine's e…
dayfine Nov 8, 2026
04f84ec
BDSP AutoStory: a door run ignores dark before 85% of its way to the …
dayfine Nov 8, 2026
bca0742
BDSP AutoStory: the mine hall corridor test runs on the grid sim; mov…
dayfine Nov 8, 2026
4d2c7a5
BDSP AutoStory: red tests for Oreburgh's Center read from its counter
dayfine Nov 8, 2026
e5388cc
BDSP AutoStory: a Pokemon Center's inside reads at the nurse's counte…
dayfine Nov 8, 2026
be57db1
BDSP AutoStory: 01.03 lines up below Oreburgh's Center against the wa…
dayfine Nov 8, 2026
f0280b9
BDSP AutoStory: grid sim test for 01.03's approach below Oreburgh's C…
dayfine Nov 8, 2026
4f13c19
BDSP AutoStory: 01.03 crosses Roark's room against the walls, not on …
dayfine Nov 8, 2026
7c617c1
BDSP AutoStory: grid sim test for 01.03 across Roark's room from a ro…
dayfine Nov 8, 2026
24d7fe3
BDSP AutoStory: the old crate cut runs from where down_column_29 leav…
dayfine Nov 8, 2026
53fbfca
BDSP AutoStory: 01.03 taps across Roark's room to his corner
dayfine Nov 8, 2026
6c65b1b
BDSP AutoStory: a wild battle on counted taps re-plans to the step's end
dayfine Nov 8, 2026
2055177
BDSP AutoStory: 01.03 routes to the street west of the Center, not be…
dayfine Nov 8, 2026
c0f8af5
BDSP AutoStory: 01.03 comes out of the mine on the decomp's warp tile
dayfine Nov 8, 2026
77bcef9
BDSP AutoStory: the mine-exit test maps names through story_to_world …
dayfine Nov 8, 2026
f29a4d4
BDSP AutoStory: the mine-exit test is a table of cases, old steps exp…
dayfine Nov 8, 2026
65e145a
BDSP AutoStory: a battle on a route leg's first input re-plans too
dayfine Nov 8, 2026
f2567a2
BDSP AutoStory: a battle on a counted leg's first tap re-plans to the…
dayfine Nov 8, 2026
08c9378
BDSP AutoStory: the mine-exit test wants 01.03 straight up column 46,…
dayfine Nov 8, 2026
0738cd5
BDSP AutoStory: 01.03 runs straight north up column 46 to the Center
dayfine Nov 8, 2026
d71d6b5
BDSP AutoStory 01.04: drop the brightness check for starting in the gym
dayfine Nov 8, 2026
aa19dfa
BDSP AutoStory 01.04: 21 taps from below the Center's door to the Gym's
dayfine Nov 8, 2026
0116fe8
BDSP AutoStory 01.04: take the Gym's taps from the map's doors
dayfine Nov 8, 2026
4fc6701
BDSP AutoStory: settle after a trainer battle before the Potion
dayfine Nov 8, 2026
30f5f33
BDSP AutoStory: settle after a trainer battle in its own function
dayfine Nov 8, 2026
b7b7443
BDSP AutoStory: running out of Potions ends the doses, not the run
dayfine Nov 8, 2026
02efdf9
BDSP AutoStory: log banner reads while waiting for a map's banner
dayfine Nov 8, 2026
81c993a
BDSP AutoStory: keep a frame every 500 ms while waiting for a banner
dayfine Nov 8, 2026
e3c811e
BDSP AutoStory: banner-wait frame and log helpers
dayfine Nov 8, 2026
95b2960
BDSP AutoStory 01.05: run into the Oreburgh Gate from Barry's spot
dayfine Nov 8, 2026
0e2630d
Merge remote-tracking branch 'origin/bdsp/sim' into HEAD
dayfine Nov 9, 2026
013c4bd
BDSP AutoStory: routes stop short of warps; a dim cave floor is not a…
dayfine Nov 9, 2026
71c3ed1
BDSP AutoStory: a wall leg that never moved waits, then plans from it…
dayfine Nov 9, 2026
5493a9e
BDSP AutoStory: routes never run along a wander zone; short wall legs…
dayfine Nov 9, 2026
8eece71
BDSP AutoStory: recovery picks the cheapest whole walk; 01.10 runs in…
dayfine Nov 9, 2026
e686375
BDSP: test portability fix + #263 (01.03 authored JSON) into the BDSP…
dayfine Nov 9, 2026
779ec11
BDSP AutoStory: 01.11 walks to the field's edge before the old woman …
dayfine Nov 9, 2026
352b050
BDSP AutoStory: fight a wild battle the game will not let the walker …
dayfine Nov 9, 2026
6dc9f89
BDSP AutoStory: route-plan golden + console-failure sim cases (#281) …
dayfine Nov 9, 2026
0192d6b
BDSP AutoStory: a warp is a fade or a banner; walks report warps (#26…
dayfine Nov 9, 2026
24384de
BDSP AutoStory: talk-over from events, one rule for scenes and post-b…
dayfine Nov 9, 2026
0d35443
AutoStory: shared screen events and judges; BDSP and FRLG adapters (#…
dayfine Nov 9, 2026
9246496
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
99daff0
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
fc2f952
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
27500ec
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
c8d6113
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
4e597bc
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
55101c3
CI: pin PokemonSimulation to 913a5e3 (mine walk to (46,57))
dayfine Nov 9, 2026
8204d6f
Merge origin/bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
287da6b
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
d00f00a
BDSP AutoStory: console and sim executors bind one story action table
dayfine Nov 9, 2026
52a71d6
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
19d318e
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
56ecb74
BDSP AutoStory: door runs and tap steps take a fade's hold unseen, on…
dayfine Nov 9, 2026
126630f
BDSP AutoStory: a comment for each fade rule
dayfine Nov 9, 2026
4cbd155
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
4a0a0dc
Merge bdsp/sim (merge of #122 b3aa69e19) into bdsp/autostory-mine-flo…
dayfine Nov 9, 2026
eb97a89
Merge bdsp/walk-v4 (timed walk events, open-leg battle placement) int…
dayfine Nov 9, 2026
c1e814d
Merge bdsp/sim (sim records tap battles' screen events) into bdsp/aut…
dayfine Nov 9, 2026
78e859f
BDSP: sim test for a wild battle on an open leg's taps, placed by its…
dayfine Nov 9, 2026
1c8b630
BDSP: a story leg's battle is placed by its screen events
dayfine Nov 9, 2026
dd31b37
Merge bdsp/walk-v4 (open-leg battles placed by screen events) into bd…
dayfine Nov 9, 2026
de79d06
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
b77c917
BDSP AutoStory: clear interrupts between story steps
dayfine Nov 9, 2026
2518d84
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
963e743
BDSP AutoStory: the Starly battle's opening is the battle step's
dayfine Nov 9, 2026
7f0b90f
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 9, 2026
9f174fa
BDSP AutoStory sim: 00.03 from each tile Rowan's scene ends on
dayfine Nov 9, 2026
ddb6fd0
BDSP AutoStory: 00.03 measures which row Rowan's scene left us on
dayfine Nov 9, 2026
2d3729d
BDSP AutoStory: test that every resource it loads is in Resources
dayfine Nov 9, 2026
d0ade1f
BDSP AutoStory sim: sweep scene end poses and battle openings over ev…
dayfine Nov 9, 2026
0d79b7b
BDSP AutoStory sim: fault sweep cases as a table of designated cases
dayfine Nov 9, 2026
03006cd
BDSP AutoStory sim: sweep only scenes that moved the player, round ev…
dayfine Nov 9, 2026
0cab275
BDSP AutoStory: 00.03 walks east into Rowan's scene
dayfine Nov 9, 2026
6b96cc6
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 9, 2026
aa9ad2c
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip (wait for a batt…
dayfine Nov 9, 2026
6647afa
BDSP AutoStory sim: a battle's opening shows its battle; sweep expect…
dayfine Nov 9, 2026
7045442
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip (scene ends afte…
dayfine Nov 9, 2026
ad99f1e
BDSP AutoStory 00.03: out of the house from Mom's proven scene end
dayfine Nov 9, 2026
9bea71f
BDSP AutoStory: keep the door step under the function limit
dayfine Nov 9, 2026
a6e1e0b
BDSP AutoStory sim: a fade looks like BDSP's eyes see it; Mom's closi…
dayfine Nov 9, 2026
ec6c089
BDSP AutoStory: route, then run into a scene until its dialogue
dayfine Nov 9, 2026
69e18b5
BDSP AutoStory sim: the run into Sandgem's cases as their own tests
dayfine Nov 9, 2026
47198eb
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip: a step on the S…
dayfine Nov 9, 2026
bd52102
BDSP AutoStory: look for the Switch HOME menu before each step
dayfine Nov 9, 2026
fe2da03
BDSP AutoStory sim: walk east and west slower than the walker's pace
dayfine Nov 9, 2026
2543014
BDSP AutoStory: time a run into a scene at the slowest pace
dayfine Nov 9, 2026
f4a421b
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 9, 2026
662adf8
BDSP AutoStory sim: a wild battle on every pass through tall grass
dayfine Nov 10, 2026
ea5ac8b
BDSP AutoStory: 00.04 to the ledge column by the border sign, clear o…
dayfine Nov 10, 2026
a43a907
BDSP AutoStory: route plans golden for 00.04's walk by the border sign
dayfine Nov 10, 2026
d4db4dd
BDSP AutoStory: rows after 01.02 no longer meet Route 203's Youngster
dayfine Nov 10, 2026
ca67fa7
BDSP AutoStory: 00.04 clips to walls after Mom's scenes
dayfine Nov 10, 2026
905d421
BDSP AutoStory: Mom's heal and hat steps in their own function
dayfine Nov 10, 2026
82f0bfb
BDSP AutoStory: 01.05 clips to walls before the Gate's mouth
dayfine Nov 10, 2026
905488c
BDSP AutoStory: 00.01 clips to Barry's back wall before his stairs
dayfine Nov 10, 2026
7818308
BDSP AutoStory: 01.06 turns up Jubilife's road at its west column
dayfine Nov 10, 2026
246eb21
BDSP AutoStory sim: Mom's call on (6, 9) and early scenes, as tests
dayfine Nov 10, 2026
422aa34
BDSP AutoStory: 00.04 runs into Mom's call on (6, 9); a walk hands an…
dayfine Nov 10, 2026
3e4ea98
BDSP AutoStory sim: a story variable's new value disarms its old trig…
dayfine Nov 10, 2026
ac497f7
BDSP AutoStory sim: the early-scene sweep covers a route, a step onto…
dayfine Nov 10, 2026
eb60b27
BDSP AutoStory: a route before a step onto a scene's trigger hands an…
dayfine Nov 10, 2026
cb8694c
BDSP AutoStory sim: an early scene spends the trigger next to it; the…
dayfine Nov 10, 2026
e3c5489
BDSP AutoStory: code health for the early-scene hand-over
dayfine Nov 10, 2026
8b3a21e
BDSP AutoStory: route bench with a shared route scorer
dayfine Nov 10, 2026
e5fa8bb
BDSP AutoStory sim: Mom's call verify runs as evidence for (6, 9)
dayfine Nov 10, 2026
c3f7bd2
BDSP AutoStory: a leg record per walked leg, and a route diff against…
dayfine Nov 10, 2026
01ed865
BDSP AutoStory leg trace: someone in the way is an interruption; repl…
dayfine Nov 10, 2026
cce3b8b
BDSP AutoStory: planner holds safe open legs, picks plans by scored time
dayfine Nov 10, 2026
ee6a6b6
BDSP AutoStory: read move names in the game's language; safe pick whe…
dayfine Nov 10, 2026
e32f809
BDSP AutoStory route bench: a planned wall stop is not backtracking
dayfine Nov 10, 2026
37c618c
BDSP AutoStory: list the move name dictionary among the files AutoSto…
dayfine Nov 10, 2026
674c442
BDSP AutoStory: pick the fastest passing plan; replans cross grass on…
dayfine Nov 10, 2026
1bfa65d
Route scorer: no game's numbers in the shared header; BDSP passes its…
dayfine Nov 10, 2026
52f08cf
BDSP AutoStory: a timed hold ends within a tile; plans run past and i…
dayfine Nov 10, 2026
3fcb799
BDSP AutoStory: plan choice tries the run variants and one search, no…
dayfine Nov 10, 2026
ad59fbe
BDSP AutoStory: 00.04b finds the Center's door column on walls
dayfine Nov 10, 2026
1485630
BDSP AutoStory: run variants for open legs of 6 tiles or more; plans …
dayfine Nov 10, 2026
4af4e3a
BDSP AutoStory: score a step's plans only when it has another to choose
dayfine Nov 10, 2026
2401cc2
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 10, 2026
a08d4f0
BDSP AutoStory: 00.04's walk into Mom's call targets her trigger
dayfine Nov 10, 2026
d0a27a5
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 10, 2026
6aba166
BDSP AutoStory: run into Mom's call; recoveries leave the grass on walls
dayfine Nov 10, 2026
cfbab3f
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 10, 2026
f846d0b
devtools/maps: leg_trace test reads a one-line route plan
dayfine Nov 10, 2026
ad51d9f
Merge remote-tracking branch 'origin/bdsp/autostory-mine-floaroma-wip…
dayfine Nov 10, 2026
4dcfdf5
Merge pull request #318 from dayfine/bdsp/autostory-move-names
dayfine Nov 10, 2026
c524c7f
Merge pull request #315 from dayfine/bdsp/route-planner-bench
dayfine Nov 10, 2026
2de91e5
Merge bdsp/autostory-mine-floaroma-wip into bdsp/autostory-leg-trace
dayfine Nov 10, 2026
a25e3d1
Merge pull request #316 from dayfine/bdsp/autostory-leg-trace
dayfine Nov 10, 2026
f3dc4f5
Merge branch 'bdsp/sim' into bdsp/autostory-mine-floaroma-wip
dayfine Nov 10, 2026
dd1b481
Migrate BDSP AutoStory mine-floaroma stack to #312 story-steps format
dayfine Nov 10, 2026
440490e
Merge branch 'bdsp/sim' into bdsp/autostory-mine-floaroma-wip
dayfine Nov 10, 2026
eed2300
Merge bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 11, 2026
f24de46
BDSP AutoStory sim: a heal that walks to the nurse during the Center'…
dayfine Nov 11, 2026
5d3d1d9
BDSP AutoStory: settle inside the Center before walking to the nurse
dayfine Nov 11, 2026
eb7eda1
Merge origin/bdsp/sim into bdsp/autostory-mine-floaroma-wip
dayfine Nov 11, 2026
085fc02
BDSP AutoStory: red test, Jubilife Center walk with timed holds overs…
dayfine Nov 11, 2026
523b040
BDSP AutoStory: tap open legs, hold only legs to a wall
dayfine Nov 11, 2026
ac6d6ba
BDSP AutoStory: overshoot sim takes the player tile by reference (cod…
dayfine Nov 11, 2026
2b843cf
Merge origin/bdsp/autostory-v4 into bdsp/autostory-mine-floaroma-wip
dayfine Nov 11, 2026
21a51a7
BDSP AutoStory: action table carries each spec's args; LEGS to_dialog…
dayfine Nov 11, 2026
85b4b7c
BDSP AutoStory: story rows carry #226's C++ table again; 00.03 into_s…
dayfine Nov 11, 2026
521d27b
BDSP AutoStory: action specs fit the function limit (code health)
dayfine Nov 11, 2026
78ad8bd
Merge origin/bdsp/sim (#167, now with #128) into bdsp/autostory-mine-…
dayfine Nov 12, 2026
aaa82fe
BDSP AutoStory: golden lines of a planned route in their own function…
dayfine Nov 12, 2026
18b4254
BDSP AutoStory: one route-walker simulator in the planned-route tests
dayfine Nov 12, 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
40 changes: 40 additions & 0 deletions .github/workflows/cpp-ci-serial-programs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,46 @@ jobs:
operation: prepare
consumer-directory: Arduino-Source

- name: Checkout authored BDSP story simulator
if: startsWith(inputs.os, 'ubuntu') && inputs.run-tests
uses: actions/checkout@v7
with:
repository: dayfine/PokemonSimulation
ref: 913a5e3eaa22865e1aeab52f23c9e23ea7141ced
path: AuthoredStorySource

- name: Replay the authoritative Arduino mine plan
if: startsWith(inputs.os, 'ubuntu') && inputs.run-tests
env:
PYTHONPATH: AuthoredStorySource/src
run: |
python3 - <<'PYTHON'
from pathlib import Path
import hashlib, json, tempfile
from pokesim.story.replay_binding import load_binding
from pokesim.story.replay_cases import read_cases, check_case
from pokesim.story.checkpoint_replay import run
source = Path('AuthoredStorySource').resolve()
folder = source / 'data/story/bdsp-mine-pilot'
native = Path('Arduino-Source/SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/StoryData')
# The Arduino plan is authoritative; bind these exact bytes explicitly.
# The simulator's checked-in plan is only a frozen regression snapshot.
with tempfile.TemporaryDirectory(prefix='.native-story-', dir=source) as temporary:
stage = Path(temporary)
raw = (native / 'bdsp-mine-01.03.plan.json').read_bytes()
(stage / 'plan.json').write_bytes(raw)
profile = json.loads((folder / 'binding.json').read_text())
profile['plan'] = {'file': str((stage / 'plan.json').relative_to(source)),
'sha256': hashlib.sha256(raw).hexdigest()}
(stage / 'binding.json').write_text(json.dumps(profile))
binding = load_binding(stage / 'binding.json', source)
cases = read_cases(folder / 'cases.json')
for case in cases:
check_case(case, run(binding, case['input']))
print(case['id'] + ': current Arduino plan replay passed')
assert len(cases) == 9
PYTHON

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
Expand Down
12 changes: 12 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ pa_pokesim_map_directory(BDSP_MAP_DIRECTORY bdsp "${POKESIM_CONSUMER}" "${POKESI
file(RELATIVE_PATH BDSP_MAP_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}" "${BDSP_MAP_DIRECTORY}")
pa_embed_text_files(SerialProgramsLib "${BDSP_MAP_RESOURCES}"
PokemonBDSP/Programs/AutoStory/Data/PokemonBDSP_AutoStory_Maps.h PokemonAutomation::NintendoSwitch::PokemonBDSP bdsp_map_json)
# TODO: Move JSON syntax preflight into pa_embed_text_files so map and story
# resources share it. Keep game/schema/semantic checks in their native tests.
# Catch JSON syntax errors during a lab build, before static table initialization.
# Native tests still validate the schema, game policy and execution semantics.
file(GLOB BDSP_STORY_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Source/PokemonBDSP/Programs/AutoStory/StoryData/*.json")
foreach(BDSP_STORY_FILE IN LISTS BDSP_STORY_FILES)
file(READ "${BDSP_STORY_FILE}" BDSP_STORY_TEXT)
string(JSON BDSP_STORY_TYPE ERROR_VARIABLE BDSP_STORY_ERROR TYPE "${BDSP_STORY_TEXT}")
if(BDSP_STORY_ERROR OR NOT BDSP_STORY_TYPE STREQUAL "OBJECT")
message(FATAL_ERROR "Invalid authored checkpoint ${BDSP_STORY_FILE}: ${BDSP_STORY_ERROR}")
endif()
endforeach()
pa_embed_text_files(SerialProgramsLib Source/PokemonBDSP/Programs/AutoStory/StoryData
PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryData.h PokemonAutomation::NintendoSwitch::PokemonBDSP bdsp_checkpoint_json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "Pokemon/Navigation/Pokemon_LegWalker_Tests.h"
#include "Pokemon/Navigation/Pokemon_MapData_Tests.h"
#include "Pokemon/Navigation/Pokemon_RouteLog_Tests.h"
#include "Pokemon/Navigation/Pokemon_RouteScorer_Tests.h"
#include "Pokemon/Navigation/Pokemon_RuntimeMap_Tests.h"
#include "Pokemon/Navigation/Pokemon_WallRecovery_Tests.h"
#include "PokemonBDSP/PokemonBDSP_Tests.h"
Expand All @@ -62,7 +63,6 @@ namespace ComputerPrograms{

UnitTestDatabase make_UNIT_TESTS_ALL(){
UnitTestDatabase ret;

add_tests_QtEventThreadPool(ret, GlobalThreadPools::computation_normal());
add_tests_Sockets(ret, GlobalThreadPools::unlimited_normal());
add_tests_BlackBorderDetector(ret);
Expand All @@ -86,6 +86,7 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){
Pokemon::add_tests_MapData(ret);
Pokemon::add_tests_RuntimeMap(ret);
Pokemon::add_tests_RouteLog(ret);
Pokemon::add_tests_RouteScorer(ret);
Pokemon::add_tests_AutoStory(ret);
NintendoSwitch::add_tests_CheckOnlineDetector(ret);
NintendoSwitch::add_tests_FailedToConnectDetector(ret);
Expand Down
267 changes: 267 additions & 0 deletions SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegTrace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
/* Leg Trace
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <charconv>
#include <utility>
#include "Common/Cpp/Json/JsonArray.h"
#include "Common/Cpp/Json/JsonObject.h"
#include "Common/Cpp/Json/JsonValue.h"
#include "Pokemon_LegTrace.h"

namespace PokemonAutomation{
namespace Pokemon{


std::string_view leg_end_kind_name(LegEndKind kind){
switch (kind){
case LegEndKind::OPEN:
return "open";
case LegEndKind::WALL:
return "wall";
case LegEndKind::TILE:
return "tile";
}
return "?";
}

std::string_view leg_end_known_name(LegEndKnown known){
switch (known){
case LegEndKnown::WALL:
return "wall";
case LegEndKnown::FADE:
return "fade";
case LegEndKnown::DIALOGUE:
return "dialogue";
case LegEndKnown::COUNTED:
return "counted";
case LegEndKnown::DEAD_RECKONED:
return "dead_reckoned";
case LegEndKnown::SEEN:
return "seen";
case LegEndKnown::UNKNOWN:
return "unknown";
}
return "?";
}

std::string_view leg_interrupt_name(LegInterrupt interrupt){
switch (interrupt){
case LegInterrupt::WILD_BATTLE:
return "wild_battle";
case LegInterrupt::TRAINER:
return "trainer";
case LegInterrupt::SCENE:
return "scene";
case LegInterrupt::DIALOGUE:
return "dialogue";
case LegInterrupt::BLOCKED:
return "blocked";
}
return "?";
}


namespace{

// [["Route 202", 23, 25], ...]
JsonArray tiles_json(const std::vector<RouteTile>& tiles){
JsonArray out;
for (const RouteTile& tile : tiles){
JsonArray entry;
entry.push_back(tile.map);
entry.push_back((int64_t)tile.pos.x);
entry.push_back((int64_t)tile.pos.y);
out.push_back(std::move(entry));
}
return out;
}

} // namespace

std::string leg_trace_json(const LegRecord& record){

Check warning on line 84 in SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegTrace.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::Pokemon::leg_trace_json( const LegRecord & record): function_lines=26 (advisory above 25, limit 50)
JsonObject out;
out["checkpoint"] = record.checkpoint;
out["event"] = record.event;
out["leg"] = (int64_t)record.leg;
out["dir"] = direction_name(record.plan.direction);
out["tiles"] = (int64_t)record.plan.tiles;
out["end_kind"] = std::string(leg_end_kind_name(record.plan.end_kind));
out["planned_end"] = tiles_json(record.plan.ends);
if (record.moved){
out["moved"] = (int64_t)*record.moved;
}
out["chunks"] = (int64_t)record.chunks;
out["ms"] = record.walked_ms;
out["end"] = tiles_json(record.end);
out["known"] = std::string(leg_end_known_name(record.known));
JsonArray interrupts;
for (LegInterrupt interrupt : record.interrupts){
interrupts.push_back(std::string(leg_interrupt_name(interrupt)));
}
out["interrupts"] = std::move(interrupts);
if (!record.note.empty()){
out["note"] = record.note;
}
return out.dump(-1);
}

std::string leg_trace_line(const LegRecord& record){
return std::string(LEG_TRACE_TAG) + leg_trace_json(record);

Check warning on line 112 in SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegTrace.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
}


namespace{

std::optional<int> parse_int(std::string_view text){
int value = 0;
const auto result = std::from_chars(text.data(), text.data() + text.size(), value);
if (result.ec != std::errc() || result.ptr != text.data() + text.size()){
return std::nullopt;
}
return value;
}

// "Route 202 (23, 25)".
std::optional<RouteTile> parse_route_tile(std::string_view text){
const size_t open = text.rfind(" (");
const size_t comma = text.rfind(", ");
if (open == std::string_view::npos || comma == std::string_view::npos || comma < open || !text.ends_with(")")){
return std::nullopt;
}
const std::optional<int> x = parse_int(text.substr(open + 2, comma - open - 2));
const std::optional<int> y = parse_int(text.substr(comma + 2, text.size() - comma - 3));
if (open == 0 || !x || !y){
return std::nullopt;
}
return RouteTile{std::string(text.substr(0, open)), TilePos{*x, *y}};
}

std::optional<Direction> parse_direction(std::string_view text){
for (Direction direction : ALL_DIRECTIONS){
if (text == direction_name(direction)){
return direction;
}
}
return std::nullopt;
}

} // namespace

std::vector<RouteTile> parse_route_tiles(std::string_view text){
std::vector<RouteTile> out;
while (!text.empty()){
// Each tile ends at its ")"; ", " separates them.
const size_t close = text.find(')');
if (close == std::string_view::npos){
return {};
}
const std::optional<RouteTile> tile = parse_route_tile(text.substr(0, close + 1));
if (!tile){
return {};
}
out.push_back(*tile);
text.remove_prefix(close + 1);
if (text.starts_with(", ")){
text.remove_prefix(2);
}else if (!text.empty()){
return {};
}
}
return out;
}

std::optional<LegPlan> parse_route_leg_line(std::string_view text){

Check warning on line 176 in SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegTrace.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::Pokemon::parse_route_leg_line( std :: string_view text): function_lines=36 (advisory above 25, limit 50)
// "Leg <n>/<m>: <direction> <tiles> (<end>) to <tiles>"
if (!text.starts_with("Leg ")){
return std::nullopt;
}
const size_t colon = text.find(": ");
if (colon == std::string_view::npos){
return std::nullopt;
}
text.remove_prefix(colon + 2);
const size_t space = text.find(' ');
const size_t open = text.find(" (");
const size_t close = text.find(") to ");
if (space == std::string_view::npos || open == std::string_view::npos || close == std::string_view::npos
|| !(space <= open && open < close)){
return std::nullopt;
}
const std::optional<Direction> direction = parse_direction(text.substr(0, space));
const std::optional<int> tiles = parse_int(text.substr(space + 1, open - space - 1));
const std::string_view end = text.substr(open + 2, close - open - 2);
if (!direction || !tiles || *tiles < 0){
return std::nullopt;
}
LegPlan plan{.direction = *direction, .tiles = (size_t)*tiles};
if (end == "to wall"){
plan.end_kind = LegEndKind::WALL;
}else if (end == "warp"){
plan.end_kind = LegEndKind::TILE;
}else if (end == "open"){
plan.end_kind = LegEndKind::OPEN;
}else{
return std::nullopt;
}
plan.ends = parse_route_tiles(text.substr(close + 5));
return plan;
}


void LegTracer::begin_event(const std::string& checkpoint, const std::string& event){
end_event();
m_checkpoint = checkpoint;
m_event = event;
m_legs = 0;
}

void LegTracer::end_event(){
if (m_leg){
end_leg({}, LegEndKnown::UNKNOWN);
}
}

void LegTracer::begin_leg(LegPlan plan){
end_event();
m_leg = LegRecord{.checkpoint = m_checkpoint, .event = m_event, .leg = ++m_legs, .plan = std::move(plan)};
}

void LegTracer::walked(const LegWalk& walk){
if (!m_leg){
return;
}
m_leg->chunks += walk.chunks;
m_leg->walked_ms += walk.walked_ms;
for (size_t i = 0; i < walk.wild_battles; i++){
m_leg->interrupts.push_back(LegInterrupt::WILD_BATTLE);
}
if (walk.tapped){
m_leg->moved = m_leg->moved.value_or(0) + *walk.tapped;
}
}

void LegTracer::interrupted(LegInterrupt interrupt){
if (m_leg){
m_leg->interrupts.push_back(interrupt);
}
}

void LegTracer::end_leg(std::vector<RouteTile> end, LegEndKnown known, std::string note){
if (!m_leg){
return;
}
LegRecord record = std::move(*m_leg);
m_leg.reset();
record.end = std::move(end);
record.known = known;
record.note = std::move(note);
m_emit(leg_trace_line(record));
}



} // namespace Pokemon
} // namespace PokemonAutomation
Loading
Loading