Gatherers
Agent Algorithm
A gatherer agent chooses the closest visible piece of food that is currently not being carried by anyone (and is not already in the agent's home base) and accelerates towards it. If no "uncarried" food can be found, the agent tries to find food carried by a member of the opposing team to accelerate towards. If no food is visible the agent sets his acceleration to a random vector to search for food. When it gets close enough to pick up a piece of food, it picks it up and carries it towards its home base corner for 20 time cycles, and drops it again. The gatherer must then rest for 10 time cycles before picking up another piece of food. During these 10 time cycles, the "exhausted" agent does not accelerate.
Pseudocode
if have food if have carried food for 20 time cycles drop food else accelerate towards home base else if have rested for 10 time cycles if can see uncarried food not in home base if am close enough to pick it up pick up food else accelerate towards closest uncarried food else if can see food carried by opponent accelerate towards opponent with food else accelerate in random direction else set acceleration to zero
Observed Behavior
The result of this algorithm is a kind of "Capture the Flag" game, except with multiple flags (and that the flags are called "food"). The applet is set to stop play if one team wins the game by getting all the food items into its home base.
Since one agent cannot carry a piece of food from the opponent's base without setting it down and resting for a bit, it is very likely that if an attempt is made by lone agent to steal a piece of food from the opponents' base, the food with be snatched back up by the enemy when he sets it down to rest. So, of course, the better strategy is to steal food in teams of two or more.
If the teams have close to the same number of members, the result is pretty much a stalemate. However, if the teams are significantly unevenly matched, one will almost always win. If there are too many players on a team, they can get in the way and hinder, rather than help, efforts. Another problem that happens (especially when team sizes are high) is that agents get trapped in their own bases because they don't know to pick up a piece of food that is in their way. Since the pieces of food are defined as stationary by default, colliding with them does no good to free trapped agents. A trapped agent will only be freed if an opponent removes one of the pieces of food blocking his path.
One unexpected observation is the benefit of the default drop spot (the place the food is placed when the agent drops it) being directly in front (in the direction of the velocity vector) of the agent. What often happens is that an agent carrying a piece of food will be pursued by one or more of his opponents. When the agent drops the food to rest, his body is between the food and the pursuers, so unless his opponents can figure a way to go around him and pick up the food within 10 time cycles, the agent can simply pick up the food again and continue!
For added fun, try unchecking the "Stationary Food" box to allow the food to drift around and respond to collisions. The resulting behavior is that several agents from a team take on "food control duty" and stay around the home base moving food back inside that has drifted out. If the ratio of agents to food is sufficiently low, "food containment" will occupy all of their time, and there will be no missions to steal the other team's food at all!