question: 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 ; }
target:  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.