Skip to content

AutoStory settle: keep-watching option, quiet timed from its change - #570

Merged
dayfine merged 2 commits into
nav/sharedfrom
autostory/settle-keep-watching
Nov 15, 2026
Merged

dayfine merged 2 commits into
nav/sharedfrom
autostory/settle-keep-watching

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Base nav/shared; the diff shows only this change. Follow-up to #546 agreed on #551.

A watching game's settle (FRLG, 400 ms looks) saw a quiet that was due mid-look only at that look's end, so it ran up to one look (~400 ms) past it; #546 already times the quiet from its change. This adds an opt-in rule that ends the settle when the quiet does.

Testing

  • New Pokemon::Settle - timing cases on a timeline-scripted watching IO, incl. a quiet due early in a look: 1210 ms with the option vs 1600 ms without. Code health: 0 failures. Fork Draft CI runs the full suites. No console run.

Follow-up (not here): a look whose since is later than the running quiet start does not restart it, so a box that flashes and closes inside one watch can be missed and the settle ends early. Fix: restart the quiet/calm on a later since, with a test for a break never seen at a look's end.

A watching game's settle (FRLG) saw the quiet end only at a whole look's
end, so each settle ran up to one look past it. SettleRule::keep_watching
makes run_settle() watch only the time the quiet or calm still needs
(TalkOver::left(), SettleIO::watch()), timed from the change that began
it, and never press. Off by default; games opt in when they adopt it.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: a5c7cf5

Verdict

APPROVED

The change is correct and the default keeps today's behavior. The findings below are non-blocking. I'd still add finding 1 before merge, because it is the case that proves the PR's headline claim.

Does it remove the overshoot from the decision note?

Partly. Part of that overshoot was already gone before this PR, and this PR removes the rest.

  • The note's "+0.4-0.8 s" adds up two parts. Part (a): a quiet that begins mid-look was only seen at the look's end, so it was counted from there. Part (b): the check then waited for the next look's end.
  • Part (a) was already removed by #546 (on the base). SettleLook::since already makes the judge count the quiet from the change. The existing case "a quiet that began early in a look counts from then" shows it.
  • On the base, only part (b) remains: the settle ends at the first look end at or after since + quiet. That costs 0 to <1 look, i.e. under 400 ms for FRLG.
  • This PR removes part (b). left() shortens the next watch to the remaining time, so the settle ends exactly at since + quiet. That holds only when the IO reports since. An IO without since still pays part (a).

The new tests do not show the size of the gain. In "keeping watch, it ends 1 s after the box closed", the quiet ends at 1550 ms, only 50 ms before the 1600 ms look end, so the gap between the option on and off is 50 ms. See finding 1.

Findings

1. [Medium, test] Add a case that shows almost a whole look saved.

  • Timeline: {{0ms, BOX}, {210ms, QUIET}}, rule timed_door(true) vs timed_door(false).
  • Without the option: the looks end at 400/800/1200/1600 ms. At 1200 the quiet has held 990 ms, so the settle ends at 1600 ms, after 4 looks and 3 presses.
  • With the option: spans 400, 400, 400, then 10. The settle ends at 1210 ms, after 4 looks.
  • That saves 390 ms, almost one 400 ms look, which is the claim in the PR description. I traced this by hand against run_settle/TalkOver::left; I did not run it.
  • The existing 550 ms case can stay as it is.

2. [Medium, pre-existing from #546, but this option relies on it] A later since does not restart a quiet that is already running.

  • judge.look(look.events, *look.since) only resets m_quiet_since when the events are not quiet.
  • Suppose a box flashes and closes inside one watch. The IO reports QUIET with a since later than the judge's m_quiet_since, and the judge keeps the old start.
  • With keep_watching, the last short watch lands exactly on old start + quiet. A break inside it is therefore ignored, and the settle ends early.
  • FRLG's adopter (#551) computes since = window.end - settle.quiet, so this case can happen there.
  • Suggested follow-up, not for this PR: a look whose since is later than the running quiet or calm start restarts it. Add a test for a break that is never seen at a look's end.

3. [Low, design] keep_watching turns on two behaviors: shortened watches, and skipping press().

  • FRLG's watching IO already makes press() a no-op ("No button: the next look's watch is the wait"), so the skip changes nothing there.
  • If a pressing game (BDSP) set this flag, it would sit in a dialog until cap.
  • The header comment says so ("It never presses"), so this is acceptable. A cleaner option is to keep calling io.press(move, rule.look_every) and let the watching IO's own no-op do the work, so the flag means only what its name says.

4. [Low, health] run_settle is now 49 lines against a limit of 50 (code health, advisory). The next change to it will fail code health. Consider moving the span computation into a small helper, e.g. next_span(rule, judge, when), or splitting the switch out now.

5. [Nit, tests] There are now two watching IOs. TimelineSettleIO covers what WatchingSettleIO does, since a per-look unchanged_for is a timeline. Folding the older one into it later would cut about 40 lines. This is not needed for this PR.

Checked, no issue

  • left(): duration_cast truncates held, so rest rounds up. A watch never ends before the quiet is due, and a 0 ms span cannot occur, because rest == 0 means over, which returns DONE. For a rule without end_on_quiet, left() returns nullopt and the span is look_every.
  • After a battle, since is reset, so the span goes back to look_every.
  • I traced all 5 timing cases against the code, and they match. presses = 0 with the option on.
  • Style: same-line braces with no space, multiline bodies, std::optional instead of sentinels, test cases as name/input/expectation with nested structs, virtual ... override. CRLF is kept in all 5 files, and there are no tabs.
  • Code health against origin/nav/shared: 0 failures, 3 advisories (finding 4, test file at 565 lines, TimelineSettleIO with 6 public methods).

Review on #570: a case where keeping watch saves almost a whole look
(1210 ms vs 1600 ms), run_settle's span computation moved into
next_span(), and the keep_watching comment says a pressing game must not
turn it on as it is.
@dayfine
dayfine marked this pull request as ready for review November 15, 2026 19:54
@dayfine
dayfine merged commit 9e405d3 into nav/shared Nov 15, 2026
16 checks passed
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