Tag Bots

Agent Algorithm

If a tag agent is "it", he will try to touch whichever non-"it" agent is closest to him. When that contact is made, the agent he touched is "it". If a tag agent is not "it", he will not accelerate unless he sees an agent that is "it", in which case the non-"it" agent will accelerate away from the agent that is "it". Additionally, when an agent is tagged "it", its maximum speed decreases by 20% (the speed is restored upon losing "it" status) and it must wait 10 time cycles before accelerating; this is to prevent two agents getting locked together repeatedly tagging one another.

Pseudocode

if there are visibleAgents
   distanceToClosestOpp = infinity
   for all visibleAgents
      if visibleAgent.it != it
         if distanceTo(visibleAgent) < distanceToClosestOpp
		closestOpponent = visibleAgent
		distanceToClosestOpp = distanceTo(visibleAgent)
   if(it)
      accelerate towards closestOpponent
   else
      accelerate away from closestOpponent
else
   set acceleration to zero

Observed Behavior

As predicted, the observed behavior is much like that of children on a playground playing the same game.

If the Agent Sight is set low, the behavior resembles that of random particles. If the agents can see far, then they tend to crowd along the walls and in the corners cowering away from the "it" agents, much like you would imagine zebras in a cage doing if you introduced a lion to the cage. If you have a lot of agents, this "crowding in the corners" pattern is much more pronounced.

The Applet

If you see this, you need to either enable java, or install the Sun Java Virtual Machine in your browser. To do so, click here.

Source Code

Back to the Applet Bots Home
The official version of this file is at applet-bots.sourceforge.net