kipedia.org/wiki/Negascout psuedo code:
int negascout(node, depth, α, β) { if node is a terminal node or depth = 0 { return the heuristic value of node } b = β // initial window is (-β, -α) foreach child of node { a = -negascout (child, depth-1, -b, -α) if (a>α) α = a if (α≥β) return α // Beta cut-off if (α≥b) { // check if null-window failed high α = -negascout(child, depth-1, -β, -α) // full re-search if (α≥β) return α // Beta cut-off } b = α+1 // set new null window } return α } int NegaScout ( p, α, β ); { determine successors p_1,...,p_w of p if ( w = 0 ) return Evaluate(p) // leaf b = β; for ( i = 1; i <= w; i++ ) { t = -NegaScout ( p_i, -b, -α ); if (t > α) && (t < β) && (i > 1) && (d < maxdepth-1) α = -NegaScout ( p_i, -β, -t ) // re-search α = max( α, t ) if ( α >= β ) return α // cut-off b = α + 1 // set new null window } return α } from http://lurgee.net/abstract-strategy-games/ negascout(node, alpha, beta) if node is a leaf return an evaluated score for the node maxscore = alpha b = beta for each child of node v = -negascout(child, -b, -alpha) if alpha < v < beta and not the first child and depth > 1 v = -negascout(child, -beta, -v) // re-search alpha = max(alpha, v) if alpha >= beta return alpha // cut-off b = alpha + 1 // set new null window return alpha
@author Barry Becker