Open jlux98 opened 2 years ago
Depending on the implementation of IterativeDeepening, I dont think the MiniMax-Instance even has to hold a reference to the IterativeDeepening-Instance. If IterativeDeepening holds a reference to the Minimax-Variant and invokes it (as it currently does), this variant returns it's result (best move) and the IterativeDeepening instance can store it.
public void evaluateTree(
Tree<? extends Node<ContentType>> tree, TreeEvaluator<ContentType> evaluator,
boolean whitesTurn, int secondsToCompute, int maxDepth) {
.
.
.
while (depth <= maxDepth && !Conductor.stopCalculating) {
bestMove = evaluator.evaluateTree(tree, depth, whitesTurn);
saveMove(bestMove, depth); // <- change implementation of saveMove() to save inside this instance
// rather than in a static variable
depth += 1;
}
Conductor.stopCalculating = true; //can this kill a new search?
}
Saving the results of iterative deepening in a single static variable might lead to a race condition where the result of an old calculation overwrites the result of the new calculation. My suggestion would be to save the results in the IterativeDeepening-instance and either