Repository navigation
AutoStory settle: keep-watching option, quiet timed from its change - #570
Conversation
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
left a comment
There was a problem hiding this comment.
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::sincealready 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 atsince + quiet. That holds only when the IO reportssince. An IO withoutsincestill 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}}, ruletimed_door(true)vstimed_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 resetsm_quiet_sincewhen the events are not quiet.- Suppose a box flashes and closes inside one watch. The IO reports QUIET with a
sincelater than the judge'sm_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
sinceis 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_casttruncatesheld, sorestrounds up. A watch never ends before the quiet is due, and a 0 ms span cannot occur, becauserest == 0meansover, which returns DONE. For a rule withoutend_on_quiet,left()returns nullopt and the span islook_every.- After a battle,
sinceis reset, so the span goes back tolook_every. - I traced all 5 timing cases against the code, and they match.
presses = 0with the option on. - Style: same-line braces with no space, multiline bodies,
std::optionalinstead 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,TimelineSettleIOwith 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.
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.
SettleRule::keep_watching: once the screen is quiet or calm, the next look watches only the time left (TalkOver::left()), not a wholelook_every. It also skips presses, so a game that presses through text (BDSP) must not turn it on as is.SettleIO::watch(span): the look for such a rule; its default islook(), so BDSP/FRLG IOs compile unchanged until they adopt it (BDSP AutoStory: settle and Center visit on the shared seam-5 code #549/FRLG AutoStory: settle and Center visit on the shared seam-5 code #551).Testing
Pokemon::Settle - timingcases 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
sinceis 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 latersince, with a test for a break never seen at a look's end.