User Tools

Site Tools


chess:programming:search:minimax

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

chess/programming/search/minimax.txt · Last modified: 2021/10/12 00:33 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki