Getting Started with FLAME
77
• Agents can create static or dynamic arrays in agent memory or make
some locally, to manipulate within the function.
• Messages can be manipulated, such as by:
– Add message with:
Add messagename message(var1,var2)
– Loop through messages with:
START MESSAGENAME MESSAGE LOOP
Messagename message->variables
FINISH MESSAGENAME MESSAGE LOOP
For example:
while(rabbitInformation_message)
{
/* Access data from message */
rabbit_id_found = rabbitInformation_message->rabbit_id;
if(rabbit_id_found==1)
{
printf("Rabbit with ID =1 is found!")
}
/* Traverse through next message */
rabbitInformation_message = get_next_rabbitInformation_message
(rabbitInformation_message);
}
/* Example Fox functions */
/** \fn Check if fox survives malnutrition
*/
int foxSurvives()
{
/* For each time step lower life expectancy */
LIFEEXPECTANCY = LIFEEXPECTANCY - 1;
/* Check if dead */
if(LIFEEXPECTANCY == 0)
{
printf("Fox dies of hunger\n");
/* Kill dead fox agent */
return 1;
}
return 0;
}
/** \fn Fox_location()
* \brief Send message with fox location
*/
int foxInformation()
{
Précédent

- 106/329

Suivant