Skip to content

Commit ddcdd43

Browse files
committed
Fixes minor bug in IterativeDeepeningEngine
1 parent 0da1e29 commit ddcdd43

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ This doesn't means that the AI can't be used to play Reversi. Simply, the revers
2121
## TODO (probable breaking changes)
2222
- com.fathzer.games.ai.AbstractAI requires an ExecutionContext in its constructor. I think this is not a good approach (even it was mine ;-)) to have this non standard implementation detail exposed outside this public class. Moreover, this disallow building different multi-threading models in AI implementation. Typically it is currently impossible to use a fork/join pool to perform the search.
2323
As it seems, in real life, a new context is created at each AI invocation, a better approach would be to let the AI manage its own threading scheme, and simply pass a SearchContext to the constructor.
24+
- Some methods in `TranspositionTable` and `com.fathzer.games.ai/iterativedeepening` implicitly suppose that the move generator implement `HashProvider`. This may be changed for an explicit requirement.
25+
2426

2527
## TODO (maybe)
2628
- Make MoveLibrary implement AI?

src/main/java/com/fathzer/games/ai/iterativedeepening/IterativeDeepeningEngine.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.concurrent.atomic.AtomicBoolean;
66
import java.util.function.Supplier;
77

8+
import com.fathzer.games.HashProvider;
89
import com.fathzer.games.MoveGenerator;
910
import com.fathzer.games.ai.Negamax;
1011
import com.fathzer.games.ai.SearchContext;
@@ -267,8 +268,10 @@ protected IterativeDeepeningSearch<M> doSearch(B board, List<M> searchedMoves) {
267268
rs.setEventLogger(logger);
268269
rs.setSearchedMoves(searchedMoves);
269270
final List<EvaluatedMove<M>> result = rs.getSearchHistory().getAccurateMoves();
270-
for (EvaluatedMove<M> ev:result) {
271-
ev.setPvBuilder(m -> getTranspositionTable().collectPV(board, m, deepeningPolicy.getDepth()));
271+
if (board instanceof HashProvider) {
272+
for (EvaluatedMove<M> ev:result) {
273+
ev.setPvBuilder(m -> getTranspositionTable().collectPV(board, m, deepeningPolicy.getDepth()));
274+
}
272275
}
273276
logger.logSearchEnd(board, rs.getSearchHistory());
274277
return rs;

0 commit comments

Comments
 (0)