public boolean addAgent(IMovingAgent agent){
  if (!agents.contains(agent)) {
    agents.add(agent);
    if (agent instanceof Hive) {
      hives.add((Hive)agent);
    }
    if (agent instanceof FoodSource) {
      foodSources.add((FoodSource)agent);
    }
    if (agent instanceof Obstacle)     obstacles.add((Obstacle)agent);
    double r=agent.getSphereRadius();
    if (r > maxAgentSphereRadius)     maxAgentSphereRadius=r;
    return true;
  }
  return false;
}

public boolean addAgent ( IMovingAgent agent ) { if ( ! agents . contains ( agent ) ) { agents . add ( agent ) ; if ( agent instanceof Hive ) { hives . add ( ( Hive ) agent ) ; } if ( agent instanceof FoodSource ) { foodSources . add ( ( FoodSource ) agent ) ; } if ( agent instanceof Obstacle ) obstacles . add ( ( Obstacle ) agent ) ; double r = agent . getSphereRadius ( ) ; if ( r > maxAgentSphereRadius ) maxAgentSphereRadius = r ; return true ; } return false ; }
add an agent to the simulation . the maximum sphere of all objects is computed during successfully adding an agent . some agent classes are additionally stored in list to provide access in the user interface .
