jill/src/main/java/io/github/agentsoz/jill/core/IntentionSelector.java
public void run() {
    Set<Integer> toRemove = new HashSet<Integer>();
    do {
      boolean idle = true;
      // Remove agents that have have become idle due to an external event
      removeInactiveAgents();
      // Add agents that have have become active due to an external event
      addActiveAgents();
      for (Integer i : activeAgents) {
        Agent agent = (Agent) GlobalState.agents.get(i);
        Stack255 agentExecutionStack = (Stack255) (agent).getExecutionStack();
        if (!isStackValid(agent, agentExecutionStack)) {
          // Mark this agent for removal
          toRemove.add(i);
          continue;
        }
        // At least one agent is active
        idle = false;
        // Get the item at the top of the stack
        Object node = (Object) agentExecutionStack.get((byte) (agentExecutionStack.size() - 1));
        if (node instanceof Plan) {
          // If it is a plan then execute a plan step; and if it finished then remove it
          managePlan(i, agentExecutionStack, (Plan) node, toRemove);
        } else if (node instanceof Goal) {
          // If it is a goal then find a plan for it and put it on the stack
          manageGoal(i, agent, agentExecutionStack, (Goal) node);
        }
        agent.nextActiveStack(); // select the next active stack for next time
      }
      // remove agents that have finished executing plans and have gone idle in this cycle
      removeFinishedAgents(toRemove);
      if (idle) {
        waitOnExternalMessage();
        if (shutdown) {
          break;
        }
      }
    } 
    while (true);
    logger.debug("Pool {} is exiting", poolid);
  }
public void run() {
    Set<Integer> toRemove = new HashSet<Integer>();
    do {
      boolean idle = true;
      // Remove agents that have have become idle due to an external event
      removeInactiveAgents();
      // Add agents that have have become active due to an external event
      addActiveAgents();
      for (Integer i : activeAgents) {
        Agent agent = (Agent) GlobalState.agents.get(i);
        Stack255 agentExecutionStack = (Stack255) (agent).getExecutionStack();
        if (!isStackValid(agent, agentExecutionStack)) {
          // Mark this agent for removal
          toRemove.add(i);
          continue;
        }
        // At least one agent is active
        idle = false;
        // Get the item at the top of the stack
        Object node = (Object) agentExecutionStack.get((byte) (agentExecutionStack.size() - 1));
        if (node instanceof Plan) {
          // If it is a plan then execute a plan step; and if it finished then remove it
          managePlan(i, agentExecutionStack, (Plan) node, toRemove);
        } else if (node instanceof Goal) {
          // If it is a goal then find a plan for it and put it on the stack
          manageGoal(i, agent, agentExecutionStack, (Goal) node);
        }
        agent.nextActiveStack(); // select the next active stack for next time
      }
      // remove agents that have finished executing plans and have gone idle in this cycle
      removeFinishedAgents(toRemove);
      if (idle) {
        waitOnExternalMessage();
        if (shutdown) {
          break;
        }
      }
    } 
    while (true);
    logger.debug("Pool {} is exiting", poolid);
  }
public void run ( ) { Set < Integer > toRemove = new HashSet < Integer > ( ) ; do { boolean idle = true ; // Remove agents that have have become idle due to an external event removeInactiveAgents ( ) ; // Add agents that have have become active due to an external event addActiveAgents ( ) ; for ( Integer i : activeAgents ) { Agent agent = ( Agent ) GlobalState . agents . get ( i ) ; Stack255 agentExecutionStack = ( Stack255 ) ( agent ) . getExecutionStack ( ) ; if ( ! isStackValid ( agent , agentExecutionStack ) ) { // Mark this agent for removal toRemove . add ( i ) ; continue ; } // At least one agent is active idle = false ; // Get the item at the top of the stack Object node = ( Object ) agentExecutionStack . get ( ( byte ) ( agentExecutionStack . size ( ) - 1 ) ) ; if ( node instanceof Plan ) { // If it is a plan then execute a plan step; and if it finished then remove it managePlan ( i , agentExecutionStack , ( Plan ) node , toRemove ) ; } else if ( node instanceof Goal ) { // If it is a goal then find a plan for it and put it on the stack manageGoal ( i , agent , agentExecutionStack , ( Goal ) node ) ; } agent . nextActiveStack ( ) ; // select the next active stack for next time } // remove agents that have finished executing plans and have gone idle in this cycle removeFinishedAgents ( toRemove ) ; if ( idle ) { waitOnExternalMessage ( ) ; if ( shutdown ) { break ; } } } while ( true ) ; logger . debug ( "Pool {} is exiting" , poolid ) ; }
Runs this intentions selction thread.
Runs this intentions selction thread .