Negamax is a common way of implementing Minimax and derived algorithms.
NegaMax is called from a root function.
In the loop which generates all the root moves:
max(a, b) == -min(-a, -b)
This is how the pseudo-code of the recursive algorithm looks like. For clarity move making and unmaking is omitted.
int negaMax( int depth ) { if ( depth == 0 ) return evaluate(); int max = -oo; for ( all moves) { score = -negaMax( depth - 1 ); if( score > max ) max = score; } return max; }
NOTE: In order for NegaMax to work, the Static Evaluation function must return a score relative to the side to being evaluated.