actors :: ClockAgent :: defaultinit
# Master of the simulation, it initiates the steps and waits for them to terminate
class ClockAgent
actor
# Number of steps to do in the simulation
var nb_steps: Int
# List of Agents in the simulation
var agents: Array[Agent]
# Number of agents that finished their step
var nb_finished = 0
fun do_step do
for a in agents do a.async.do_step
nb_steps -= 1
end
fun finished_step do
nb_finished += 1
if nb_finished == agents.length then
nb_finished = 0
if nb_steps != 0 then async.do_step
end
end
end
lib/actors/examples/agent_simulation/agent_simulation.nit:20,1--45,3