1. Simple SI model
This step builds a susceptible–infected (SI) model. People agents move through a square world, and infected agents can infect nearby people with a configurable probability.

Model structure
A GAML model has a global section for the world state and initialization, one or more species sections for agents, and an experiment section for run parameters and output. See model organization for the section roles.
People agents
The people species uses the built-in moving skill. Its two reflexes move agents and spread infection, while its default aspect draws infected and susceptible agents in different colors.
species people skills: [moving] {
bool is_infected <- false;
reflex move {
do wander();
}
reflex infect when: is_infected {
ask people at_distance infection_distance {
if (flip(proba_infection)) {
is_infected <- true;
}
}
}
aspect default {
draw circle(5) color: is_infected ? #red : #green;
}
}
World and initialization
The global section defines the number of people, their speed, infection parameters and world geometry. Its init block creates the population, assigns the speed supplied by the moving skill and infects the initial sample.
global {
int nb_people <- 500;
float agent_speed <- 5.0 #km/#h;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
float step <- 1 #minutes;
geometry shape <- envelope(square(500 #m));
init {
create people number: nb_people {
speed <- agent_speed;
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
Experiment
The GUI experiment exposes infection distance, infection probability and the initial infected count. The map display draws all people agents with their default aspect.
experiment main_experiment mode: gui {
parameter "Infection distance" var: infection_distance unit: #m;
parameter "Proba infection" var: proba_infection min: 0.0 max: 1.0;
parameter "Nb people infected at init" var: nb_infected_init;
output {
display map {
species people;
}
}
}
Read the complete Incremental Model 1 source for the runnable model. Later steps extend it with charts, statistics, spatial data and a graphical interface.