The language for the programs executed by the ants consists of two
types of statements, commands and directions.
Directions come in two flavors, relative and absolute
- Absolute Directions - N, S, E, W, C North, South, East,
West and the Current squares.
- Relative Directions - L, R, F, B Left, Right, Forward,
and
Backwards indicate the square in the direction relative to the haeding of
the ant.
Commands are used for control flow and action. The commands used
are:
- (move DIR) - moves in direction specified by DIR.
- (drop PGM) - drop a phermone and execute PGM.
- (if_present DIR PGM1 PGM2) - if pheromone is present in
direction DIR, then execute PGM1. Otherwise execute PGM2.
- (if_ant DIR PGM1 PGM2) - if an ant is present in direction DIR,
then execute PGM1. Otherwise execute PGM2.
- (if_last_move DIR PGM PGM) - if the last move was DIR, then
execute PGM1. Otherwise execute PGM2.
- (if_less_than DIR1 DIR2 PGM1 PGM2) if there is less pheromone
in direction DIR1 than DIR2, then execute PGM1. Otherwise execute
PGM2.
Notice that all branches of the tree must end in a move command. The
result of executing a program is a move and possibly a drop.
An program might look like:
if_less_than F B
if_present L
move L
move R
if_present S
drop
move N
move E
|
In this program, the PGM part of each command is given its own
line and indented one space
further than its "parent".
|