118
X-Machines for Agent-Based Modeling: FLAME Perspectives
damping force can allow the agent to move towards the leader, in the direction,
giving the impression of a simple walk rather than a jump towards the leader.
Similar mathematical equations can be updated to add more complexity in
person movements, to make them appear more real.
5.3.2 Entering and Exiting Agents
//from the Generate Agent functions
int generate_people()
{
int gnumber=rand()%MAXIMUM_GENERATED_PERSONS;
int i=0;
int leader=0;
NUMBER_GROUP_GENERATE=NUMBER_GROUP_GENERATE+1;
for(i=0; i {
if(i==0)
{
leader=1;
}
else
{
leader=0;
}
NUMBER_PEOPLE_GENERATE=NUMBER_PEOPLE_GENERATE+1;
add_person_agent(NUMBER_PEOPLE_GENERATE, X, Y, X,Y, 5.0, 1, 0,0,1,
NUMBER_GROUP_GENERATE,leader);
}
return 0;
}
The Generate agent can add new Person agents into the scene, using the
function ‘add person agent()’. The agent will first have to calculate the variables for the person memory and declare them as function parameters when
creating agents.
For exiting agents, the person agent needs to have a function which returns
a ‘1’ rather than a ‘0’, to allow it to be removed from the simulation. This
can accompany an ‘if’ condition to check, if the exit point is reached, such as
if(current_location==exit_position)
return 1;
else
return 0;
Figure 5.15 shows two snapshots from the simulation, where the person
agents are superimposed into a screen to walk around a collection of buildings.
Précédent

- 147/329

Suivant