private void cleanNeeds() { while (!needs.isEmpty()) { Need need = needs.getFirst(); // TODO consider other strategies (e.g. continuous needs) if (need.isFulfilled(bot)) { needs.remove(need); } else { return; } } }
public Action getNextAction() { cleanNeeds(); // TODO consider recent research on planning management Need need = needs.isEmpty() ? null : needs.getFirst(); if (need instanceof LocationNeed) { LocationNeed need2 = (LocationNeed) need; // TODO make smarter decision + check pre-conditions Collection<Action> alternatives = Arrays.<Action>asList(new WalkingAction(need2.getTargetX(), need2.getTargetY())); for (Action action : alternatives) { Need preCondition = action.getPreCondition(); if (preCondition == null || preCondition.isFulfilled(bot)) { return action; } else { continue; } } return null; } else { return null; } }