====== Chess - Programming - Search - Minimax ====== **Minimax** is an algorithm used to determine the score in a zero-sum game after a certain number of moves, with best play according to an evaluation function. * The score of each move is the score of the worst that the opponent can do. ---- int maxi( int depth ) { if ( depth == 0 ) return evaluate(); int max = -oo; for ( all moves) { score = mini( depth - 1 ); if( score > max ) max = score; } return max; } int mini( int depth ) { if ( depth == 0 ) return -evaluate(); int min = +oo; for ( all moves) { score = maxi( depth - 1 ); if( score < min ) min = score; } return min; } ---- ===== References ===== http://web.archive.org/web/20120209041607/http://chessprogramming.wikispaces.com/Minimax