Skip to content

feat(tutorial): add the decimal digit stage - #106

Merged
Rn86222 merged 10 commits into
mainfrom
feat/decimal-digit-stage
Nov 20, 2026
Merged

Rn86222 merged 10 commits into
mainfrom
feat/decimal-digit-stage

Conversation

@Rn86222

@Rn86222 Rn86222 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Stage 8 makes one decimal digit of the stopwatch: it counts 0 to 9 while Up is ON and carries back to 0.

  • Stage 8, "One decimal digit":
    • Input Up, outputs Count (four bits) and Carry. Count goes up only at the time steps when Up is ON and goes back to 0000 after 1001; Carry is ON when Count is 1001 and Up is ON.
    • It starts with the counter of stage 7, made to add 0001 only while Up is ON with a Const, a Broadcast and an And, and with Count split into bits by a Decompose. Every wire it starts with runs left to right, clear of the nodes and their names.
    • The player makes Carry from the eights and ones digits and Up, and goes back to 0000 with Not Carry spread to four bits by a Broadcast and joined with S by an And. The same Broadcast-and-And pattern is already on the screen for Up.
    • The goal explains decimal, says that 1001 is 9, and tells how Check switches Up: ON for time steps 1 to 9, OFF for 10 and 11, ON from 12. A player can replay a failure in play mode from this, and Up is OFF while Count is 1001 to catch a Carry that ignores Up.
    • The steps explain Broadcast, And over several bits, and how to set the bit width of a Broadcast's output from the box on its pin.
  • Bits: stage 4 teaches that a digit of a binary number is called a bit. The editor shows the word (the Const box, the bit width box, the notice on a refused wire), and part summaries and Check's messages are the same in every stage. Widths are written in bits from there on, in the Decompose, Aggregate and Broadcast summaries, the message on a pin of the wrong width and the stage texts. Positions in a number stay digits.
  • Layout checks: tests check, for every stage, that no node or its name overlaps another, before or after the stage is solved, and that no wire it starts with runs over a node or its name. The path of a wire moves out of the renderer, so that the tests follow the curve the editor draws.
  • Smaller changes: Broadcast gets a summary, also shown in the free mode, and stages 6 to 8 share how the 7seg and Display are placed, at a position each stage chooses.

Testing

  • npx vitest run (247 tests), npx tsc -p . and npx biome check src pass. New tests cover:
    • stage 8 cleared by its solution, using only the parts it offers
    • stage 8's goal table, with Count held at 1001 while Up is OFF and the carry back to 0000
    • no overlapping nodes or names, and no wire over a node or name, in every stage
    • the path of a wire
  • In the browser, stage 8 can be built by following its steps, counts on the display only while Up is ON, goes back to 0 after 9 and clears. Its wires keep clear of the nodes, and the texts of stages 4, 6 and 7 read as intended.

🤖 Generated with Claude Code

Rn86222 and others added 10 commits November 20, 2026 13:01
Stage 8 counts 0 to 9 while Up is ON and carries back to 0. It starts with the
counter of stage 7, made to add 0001 only while Up is ON with a Const, a Broadcast
and an And, and with Count split into digits. The player makes Carry from the
eights and ones digits and Up, and goes back to 0000 with Not Carry spread by a
Broadcast and joined with S by an And.

The goal tells how Check switches Up over the time steps, so a failure can be
replayed, and Up stays OFF while Count is 1001 to catch a Carry that ignores Up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e layouts apart

- The adder sits below the FlipFlop, so the wire from Count to A no longer looks
  like S already going into the FlipFlop.
- The steps say to change the 1 in the width box to 4, and to take Not's input
  from the And that drives Carry, as Carry itself has no output.
- The goal says that 1001 is 9, that Carry turns ON, and that Check switches Up.
- The solution's Ands no longer overlap, and a test now checks that no stage
  places a node over another, before or after it is solved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Const box shows "4 bits" in stage 7, and in stage 8 the box for the width of
a Broadcast's pin and the notice on a refused wire speak of bit widths. Stage 7
now says that a digit of a binary number is called a bit, and stage 8 says that
the box is the bit width, the number of bits of the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onst as asked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wire from the FlipFlop back to the adder ran over both of them and the adder's
name, and the wire from the Const to the And grazed the Const. The FlipFlop now
sits left of the adder, so every wire placed runs left to right, and the Decompose
sits below on the left, where its wire passes clear of the adder.

A test now checks, for every stage, that no wire it starts with runs over a node
or the name above it. The path of a wire moves out of the renderer, so that the
test follows the same curve the editor draws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r sizes with the editor

The overlap check now covers the name above each node, which moves an And of the
stage 8 solution clear of the Const. The checks take the height of a name and the
straight part of a wire from the editor's own constants, and the path of a wire
gets a test of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage 8 and the Broadcast summary spoke of digits for the width of a value, and
one step mixed bits and digits. They now say bits for widths, and keep digits
and places for the positions in a number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idths in bits

Part summaries and the message on a pin of the wrong width show the same text in
every stage, so the word bit cannot wait for stage 7. Stage 4 now says that a
digit of a binary number is called a bit, and Decompose, Aggregate, the width
message and the Const step write widths in bits. Digits and places stay for the
positions in a number and for how many digits a number has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ummaries

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

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

Copy link
Copy Markdown

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

Latest commit: ab986de
Status: ✅  Deploy successful!
Preview URL: https://14942008.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://feat-decimal-digit-stage.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@Rn86222
Rn86222 merged commit e18b769 into main Nov 20, 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