Seeded simulation clock driving deterministic probe sampling. More...
| Import Statement: | import Clayground.Lab |
The heart of the determinism contract: all lab randomness must come from this clock's seeded generator, and probes are sampled on a fixed sim-time grid. With a world assigned, sim time advances with the physics steps (exact under the inspector's time/step action); without one, a frame ticker advances it, honoring Clayground.paused and Clayground.timeScale.
Example usage:
import Clayground.Lab SimClock { id: clock; seed: 42; world: theWorld }
fixedStep : real |
maxStepsPerAdvance : int |
Fixed steps allowed per advance, so a hitch cannot become a freeze.
An advance that needs more steps than this runs this many and drops the rest of the whole steps; the part of a step still to come is kept. An advance that needs exactly this many loses nothing.
resting : bool |
While true, live time stands still - the lab has nothing to show.
A binding on time is a redraw on every frame, and so is every probe sample, which repaints the plots, and the time readout on the TransportChip. A lab whose state does not change while nothing in it moves - a circuit with no current, pipes with no flow - binds this to that condition and then renders nothing at all until something starts: electronics-101 drew 60 frames a second at rest (#575).
Only the frame ticker honours it. Stepping - the inspector's step action, lab-check, a reload re-stepping to the saved time - advances time as before, so a stepped record does not depend on it. A lab whose model advances in stepped must not rest while that model is still changing. A change made while resting - a value edited on a board with no current - reaches the probes through wake().
sampleInterval : real |
Sim-time seconds between probe samples.
seed : int |
Seed for the deterministic random generator; changing it resets the clock.
time : real |
Simulated seconds since the last reset.
timeScale : real |
Slow-motion/fast-forward factor for live (frame-driven) mode.
Composes with Clayground.timeScale; ignored while stepping, which always advances fixed frames for reproducibility.
world : var |
Optional ClayWorld2d; when set, time advances with physics steps.
stepped(real dt) |
wasReset() |
Emitted after a reset; sensors/estimators snap their state here.
Note: The corresponding handler is onWasReset.
real random() |
Deterministic uniform random number in [0, 1) (mulberry32).
real randomGaussian() |
Deterministic standard-normal random number (Box-Muller).
real randomRange(real from, real to) |
Deterministic uniform random number in [from, to).
void reset() |
Resets time, random state and all probe samples.
void wake() |
Lets live time run on to the next probe sample, even while resting.
For a lab whose state changed while it rests: the plots show a reading only once it is sampled, so without this an edit to a still board would not reach them until something moved. Costs the frames up to that sample, then the clock rests again. No effect on stepping.