appletbots.swarm
Class SwarmAgent

java.lang.Object
  extended by appletbots.WorldObject
      extended by appletbots.Agent
          extended by appletbots.swarm.SwarmAgent

public class SwarmAgent
extends Agent

A swarm agent looks at its neighbors, chooses a certain number of them, and accelerates in the direction of their average velocity, with a part of its acceleration being randomized.

Author:
Erik Rasmussen

Field Summary
 
Fields inherited from class appletbots.Agent
accelerationVectorColor, maxAcceleration, sight, velocityVectorColor, world
 
Fields inherited from class appletbots.WorldObject
color, mass, maxSpeed, size
 
Constructor Summary
SwarmAgent(int size, int sight, double maxSpeed, double maxAcceleration, int numNeighborsToFollow, boolean chooseNeighborsByProximity, double randomizationFactor)
          Constructs a swarm agent with the given parameters
 
Method Summary
 void observeWorld()
          Observes the world, and follows the Swarm Agent Algorithm.
 
Methods inherited from class appletbots.Agent
getAcceleration, getMaxAcceleration, getRandomAcceleration, getShowAcceleration, getShowVelocity, getSight, getVectorsToDraw, setAcceleration, setShowAcceleration, setShowVelocity, setWorld
 
Methods inherited from class appletbots.WorldObject
collidedWith, getColor, getMass, getMaxSpeed, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwarmAgent

public SwarmAgent(int size,
                  int sight,
                  double maxSpeed,
                  double maxAcceleration,
                  int numNeighborsToFollow,
                  boolean chooseNeighborsByProximity,
                  double randomizationFactor)
Constructs a swarm agent with the given parameters

Parameters:
size - The agent's radius
sight - The distance the agent can see
maxSpeed - The maximum speed the agent can travel
maxAcceleration - The maximum acceleration for this agent
numNeighborsToFollow - The number of neightbors to follow
chooseNeighborsByProximity - How to choose neighbors to follow
randomizationFactor - The percentage of acceleration to be random
Method Detail

observeWorld

public void observeWorld()
Observes the world, and follows the Swarm Agent Algorithm.

Specified by:
observeWorld in class Agent