runDynamicsAll

suspend fun <A : AgentLike> KSLProcessBuilder.runDynamicsAll(dynamics: Dynamics<A>, agents: () -> Collection<A>, dt: Double = 0.05, until: () -> Boolean = { false }, apply: (agent: A, vNew: Point2D, pNew: Point2D) -> Unit = { a, v, p -> dynamics.setVelocity(a, v) dynamics.space.moveTo(a, p) })(source)

Drive a whole population under dynamics from a single controller process using a Jacobi (synchronous, order-independent) update. Each tick computes every agent's step from the shared current state via Dynamics.stepAll, then applies them all, then delays dt. This is the batched analog of runDynamics and avoids the order-of-update bias you get when each agent runs its own runDynamics loop.

agents is re-evaluated each tick so the population may change (births / deaths). Override apply to inject boundary handling (e.g., toroidal wrap) before the candidate position is committed; by default the candidate is applied as-is.

val controller = process(isDefaultProcess = true) {
runDynamicsAll(dynamics, agents = { flock.members }, dt = 0.05)
}

Throws

if dt is non-positive