MCPcopy Index your code
hub / github.com/coding-parrot/chess-engine / iterativeDeepening

Method iterativeDeepening

src/main/java/Engine.java:125–142  ·  view source on GitHub ↗
(final Board board, final long time)

Source from the content-addressed store, hash-verified

123 }
124
125 public OutCome iterativeDeepening(final Board board, final long time) {
126 transpositionTable = new HashMap<>();
127 final long start = System.currentTimeMillis();
128 int depth = 1;
129 OutCome evaluation = alphaBeta(board, depth, Integer.MIN_VALUE, Integer.MAX_VALUE, 1000);
130 while (System.currentTimeMillis() - start < time * 1000 && Math.abs(evaluation.getScore()) - Integer.MAX_VALUE < 0.0001) {
131 depth++;
132 System.out.println("DEPTH: " + depth + " EVAL: " + evaluation + " TIME: " + ((System.currentTimeMillis() - start) / 1000));
133 try {
134 int finalDepth = depth;
135 evaluation = CompletableFuture.supplyAsync(() -> alphaBeta(board, finalDepth, Integer.MIN_VALUE, Integer.MAX_VALUE, 1000)).get(time * 1000 - (System.currentTimeMillis() - start), TimeUnit.MILLISECONDS);
136 } catch (InterruptedException | ExecutionException | TimeoutException e) {
137 System.out.println("TIMEOUT: " + depth);
138 break;
139 }
140 }
141 return evaluation;
142 }
143
144 private String getString(Move move) {
145 return move.piece.position.notation() + move.target.notation();

Callers 4

complexPositionMethod · 0.95
winQueenMethod · 0.95
endGamePgnMethod · 0.95
hardMateIn3Method · 0.95

Calls 3

alphaBetaMethod · 0.95
getScoreMethod · 0.95
getMethod · 0.45

Tested by 4

complexPositionMethod · 0.76
winQueenMethod · 0.76
endGamePgnMethod · 0.76
hardMateIn3Method · 0.76