Skip to content

feat(tutorial): check a circuit over time steps - #104

Merged
Rn86222 merged 2 commits into
mainfrom
feat/sequential-check
Nov 19, 2026
Merged

Rn86222 merged 2 commits into
mainfrom
feat/sequential-check

Conversation

@Rn86222

@Rn86222 Rn86222 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stages 7 to 9 (the counter, a decimal digit and MM:SS) build circuits whose outputs change over time with flip-flops. Check simulated every input combination from scratch, so a flip-flop always output 0 and such a stage could never be cleared. This PR adds a check over time steps for those stages. No stage uses it yet, so nothing on the screen changes.

  • A check over time: a stage's check is now either combinational, as before, or sequential.
    • sequentialCheck(pins, model, inputSteps) works out what the outputs should be at each step from a model of the circuit (its state, and for each step the outputs and the next state) and the inputs fed at each step.
    • Check simulates the steps in turn, carrying the flip-flops on from the step before, as play mode does. A combinational check still starts every combination afresh.
  • Messages:
    • A wrong output tells the time step, counted from 1 as the editor shows it, and the inputs at that step: "At time step 3 (Start is ON), Count should be 0011, but it is 0010." / 「3 ステップ目(Start が ON)に、Count が 0011 のはずが 0010 でした。」 Without inputs, the brackets are left out.
    • A cleared stage over time says up to which step it works.
    • English says "time step", as "step" alone could be read as one of the numbered Steps of the stage.
  • Stage mistakes: steps that feed an input of the wrong width, or expect an output to change width, fail where the stage is defined, instead of looking like a mistake in the player's circuit.
  • Smaller changes: checkCombinational is renamed checkCircuit, and the two wrong-output messages share how they label values.

Not in this PR

  • The goal of a stage over time shows no table yet (goalTableOf returns null, marked TODO). The counter stage decides how its goal looks.
  • A wrong output tells only the inputs at that step. When an input such as Up changes between steps, the player cannot replay the steps before it from the message alone. To be settled with the decimal-digit stage, together with how its goal shows the inputs.

Testing

  • npx vitest run (218 tests), npx tsc -p . and npx biome check src pass. New tests cover:
    • a flip-flop circuit passing as it carries values from step to step, and a blinker without inputs
    • the first wrong step reported with its number and inputs
    • a combinational check starting every combination afresh, which fails if frames are carried over
    • steps refused when they do not fit the pins
    • the messages in both languages, and describeFailure for a wrong step
  • In the browser, stage 1 still reports a wrong output and clears as before.

🤖 Generated with Claude Code

Rn86222 and others added 2 commits November 20, 2026 03:21
…at went wrong

A sequential check works out what the outputs should be at each step from a model
of the circuit and the inputs fed to it. Check then simulates the steps in turn,
carrying the flip-flops on from the step before, and reports the first step at
which an output is wrong with the inputs at that step. A stage cleared this way
says up to which step it works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tep" in English

A stage whose steps feed an input of the wrong width, or expect an output to change
width, now fails where it is defined instead of looking like a mistake in the
player's circuit. In English, "step" alone could be read as one of the numbered
Steps of the stage. Tests now cover that a combinational check starts every
combination afresh, and the text of a failure at a step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6596b1b
Status: ✅  Deploy successful!
Preview URL: https://874ef41b.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://feat-sequential-check.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@Rn86222
Rn86222 merged commit a4d79b3 into main Nov 19, 2026
2 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