src/model/agent/Agent.java
private Action stalk() {
        Action action = Action.WAIT;
        if (!targetAgent.active || targetAgent.getState() == AgentState.STALKING) {
            setState(AgentState.LOITERING);
        } else if (route == null || route.isEmpty()) {
            route = context.getRouteToAgent(targetAgent);
        } else if (context.isFree(route.get(0))) {
            action = Action.MOVE;
            action.direction = route.remove(0);
        } else if (context.getOccupant(route.get(0)) == targetAgent
                && context.conditionsAreRight()) {
            action = Action.ROB;
            action.direction = route.get(0);
        } else if (Model.rand.nextBoolean()) {
            if (context.dodgeObstruction(route)) {
                action = Action.MOVE;
                action.direction = route.remove(0);
            }
        } else if (wait <= 0) {
            setState(AgentState.LOITERING);
        }
        
        return action;
    }
/**
     * - If the target is gone or stalking someone, loiter.
     * - If not and the route is empty, poll for a new one.
     * - If not and the next step is free, take it.
     * - If not and the next step is blocked by the target, rob it.
     * - If not, flip a coin, if heads figure out a detour;
     * - If not and we have waited too long, loiter;
     */
- If the target is gone or stalking someone, loiter.
- If not and the route is empty, poll for a new one.
- If not and the next step is free, take it.
- If not and the next step is blocked by the target, rob it.
- If not, flip a coin, if heads figure out a detour;
- If not and we have waited too long, loiter.
- If the target is gone or stalking someone loiter . - If not and the route is empty poll for a new one . - If not and the next step is free take it . - If not and the next step is blocked by the target rob it . - If not flip a coin if heads figure out a detour ; - If not and we have waited too long loiter .
private Action stalk() {
        Action action = Action.WAIT;
        if (!targetAgent.active || targetAgent.getState() == AgentState.STALKING) {
            setState(AgentState.LOITERING);
        } else if (route == null || route.isEmpty()) {
            route = context.getRouteToAgent(targetAgent);
        } else if (context.isFree(route.get(0))) {
            action = Action.MOVE;
            action.direction = route.remove(0);
        } else if (context.getOccupant(route.get(0)) == targetAgent
                && context.conditionsAreRight()) {
            action = Action.ROB;
            action.direction = route.get(0);
        } else if (Model.rand.nextBoolean()) {
            if (context.dodgeObstruction(route)) {
                action = Action.MOVE;
                action.direction = route.remove(0);
            }
        } else if (wait <= 0) {
            setState(AgentState.LOITERING);
        }
        return action;
    }
private Action stalk ( ) { Action action = Action . WAIT ; if ( ! targetAgent . active || targetAgent . getState ( ) == AgentState . STALKING ) { setState ( AgentState . LOITERING ) ; } else if ( route == null || route . isEmpty ( ) ) { route = context . getRouteToAgent ( targetAgent ) ; } else if ( context . isFree ( route . get ( 0 ) ) ) { action = Action . MOVE ; action . direction = route . remove ( 0 ) ; } else if ( context . getOccupant ( route . get ( 0 ) ) == targetAgent && context . conditionsAreRight ( ) ) { action = Action . ROB ; action . direction = route . get ( 0 ) ; } else if ( Model . rand . nextBoolean ( ) ) { if ( context . dodgeObstruction ( route ) ) { action = Action . MOVE ; action . direction = route . remove ( 0 ) ; } } else if ( wait <= 0 ) { setState ( AgentState . LOITERING ) ; } return action ; }
- If the target is gone or stalking someone, loiter.
- If the target is gone or stalking someone loiter .