216
X-Machines for Agent-Based Modeling: FLAME Perspectives
else if (ISINNEST == 1 && FOODLEVEL >= 1.0) {
STATE = stateStayInNest;
//printf("stay in nest!\n");
}
else {
//printf("this should never happen!\n");
}
return 0;
}
int stayInNest(){
//printf("stay in nest called: ant %d\n", ANTID);
return 0;
}
int forageIdle(){
//printf("forage idle called: ant %d\n", ANTID);
return 0;
}
int depositIdle(){
//printf("deposit idle called: ant %d\n", ANTID);
return 0;
}
//Ant agent
//walk based on turning kernel
int walk() {
double pheromoneX = -1;
double pheromoneY = -1;
ISINNEST = 0;
detectPheromone(&pheromoneX, &pheromoneY);
//no pheromones nearby
if (pheromoneX == -1 && pheromoneY == -1)
{
turningKernel();
} else {
//pheromone found
double currentX = ANTX;
double currentY = ANTY;
int direction = getDirection(ANTX, ANTY, pheromoneX, pheromoneY);
updatePosition(¤tX, ¤tY, direction);
ANTX = checkAntPositionX(currentX);
ANTY = checkAntPositionY(currentY);
ANTDIRECTION = direction;
}
return 0;
}
//Ant agent
//decrease foodLevel at each iteration
int decreaseFoodLevel() {
//printf("in decrease food level\n");
FOODLEVEL = FOODLEVEL - 0.02;
if (FOODLEVEL <= 0) {
Précédent

- 245/329

Suivant