1 # This file is part of NIT (http://www.nitlanguage.org).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # a "Framework" to make Multi-Agent Simulations in Nit
16 module agent_simulation
is example
, no_warning
("missing-doc")
20 # Master of the simulation, it initiates the steps and waits for them to terminate
24 # Number of steps to do in the simulation
27 # List of Agents in the simulation
28 var agents
: Array[Agent]
30 # Number of agents that finished their step
34 for a
in agents
do a
.async
.do_step
40 if nb_finished
== agents
.length
then
42 if nb_steps
!= 0 then async
.do_step
50 # Doing a step in the simulation
54 fun end_step
do clock_agent
.async
.finished_step
59 var clock_agent
: ClockAgent is noautoinit
,writable