Ant Food Collection Genetic Program
Instruction Set

The ant programs are stored as a binary tree. The instruction set for the ant programs is divided into two categories: Leaf Statements and Non-Leaf Statements. The Leaf Statements are actions performed by the ant. These statements do not have children. The Non-Leaf Statements are conditions. If the condition is true, the left branch of the Non-Leaf Node is executed. If the condition is false, the right branch is executed. Conditions may also have side effects. These side effects are actions that are performed if the condition is true, before the left branch is executed. Side effects are shown in ()'s.

Leaf Statement Description
MoveRandom Move the ant 1 spaces in any of the 4 cardinal directions.
MoveQuasiRandom Same as MoveRandom, but the random is weighted to most likely move the ant forward, and least likely backward.
MoveToNest Move the ant 1 space toward the nest in a cardinal direction. It is assumed that ants know how to return to their nest without help.
MoveToNestThroughWater Same as MoveToNest, but if there is water in the way, move into it and die. If carrying the food, drop it where the ant dies.
TurnLeft Turn Left 90 degrees.
TurnRight Turn Right 90 degrees.
MoveForward Move one space forward.
PickUpFood Pick up food if food exists at current location and the ant is not currently carrying food or a leaf.
DropFood Drop food if food is carried and there isn't food or a leaf at this location.
PickUpLeaf Pick up a leaf if there is a tree or leaf at the current location as long as the ant isn't already carrying a leaf or food.
DropLeaf Drop a leaf if a leaf is carried and there is no leaf or food at the current location..
DropLeafInWater If there is water directly in front of the ant, then drop the leaf in that space.
ReleasePheromone Release pheromones.
MoveIntoWater If water ahead, move into it and die. Drop food if carried.
EscapePheromone Move forward until no pheromone detected. If an obstacle is hit then turn in a random direction and continue moving. After 20 moves, give up trying to escape the pheromone.
NoOp Do nothing.
Non-Leaf Statement Description
Two Statements ( ) This special instruction allows 2 statements to be executed in a if or else block.
if ( FoodAhead ) If there is food in the space directly in front of the ant.
if ( FoodLeft ) If there is food in the space left of the ant.
if ( FoodRight ) If there is food in the space right of the ant.
if ( FoodAdjacent ) If there is food in any of the 4 spaces next to the ant.
if ( FoodHere ) If there is food at the same position as the ant.
if ( PheromoneHere ) If there any pheromones at the same position as the ant.
if ( LeafHere ) If there a leaf or a tree at the same position as the ant.
if ( CarryingFood ) If the ant is carrying food. This condition is true even if the ant can't lift the food.
if ( CarryingLeaf ) If the ant is carrying leaf.
if ( AtNest ) If the ant is at the nest location.
if ( MoveToAdjacentFood ) If there is an adjacent piece of food (move to the food).
if ( MoveToAdjacentLeaf ) If there is a leaf or a tree in one of the two directions away from the nest (move to the leaf).
if ( MoveToPheromoneAwayFromNest ) If there is a pheromone in one of the two directions away from the nest (move to the pheromone. move to the strongest if both directions have pheromones).
if ( MoveToDeadAnt ) If there is a dead ant ahead (move to the dead ant).
if ( MoveToStrongestPheromone ) If there is an adjacent pheromone (move to the strongest adjacent pheromone).
if ( MoveToNest ) If there is no obstacle blocking the way to the nest (move to the nest).
if ( MoveToNestThroughWater ) If there is no obstacle blocking the way to the nest (move to the nest. If water ahead, move into the water and die and drop food).
if ( WaterAhead ) If there is water ahead.
if ( ObstacleAhead ) If there is a wall ahead.
if ( AnotherAntHere ) If there is another living ant at this location.
if ( CantLiftFood ) If not enough ants at this location helping to lift heavy piece of food.
if ( TiredOfWaiting ) If have been waiting for other ants for help to lift a heavy piece of food for a given period of time