104
X-Machines for Agent-Based Modeling: FLAME Perspectives
return 1; //returning 1 deletes the agent from the
simulation
}
return 0;
}
0
Citizen
50
0
33.542894
59.733879
0
Sugar
1
90.304270
98.867763
5.1.4 Find Agents around Me
Although sugar is an inactive entity, it had to be located and found by
other agents. The sugar agents perform the following:
• Post their location messages, so they are read by citizen agents.
• Read ‘eat’ messages to determine if they are eaten and should disappear
from landscape.
Agents can parse through messages to work out if there are agents close to
it. The citizen agents read through a list of sugar location messages to collect
their x and y coordinates. These allow a distance to be calculated and then
measure the viewed distance to calculate if the citizen can see these sugars.
If any sugar is found, the ID is recorded and then posted in the next loop to
tell the sugar agent that it was found.
sugar_location_message=get_first_sugar_location_message();
while(sugar_location_message)
{
//Extracting information from message
current_distance_squared=
X-Machines for Agent-Based Modeling: FLAME Perspectives
return 1; //returning 1 deletes the agent from the
simulation
}
return 0;
}
5.1.4 Find Agents around Me
Although sugar is an inactive entity, it had to be located and found by
other agents. The sugar agents perform the following:
• Post their location messages, so they are read by citizen agents.
• Read ‘eat’ messages to determine if they are eaten and should disappear
from landscape.
Agents can parse through messages to work out if there are agents close to
it. The citizen agents read through a list of sugar location messages to collect
their x and y coordinates. These allow a distance to be calculated and then
measure the viewed distance to calculate if the citizen can see these sugars.
If any sugar is found, the ID is recorded and then posted in the next loop to
tell the sugar agent that it was found.
sugar_location_message=get_first_sugar_location_message();
while(sugar_location_message)
{
//Extracting information from message
current_distance_squared=
