This code does not take into account whether the previous call of AlphaBeta failed low or high, for currDepth >= 4 it always re-searches with a window of [Score - margin .. Score + margin] where margin is 20, 40, 80, ... A better attempt could be to do the following:tomitank wrote:And here is my ASP:Code: Select all
search : for (currDepth = 1; currDepth <= maxSearchDepth; currDepth++) { if (countMove == 1 && currDepth > 5 && bestMove) break; for (var margin = (currDepth >= 4 ? 10 : INFINITE); ; margin *= 2) { alpha = Math.max(Score - margin, -INFINITE); beta = Math.min(Score + margin, INFINITE); Score = AlphaBeta(alpha, beta, currDepth, true, inCheck); if (timeStop == 1) break search; // time out if (Score > alpha && Score < beta) break; } }
- After failing low re-search with a lower alpha and *unchanged* beta
- After failing high re-search with a higher beta and *unchanged* alpha
(SF9 does that, too, search for the comment "In case of failing low/high increase aspiration window" ...)
That might help to avoid toggling up and down between fail-low and fail-high which can be caused by search instability (which itself is caused by TT entries being overwritten in the meantime, and is also a possible explanation for non-reproducability problems).