Code: Select all
int search(int depth, int lastTo, int alpha, int beta)
{
if(depth<=0) staticval=EVAL();
if( ! IN_CHECK() && I_HAVE_MORE_THAN_TWO_PIECES() )
{
if(staticval >= beta ) return beta;
}
ALLMOVES = GENERATE_ALL_MOVES();
if(ALLMOVES is empty) return checkmate/stalemate score accordingly
for each MOVE in ALLMOVES
{
if(depth>0 || to==lastTo)
{
Make(MOVE);
val=-search(depth-1,to,-beta,-alpha);
Undo(MOVE);
}
else val=staticval;
if(val >= beta) return beta;
if(val > alpha) alpha=val;
}
return alpha;
}
I guess if there is a hash move, then like the moves generated, it will only be played if its destination is the lastTo square.
Thanks