Repository navigation
AutoStory: story step types and engine (split from #122, layer 1 of 3) - #312
Conversation
The story step vocabulary, the checkpoint builder and executor interface, the variant parser, the shared story-step JSON codec and authored checkpoint envelope, the story run options, and the StoryEvents/ StorySegments additions (changed_nothing, game_not_running), taken as they are at nav/story-steps fd603ca. Screen state and interrupt tracking follow in their own layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ace, spacing Review of #312: - The plain story data types move out of Pokemon_StorySteps.h into Pokemon/AutoStory/Types/ (StoryStepKind, StoryChecks, StoryStep with StoryLeg and StoryItem, StoryCheckpoint). Pokemon_StorySteps.h still includes them, so its users build unchanged; the JSON codec and the run options now include only the types. - StoryStepExecutor is an interface with no data and no protected or private members: begin_attempt(), run() (pure) and holds(). The 15 per-kind virtuals and dispatch_story_step() go: a game dispatches by kind in run(), as the StoryActionTable of the next layer does. The executor's checks level and language go too; nothing read them, and the program passes StoryRunOptions' values to the game's own steps. - Read-only sequence parameters take std::span. - Spacing: header comment blocks, blank lines after includes, around namespaces and between definitions, one statement per line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ta-free executor) # Conflicts: # SerialPrograms/cmake/SourceFiles.cmake
#312's StoryStepExecutor no longer has a virtual per step kind, so a step the table has no action for is unsupported_step(). A binding that still does some kinds itself overrides run_action(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
A step's variant carried its action's arguments as free text ("mart
CeruleanCity_Mart budget=1500 ..."), parsed by each action. Steps now
carry them in `args` (flags, whole numbers, words), which the shared JSON
codec reads and writes; actions declare StoryArgSpecs and a game checks
args against them at load. split_legacy_variant() reads an old variant
into a name and args during the migration; the variant word helpers are
deprecated. Design: docs/design/AutoStory.md section 10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
StoryRangeOptions is the start/end checkpoint dropdowns over one list with the start-before-end check; StoryRunOptions is now that group plus the run policy, with the same keys and public members. Pokemon_StoryLog holds the checkpoint start/attempt/pass/reset lines, event_log_line and a stats counts helper, with no engine dependency; run_checkpoint, run_segment and record_story_stats use it, with unchanged output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
SV reads its end checkpoint after each checkpoint and leaves the end dropdown unlocked during a run; the range group now takes that lock mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Keeps the unit test runner's list short as the stacked layers add suites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
|
||
|
|
||
| // One argument's value: a flag, a whole number or a word. | ||
| using StoryArgValue = std::variant<bool, int64_t, std::string>; |
There was a problem hiding this comment.
is it a StoryArg or StoryActionArg?
There was a problem hiding this comment.
They are the action's arguments (the action is picked by variant), so StoryActionArg(s) reads better. Not renamed yet: it depends on how you want the step redesigned (see the StoryStep thread). Should I rename now?
There was a problem hiding this comment.
Done in 31ddeae: StoryActionArg(s), in Types/Pokemon_StoryActionArg.h (specs in Types/Pokemon_StoryActionSpec.h).
| using StoryArgs = std::map<std::string, StoryArgValue, std::less<>>; | ||
|
|
||
|
|
||
| // The number `key` holds; nothing if absent or not a number. |
There was a problem hiding this comment.
do we really need these helpers?
There was a problem hiding this comment.
FRLG's actions call them about 35 times, mostly story_arg_number and story_arg_text, each in place of a find plus std::get_if. I kept them. Drop them anyway?
There was a problem hiding this comment.
could keep but make them obvious
these are also very general, so maybe should be a map_util
though I think map lookup should generally using _it, so we don't mess up copy vs. reference etc, so maybe being explicit is better
There was a problem hiding this comment.
Done in 31ddeae: the story_arg_* helpers are gone; Pokemon_MapUtil.h has value_at_it()/value_if_at_it() taking the find() iterator, and story_arg() reads a loaded arg.
| TEXT, | ||
| }; | ||
|
|
||
| // An argument an action takes. |
There was a problem hiding this comment.
how static / dynamic is this?
I suppose for built-in actions the schema is uniform, but for game specific actions this needs to be sepcifically defiend -- still, sounds like it can be a config file instead of C++ class. I am trying to see if this is more beneficial to do in C++?
There was a problem hiding this comment.
Fixed per action, at compile time: an action declares its specs next to the C++ code that reads the args, and the game checks every step's args when it loads the table. A config file would hold a second copy of what the code reads. A JSON schema only pays off if PokemonSimulation should check the args before the C++ sees them. Do you want that?
There was a problem hiding this comment.
Kept in C++ as agreed (31ddeae): built-in specs in Pokemon_BuiltinStoryActions, games add theirs; a shared JSON spec file can come later.
There was a problem hiding this comment.
this is deprecated in favor of args, right? can we drop?
There was a problem hiding this comment.
Yes, it's deprecated, but FRLG, BDSP and PLZA still parse old variants with variant_words/name/pair/value/number (dozens of calls in their actions). Dropping it here would break them until their tables move to args. Should I keep it until those PRs have moved, or drop it now and make each game migrate on its next merge?
There was a problem hiding this comment.
evolve all of them - to json with args
There was a problem hiding this comment.
Done in 31ddeae: StoryVariant is deleted; tables move to JSON with args. FRLG, BDSP and PLZA tables have to move before they compile on top.
There was a problem hiding this comment.
this is a prework PR that should go with #45 maybe?
There was a problem hiding this comment.
| // joined: a section's entry i is then story_index(true, i, first of the | ||
| // section). The program keeps it in a function-local static: the options | ||
| // hold a reference. | ||
| template <typename Row> |
There was a problem hiding this comment.
is this part merged upstream?
There was a problem hiding this comment.
No. make_story_select_database() (Pokemon_AutoStorySelect.h) is upstream; story_checkpoint_database() is fork-only, from this PR. It is no longer a template either (e8833b3).
There was a problem hiding this comment.
is it supposed to be shareable - then it should go in a pre-122 PR (45 or like)
…utor, StoryChecks to StoryCheckLevel File moves and path updates only (#312 review): the story-step and authored-checkpoint JSON modules are I/O, so they go under Pokemon/AutoStory/Data/; Pokemon_StorySteps is named for what it holds, the StoryStepExecutor; Types/Pokemon_StoryChecks becomes Pokemon_StoryCheckLevel ahead of the type's rename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
- StoryStepExecutor.h keeps the executor and building checkpoints: tile_pose() and facing_of() are in Pokemon_TilePose (merged from #114), record_story_stats() becomes SegmentReport::story_counts() for record_story_counts(), and build_story_checkpoint() takes an optional PreparedSteps* instead of a second overload. - StoryLog: default arguments instead of overloads; the segment's reload line is segment_reload_line(). - StoryChecks is StoryCheckLevel; names come back as std::string, and GAME_NOT_RUNNING is a std::string_view constant: no char* in new code. - StoryArgType::FLAG is BOOLEAN; story_args_errors() returns every error. - Authored checkpoint JSON: validate_json_fields(), `game`, and an EmbeddedJsonFile alias for the embedded resources. - StoryRunOptions takes the game's languages from the new Pokemon_GameLanguages (generations 8-9, and FireRed/LeafGreen), and the checkpoint dropdown is built from a span of checkpoints without the StoryCheckpointEntry adapter. - Read-only strings and sequences as std::string_view and std::span. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
They build and read a TilePose, so they live with it instead of in the story step executor header (#312 review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
story_args_errors() now returns each error (#312 review); the action table's checkpoint lint reports one problem per error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
- StoryArgs -> StoryActionArg(s) (Types/Pokemon_StoryActionArg.h) and StoryActionSpec (Types/Pokemon_StoryActionSpec.h): typed values (boolean, integer, word, direction, grid pose, legs, words, items), specs with fallbacks and a why line. - StoryStep keeps only the shared fields plus `action` (was `variant`) and `args`; target/direction/legs/fight_wild/yes/may_lose/battles/items are args of the built-in actions (Pokemon_StoryActions.h). - GridPose (Types/) aggregates map, tiles and facing for 2D grids; a step's pose_after and a checkpoint's start use it. - JSON is parsed in one layer: read_story_step() parses args against the action's spec and fills fallbacks; the authored envelope hands its execution object to the game's reader instead of keeping JSON. - Explicit map utils taking the find() iterator (Pokemon_MapUtil.h) replace the story_arg_* helpers; story_arg<T>() reads a loaded arg. - StoryVariant is dropped: tables move to JSON args. - Check levels: TESTING, THOROUGH, DEFAULT, FAST, SPEEDRUN (DEFAULT is the default). - SegmentPolicy drops stop_at_first_failure (attempts 1 does it) and recoveries_per_event (with SegmentHooks::recover); the plain segment types move to Types/Pokemon_StorySegmentTypes.h. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ng gives them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…tions and the segment edits now come from below StoryLog and StoryRangeOptions (with story_checkpoint_database(), which now takes labels) live in the prep PR on #45; StoryEvents' and StorySegments' edits and Types/Pokemon_StorySegmentTypes.h live in #114. This PR keeps story_checkpoint_label() and registers only the engine's own suites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…122's action table Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ySegments edits Moved from #312 per its review: StoryEvents' and StorySegments' changes (StoryLog lines), SegmentPolicy without stop_at_first_failure and recoveries_per_event, and the plain segment types in Types/Pokemon_StorySegmentTypes.h. StoryLog comes from the prep PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
# Conflicts: # SerialPrograms/cmake/SourceFiles.cmake
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
…y loop (#391) # Conflicts: # SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySegments.cpp # SerialPrograms/cmake/SourceFiles.cmake
…o the segment report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss # Conflicts: # SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h # SerialPrograms/cmake/SourceFiles.cmake
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss # Conflicts: # SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySegments.cpp
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_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… run The shared wire cases at PokemonSimulation 866613f (and its main) still use the old pose (certainty/where) and per-kind step fields; since the #312 review the native reader reads steps as an action plus typed args, so every kind case without args failed. The Python reader still checks those cases; the native codec is covered by its own CTest cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… on #312, ScreenEvents case names Conflicts: ScreenEvents_Tests.cpp takes #313's case struct (name outside the input); the story-data README keeps this branch's reader-only text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
Verdict: mergeable on the fork Reviewed SHA: e4ce5af VerdictAPPROVED (comment only): no blocking findings. Four should-fix items below; they can land at the tip or in #332. Scope: blockingNone. should-fix
nit
Dropped: 3 minor items (output-parameter helpers inside the anonymous namespace in PostconditionCheck, positional |
…known (#312 review) checkpoint_end_pose() stopped looking back only at LEGS, so a STEP after a route kept the route's target as the end and the tile check failed a run that worked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…and #313 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
Review follow-up: 0957678 drops the native run of PokemonSimulation's wire cases from Story data codec (they still use the old pose/certainty and per-kind fields; the Python reader keeps checking them), the same change #332 made. 68e4ecf fixes should-fix 1: a single STEP after the last target now leaves the end pose unknown, with a test. Should-fix 2-4 (SAVE steps in none mode, once_per_save in JSON, option text) and the nits are left for follow-ups. Code health's 5 test-case findings stay advisory here; #332 restructures those tables. |
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
…merged, review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…merged, review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…merged, review fixes Conflict: the engine-runs test table takes the engine's case shape (name outside the input); the breakpoint rows are written in it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…rged, review fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
|
On the two
Both in #495. |
Game languages: FRLG keeps six languages, one Spanish (#312 review)
Depends on #114.
The bottom of three layers split from #122: the shared story step data types (
Types/: steps, checkpoints, args, step kinds, check levels), theStoryStepExecutorinterface that turns a checkpoint into engine events, the story-step and authored-checkpoint JSON codecs (Data/) with their portable CMake tests, and the run options (StoryRunOptionsover #325'sStoryRangeOptions, per-game language lists inPokemon_GameLanguages); the shared log lines and stats counts come from #45. Screen state and interrupts are #313; #122 keeps only where steps meet screen state. The StoryEvents/StorySegments edits here still have to move to #114 (open questions in the review threads).Testing: StoryStepExecutor, StoryStepJson, AuthoredCheckpointJson, StoryArgs, StoryLog, StoryRangeOptions, StoryEvents and StorySegments suites pass in test mode with the isolated profile, here and on #313 and #122.
🤖 Generated with Claude Code
https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss