puzzles
Multi-step code puzzles in the Software Whisper style, as data. A puzzle is a target and a list of steps; each step shows lines of code, some hidden until the player READs them, some rewritable with a list of options (a logic line is PATCHed whole). Picking the right option advan…
rewriteKit.puzzles
Multi-step code puzzles in the Software Whisper style, as data. A puzzle is a target and a list of steps; each step shows lines of code, some hidden until the player READs them, some rewritable with a list of options (a logic line is PATCHed whole). Picking the right option advances the step; a glitch option is rejected and costs extra, a crash option throws a full-screen SYSTEM ERROR and the step is retried; solving every step shows a results screen (actions, system errors, glitches, resource spent, time, 1 to 3 stars). Rewrite.definePuzzle(id, spec) registers one, Rewrite.playPuzzle(id, opts, onDone) plays it in any of the eight looks with keyboard (arrows, R read, E rewrite, Enter, Esc), gamepad (d-pad, X read, A rewrite, B exit) and touch (tap a line to select, tap again to READ, tap an option to choose, tap again to REWRITE). Four built-in kinds build a spec from a few fields: sequence (actions in a set order), fixBug (one faulty line among decoys), tune (a number into a safe band) and logicGate (flip inputs and patch the gate until the output is right). Puzzles.session(spec) is the pure state machine underneath, for a game's own UI or tests.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
check(spec: any, id: string) → void
| arg | type | description |
|---|---|---|
| spec | any | |
| id | string |
define(id: string, spec: any) → any
Register a puzzle under `id` (raises on a malformed spec). `spec.kind` + params builds one of the built-in kinds when `steps` is left out.
| arg | type | description |
|---|---|---|
| id | string | |
| spec | any |
get(id: string) → any return registry
A registered puzzle (nil when unknown).
| arg | type | description |
|---|---|---|
| id | string |
list( ) → void
Every registered puzzle id, sorted.
lineOf(step: any, id: string) → any
| arg | type | description |
|---|---|---|
| step | any | |
| id | string |
session(specOrId: any, opts: any?) → any
Start a run of a puzzle spec (or id). opts: { budget? (resource for READ/EDIT/PATCH, nil = unlimited), costs? }.
| arg | type | description |
|---|---|---|
| specOrId | any | |
| opts | any? |
_load(i: number) → void
| arg | type | description |
|---|---|---|
| i | number |
step( ) → any return self
_say(text: string, kind: string?) → void
| arg | type | description |
|---|---|---|
| text | string | |
| kind | string? |
_pay(kind: string) → boolean
| arg | type | description |
|---|---|---|
| kind | string |
_crash(text: string) → void
| arg | type | description |
|---|---|---|
| text | string |
_orderOk(lineId: string, action: string, value: any?) → boolean
the next action an ordered step expects
| arg | type | description |
|---|---|---|
| lineId | string | |
| action | string | |
| value | any? |
_solvedNow( ) → boolean
_advance( ) → void
read(lineId: string) → void
READ a line: reveals a hidden line. Returns ok, why ("crash" for a READ out of order).
| arg | type | description |
|---|---|---|
| lineId | string |
edit(lineId: string, which: any) → string
REWRITE a line to option `which` (its index or its value). Returns result "ok" | "glitch" | "crash" | an error.
| arg | type | description |
|---|---|---|
| lineId | string | |
| which | any |
retry( ) → boolean
After a SYSTEM ERROR, start the step again (values and reads reset, crashes kept).
abort( ) → void
Give up the run.
result( ) → any
The result of a finished run: { id, success, reason?, crashes, glitches, actions, spent, seconds, stars (1 to 3) }.
view(lineId: string) → any
What a line shows right now: its code, its value (scrambled until READ), whether it is readable and rewritable.
| arg | type | description |
|---|---|---|
| lineId | string |
sequence(p: any) → void
sequence: `lines` and `order` = { { line, action = "read"|"edit", value? }, ... }; every action must come in order, anything else crashes.
| arg | type | description |
|---|---|---|
| p | any |
fixBug(p: any) → void
fixBug: one faulty `line` among `decoys`; its `fix` option solves, `glitches` are rejected, `crashes` break it.
| arg | type | description |
|---|---|---|
| p | any |
tune(p: any) → void
tune: a number `line` from `min` to `max` by `step`; the run solves inside [`lo`, `hi`] and crashes past `crashAbove` / below `crashBelow`.
| arg | type | description |
|---|---|---|
| p | any |
check(values: ?) → void
| arg | type | description |
|---|---|---|
| values | ? |
AND(a: boolean, b: boolean) → void
| arg | type | description |
|---|---|---|
| a | boolean | |
| b | boolean |
OR(a: boolean, b: boolean) → void
| arg | type | description |
|---|---|---|
| a | boolean | |
| b | boolean |
XOR(a: boolean, b: boolean) → void
| arg | type | description |
|---|---|---|
| a | boolean | |
| b | boolean |
NAND(a: boolean, b: boolean) → void
| arg | type | description |
|---|---|---|
| a | boolean | |
| b | boolean |
NOR(a: boolean, b: boolean) → void
| arg | type | description |
|---|---|---|
| a | boolean | |
| b | boolean |
gate(op: string, a: boolean, b: boolean) → boolean
The output of a gate line ("A AND B", "A XOR B", ...) for inputs a, b.
| arg | type | description |
|---|---|---|
| op | string | |
| a | boolean | |
| b | boolean |
logicGate(p: any) → void
logicGate: inputs `a`, `b` (booleans), a `gate` (AND, OR, XOR, NAND, NOR) and the `want`ed output; inputs flip with REWRITE, the gate is PATCHed; `locked` = { "a" } pins an input.
| arg | type | description |
|---|---|---|
| p | any |
boolOpts(locked: boolean) → any
| arg | type | description |
|---|---|---|
| locked | boolean |
check(values: ?) → void
| arg | type | description |
|---|---|---|
| values | ? |
build(kind: string, params: any) → any
Build a spec from a built-in kind and its params.
| arg | type | description |
|---|---|---|
| kind | string | |
| params | any |
zin( ) → void
zcall(fn: string, a: any) → any
| arg | type | description |
|---|---|---|
| fn | string | |
| a | any |
kp(code: string) → boolean return zcall
| arg | type | description |
|---|---|---|
| code | string |
pp(btn: string) → boolean return zcall
| arg | type | description |
|---|---|---|
| btn | string |
lbl(text: string, style: any, id: string?, props: any?) → any
| arg | type | description |
|---|---|---|
| text | string | |
| style | any | |
| id | string? | |
| props | any? |
box(t: string, style: any, children: any, id: string?, props: any?) → any
| arg | type | description |
|---|---|---|
| t | string | |
| style | any | |
| children | any | |
| id | string? | |
| props | any? |
up(L: any, s: string) → string return if L
| arg | type | description |
|---|---|---|
| L | any | |
| s | string |
lineIds(s: any) → void
| arg | type | description |
|---|---|---|
| s | any |
buildTree( ) → any
button(id: string, text: string, enabled: boolean) → any
commands
| arg | type | description |
|---|---|---|
| id | string | |
| text | string | |
| enabled | boolean |
render( ) → void
finish( ) → void
after( ) → void
press(action: string) → void
Drive the open puzzle screen by action name (what keys, pad and taps call): "up", "down", "left", "right", "read", "write", "retry", "exit", "done", "line:<i>", "opt:<i>".
| arg | type | description |
|---|---|---|
| action | string |
pollInput( ) → void
play(id: string, opts: any?, onDone: any?) → any
Play a registered puzzle on this screen. opts: { look?, budget?, costs?, layer? }. `onDone(result)` gets { id, success, reason?, crashes, glitches, actions, spent, seconds, stars } after the results screen. Returns the session.
| arg | type | description |
|---|---|---|
| id | string | |
| opts | any? | |
| onDone | any? |
current( ) → any return if UI
Whether a puzzle screen is open on this peer, and its session.
close( ) → void
Close the open puzzle screen without a result callback.
tree( ) → any return if UI
The widget tree the puzzle screen draws right now (tests and previews).
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.