public void setBestChain(AiChoice bestChain) {
this.bestChain.set(bestChain);
}
protected void popActionChain() {
AiChoice toExecute = null;
AiChoice best = bestChain.get();
if (best.getPrevious() == null) {
toExecute = best;
bestChain.set(null);
} else {
AiChoice choice = best;
while (choice.getPrevious().getPrevious() != null) {
choice = choice.getPrevious();
}
toExecute = choice.getPrevious();
choice.setPrevious(null); //cut last element from chain
}
//logger.info("pop chain " + this.toString() + ": " + toExecute.toString());
//execute after chain update is done
toExecute.perform(getServer());
}