March Docs

Arcade.Physics.Sim

Types

typeSimClockSimClock = { t : Float, step : Int }#

Simulated time and the number of steps taken to reach it.

typeTimedTimed(e) = { at : Float, ev : e }#

Something that happened at a moment of simulated time.

typeSampledSampled(p) = { sampled_at : Float, point : p }#

A point on a recorded path, at a moment of simulated time.

typeTurnTurn(s, r) = TurnOn(s) | TurnStop(s) | TurnDone(r)#

What one step left: go on, stop here (as a loop's break does, so the caller's stop function closes the run), or done with a result.

Functions

fnchronologicalchronological(xs : List(a)) : List(a) needs ()#

fn record_every(n : Int, step : Int, x : a, xs : List(a)) : List(a) needs () do if records(step, n) do Cons(x, xs) else xs end end

fnclockclock() : SimClock needs ()#
fnemitemit(events : List(Timed(e)), at : Float, what : e) : List(Timed(e)) needs ()#

fn tick(c : SimClock, dt : Float) : SimClock needs () do { t: c.t +. dt, step: c.step + 1 } end

fnrecordsrecords(step : Int, n : Int) : Bool needs ()#
fnrun_stepsrun_steps(cx : c, max_t : Float, time_of : s -> Float, step : c -> s -> Turn(s, r), stop : c -> s -> r, s0 : s) : r needs ()#

Step s0 with step while time_of says it is before max_t. A step that goes on is stepped again; one that stops, or a state already out of time, is closed by stop; one that is done is the result. cx is passed to every call, so the hooks can be named top-level functions. Tail-recursive.