/** * This callback is specific to TreeAgentState * and has no UI dependencies. * It should not be used with any agent state other then * TreeAgentState */ public class TreeCallbackTrackMaxDepth implements ISimUICallback { int m_nMaxDepth; public TreeCallbackTrackMaxDepth() { m_nMaxDepth = 0; } public boolean doCallback(double [] arrLfState, IAgent agent, StateBundle [] arrStates, ISensor [] arrSensors, IEnvironment env , CommGraph graph, double lfSimTime) { for(int i = 0; i < arrStates.length; ++i) { TreeAgentState currState = (TreeAgentState)(arrStates[i].getVars()); int nDep = currState.getDepthEst(); Boolean bObjDone1 = currState.getBoolVar(new Integer(0)); boolean bDone1 = (bObjDone1 != null) && bObjDone1.booleanValue(); if(!bDone1 && nDep > m_nMaxDepth) { // track the max depth of any agent which hasn't attached // to an ancestor. m_nMaxDepth = nDep; } } return false; } /** * In case we need more info then true/false from doCallback * @return arbitrary object (meaning depends on derived class) */ public Object getLastObject() { return new Integer(m_nMaxDepth); } }