runDynamics

suspend fun <A : AgentLike> KSLProcessBuilder.runDynamics(agent: A, dynamics: Dynamics<A>, dt: Double = 0.05, until: () -> Boolean = { false })(source)

Run agent under dynamics until until returns true. Each iteration: compute the Euler step, store the new velocity, move the agent to the candidate position as-is, delay dt.

This is the convenience entry point for the common case where no boundary handling is needed (e.g., flocking in an unbounded or toroidal space if you set up space with torus = true — note that for torus models you also want to wrap positions yourself or use Dynamics with a custom loop, since ContinuousProjection stores positions verbatim).

For models with walls, gates, or other position-rejection rules, write your own loop around Dynamics.step so you can validate the candidate position before applying.

val script = process(isDefaultProcess = true) {
runDynamics(this@Boid, dynamics, dt = 0.05) { false }
}

Throws

if dt is non-positive