Angry Bits

Words on bytes and bits

Minimax, the chess engine's core

A chess engine selects the best move to do given a board configuration. There are several ways to achieve it, despite the common sense, the most used and studied is the simplest: exhaustive search.

Not so easy

Easy, isn't it? So why did it take so long before we were able to build a good artificial chess player? The answer is quite fascinating: chess game has too many variants.

For each position we have to follow all the possible moves. In middle-game the average number of moves is over 20, this means that if it would be possible to find a forced victory for either player with just 30 turns, we would have to compute about 20^30 positions. Let's say our computer is good enough to elaborate 1 billion of billion positions in a millisecond, then it would take about 34 billion years for Minimax to finish.

That sounds crap. How can we deal with this problem?

Here come strategies developed during last century. These strategies help our chess engine reducing the number of positions to consider. Few of them are optimal, so they don't actually change the result of the Minimax algorithm, many others are heuristics and take the risk to do some mistakes in order to dramatically reduce the time required to choose the best move.

Comments