Global registry connecting parameters, probes and the sim clock. More...
| Import Statement: | import Clayground.Lab |
Every Parameter and Probe registers itself here on creation. UI components (ParamPanel, Plot2D) and agents (via eval on the inspector protocol) address them by name through this singleton.
Example usage:
import Clayground.Lab
// read a parameter value
property real g: Lab.p("gravity")
// set one (also the agent-facing entry point)
Component.onCompleted: Lab.set("gravity", 3.7)
See also Parameter, Probe, and SimClock.
flowIds : var |
Ids of all registered flows (registration order).
headless : bool |
No one is watching: skip audio and character travel.
Set by runFlow() for the length of a headless run and restored afterwards; a host may also set it by hand. What honours it is deliberately small and listed here rather than guessed at: Narrator hides, the professor kit's FlowGuide leaves the character where it is, and pre-rendered narration is not loaded. Nothing about the SIMULATION changes - a flow must traverse the same states headless as it does on screen, or running it as a check proves nothing.
paramNames : var |
Names of all registered parameters (registration order).
probeNames : var |
Names of all registered probes (registration order).
scenario : string |
Name of the currently applied scenario ("" if none).
sampled(real t) |
Emitted after all probes took a sample at sim time t.
Note: The corresponding handler is onSampled.
void applyViewState(var s) |
Restores parameters and, for world-less clocks, re-steps sim time.
Sets every parameter in s.params through the clamped set(), then - only when a SimClock exists, is world-less and s.time > 0 - deterministically re-steps it to s.time in fixed 1/60 s increments.
Ordering contract: the Sandbox root MUST apply s.scenario BEFORE calling this. The scenario apply resets the clock + RNG, so the re-step here replays the exact causal chain (takeSamples -> sampled -> sensors/filter), restoring bit-identical sim state. World-driven (Box2D) clocks cannot be synchronously re-stepped and are left untouched.
See also viewState.
void clearProbes() |
Drops all probe samples (done automatically on SimClock.reset).
var labInfo() |
Standard lab state block for the flagInfo()/labInfo() convention.
real p(string name) |
Shorthand for the value of the named parameter.
Parameter parameter(string name) |
Returns the Parameter with the given name (null if unknown).
Probe probe(string name) |
Returns the Probe with the given name (null if unknown).
var probeSummary() |
Per-probe {first, last, min, max, count} map.
var runFlow(string flowId, var opts) |
Runs a registered Flow to its end with nobody watching.
The headless half of "every flow is also a test": it starts the flow through the lab's own startFlow() when the lab has one, forces pacing: "auto", advances clock in fixed 1/60 s steps and performs every task itself with Flow::solve(). Nothing is waited for in wall-clock time, so a whole lesson runs in well under a second.
Returns what broke rather than throwing:
flowId, steps - the id asked for and how many 1/60 s steps it took;unresolvedVerbs - verb names the flow asked the lab for and did not get (a missing verb otherwise fails silently);failedTasks - {index, step} for a task still unsatisfied opts.solveGrace sim seconds after its own solve() ran;failedExpects - {index, step} (plus error when the predicate threw) for every FlowStep::expect that did not hold, asserted the moment the flow leaves the step;finished - the flow reached its end. False means the bound was hit;error - the run never started (no such flow, no clock).opts.maxSteps (default 20000, i.e. ~5.5 sim minutes) bounds the run so a watch that never comes true is a false finished rather than a hang. opts.solveGrace (default 5 sim seconds) is how long a task gets after being solved before it counts as failed.
headless is true for the length of the run and restored afterwards.
bool set(string name, real value) |
Sets a parameter value, clamped to its range.
var viewState() |
JSON-serializable lab state for the live-loader reload convention.
Returns { scenario, time, params }: the current scenario name (key omitted while empty), the sim-clock time and every registered parameter value. Sandbox roots merge their own camera/toggle state on top and hand the result to the dojo, which re-applies it after the next reload.
See also applyViewState.