Skip to content

Use a single power value for Redpiler nodes - #264

Closed
Paul1365972 wants to merge 9 commits into
MCHPR:masterfrom
Paul1365972:refactor/redpiler-node-state
Closed

Paul1365972 wants to merge 9 commits into
MCHPR:masterfrom
Paul1365972:refactor/redpiler-node-state

Conversation

@Paul1365972

@Paul1365972 Paul1365972 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #260.

Every node stored both a powered flag and a power level (output_power in the backend, output_strength in the compile graph and exported graph).
For the behavior Redpiler currently implements, we can derive the boolean from the power level instead.

There is now just power, with is_powered() checking whether it is nonzero.
Lamps, trapdoors and note blocks store their activation as 0 or 15 too, which is why I went with power rather than output_strength.

SignalStrength is a repr(u8) enum with 16 variants covering 0 to 15.
It takes one byte and gives the compiler the valid range, while conversions and deserialization reject out-of-range values.
Option<SignalStrength> also replaces NonMaxU8 for comparator far inputs without taking more space.

Flushing is also restructured.
write_blocks writes a node's blocks and play_pending_notes plays pending notes, so reset writes every changed node directly instead of going through flush.
Whether flush writes a node is decided at compile time: is_io becomes visible (!io_only || is_input || is_output), and JITBackend::flush loses its io_only parameter.

Some related cleanup:

  • Rename link ss to weight for consistency.
  • Rename runtime locked to repeater_locked.
  • Move input queries and histogram updates into NodeInput, with private buckets and capacity checking during construction.
  • Share comparator_output_power between the update and tick paths.
  • Replace the old state helpers with Node methods and keep propagation in set_power_and_propagate.
  • Remove the redundant scheduler wrapper and unused helpers.

Input histograms now also start valid and stay nonzero, so power lookup uses NonZeroU128 and drops the zero check we had before.

Valid RIL syntax is unchanged.
The parser now rejects powers outside 0..=15 and link weights above 255 instead of truncating them, and docs/RIL.md documents link weights as they are parsed.
Exported graphs lose the separate powered field and will need to be regenerated.

Quick link to review only the refactor.

@Paul1365972 Paul1365972 changed the title Derive node power from output strength Use a single power value for Redpiler nodes Sep 18, 2026
@Paul1365972
Paul1365972 force-pushed the refactor/redpiler-node-state branch from a36e7c8 to 896e896 Compare September 18, 2026 02:50
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