How to implement iterative deepening with alpha beta pruning
Well, Iterative Deepening is not really difficult to implement. If you already have a function to perform a search, let's call it alphaBetaAtRoot
, which performs a search with a fixed distance, you just call it repeatedly, starting with distance 1:
for(int distance = 1; distance < MAX_DISTANCE && !outOfTime(); distance++) {
bestmove = alphaBetaAtRoot(position, distance);
}
play(bestmove);
What is important, though, is that you implement a Transposition Table. Otherwise, you will not benefit from a better move ordering, as each search will just start with zero knowledge.
I have found the following link: https://github.com/nealyoung/CS171/blob/master/AI.java I hope that helps you.