public void decideNextStep(LocalSearchStepScope localSearchStepScope) {
WorkingMemory workingMemory = localSearchStepScope.getWorkingMemory();
Iterator<Move> moveIterator = selector.moveIterator(localSearchStepScope);
while (moveIterator.hasNext()) {
Move move = moveIterator.next();
MoveScope moveScope = new MoveScope(localSearchStepScope);
moveScope.setMove(move);
// Filter out not doable moves
if (move.isMoveDoable(workingMemory)) {
doMove(moveScope);
if (forager.isQuitEarly()) {
break;
}
} else {
logger.trace(" Ignoring not doable move ({}).", move);
}
}
MoveScope pickedMoveScope = forager.pickMove(localSearchStepScope);
if (pickedMoveScope != null) {
Move step = pickedMoveScope.getMove();
localSearchStepScope.setStep(step);
if (logger.isDebugEnabled()) {
localSearchStepScope.setStepString(step.toString());
}
localSearchStepScope.setUndoStep(step.createUndoMove(workingMemory));
localSearchStepScope.setScore(pickedMoveScope.getScore());
}
}