218
X-Machines for Agent-Based Modeling: FLAME Perspectives
foodEaten_message = get_first_foodEaten_message();
while (foodEaten_message) {
int localID = foodEaten_message->id;
if (localID == FOODID) {
SIZE = foodEaten_message->size;
if (SIZE <= 0.2) {
//printf("creating new food\n");
double xPosition = rand() / (double) (RAND_MAX) * 480;
double yPosition = rand() / (double) (RAND_MAX) * 480;
SIZE = (rand() / (double) (RAND_MAX) * 100) + 1;
if (SIZE > 0 && SIZE < 5) {
RADIUS = 5.0;
}
else if (SIZE >= 5 && SIZE < 10) {
RADIUS = 6.0;
}
else if (SIZE >= 10 && SIZE < 20) {
RADIUS = 7.0;
}
else if (SIZE >= 20 && SIZE < 30) {
RADIUS = 8.0;
}
else if (SIZE >= 30 && SIZE < 40) {
RADIUS = 9.0;
} else if (SIZE >= 40 && SIZE < 50) {
RADIUS = 10.0;
} else if (SIZE >= 50 && SIZE < 60) {
RADIUS = 11.0;
} else if (SIZE >= 60 && SIZE < 70) {
RADIUS = 12.0;
} else if (SIZE >= 70 && SIZE < 80) {
RADIUS = 13.0;
} else if (SIZE >= 80 && SIZE < 90) {
RADIUS = 14.0;
} else if (SIZE >= 90) {
RADIUS = 15.0;
}
add_newFood_message(SIZE, xPosition, yPosition, RADIUS);
return 1;
}
}
foodEaten_message = get_next_foodEaten_message(foodEaten_message);
}
return 0;
}
//Food agent
//add foodInfo
int foodInformation() {
if (SIZE > 0 && SIZE < 5) {
RADIUS = 5.0;
} else if (SIZE >= 5 && SIZE < 10) {
RADIUS = 6.0;
} else if (SIZE >= 10 && SIZE < 20) {
RADIUS = 7.0;
} else if (SIZE >= 20 && SIZE < 30) {
X-Machines for Agent-Based Modeling: FLAME Perspectives
foodEaten_message = get_first_foodEaten_message();
while (foodEaten_message) {
int localID = foodEaten_message->id;
if (localID == FOODID) {
SIZE = foodEaten_message->size;
if (SIZE <= 0.2) {
//printf("creating new food\n");
double xPosition = rand() / (double) (RAND_MAX) * 480;
double yPosition = rand() / (double) (RAND_MAX) * 480;
SIZE = (rand() / (double) (RAND_MAX) * 100) + 1;
if (SIZE > 0 && SIZE < 5) {
RADIUS = 5.0;
}
else if (SIZE >= 5 && SIZE < 10) {
RADIUS = 6.0;
}
else if (SIZE >= 10 && SIZE < 20) {
RADIUS = 7.0;
}
else if (SIZE >= 20 && SIZE < 30) {
RADIUS = 8.0;
}
else if (SIZE >= 30 && SIZE < 40) {
RADIUS = 9.0;
} else if (SIZE >= 40 && SIZE < 50) {
RADIUS = 10.0;
} else if (SIZE >= 50 && SIZE < 60) {
RADIUS = 11.0;
} else if (SIZE >= 60 && SIZE < 70) {
RADIUS = 12.0;
} else if (SIZE >= 70 && SIZE < 80) {
RADIUS = 13.0;
} else if (SIZE >= 80 && SIZE < 90) {
RADIUS = 14.0;
} else if (SIZE >= 90) {
RADIUS = 15.0;
}
add_newFood_message(SIZE, xPosition, yPosition, RADIUS);
return 1;
}
}
foodEaten_message = get_next_foodEaten_message(foodEaten_message);
}
return 0;
}
//Food agent
//add foodInfo
int foodInformation() {
if (SIZE > 0 && SIZE < 5) {
RADIUS = 5.0;
} else if (SIZE >= 5 && SIZE < 10) {
RADIUS = 6.0;
} else if (SIZE >= 10 && SIZE < 20) {
RADIUS = 7.0;
} else if (SIZE >= 20 && SIZE < 30) {
