This is the regular alpha-beta search as applied to SEE, where there is no loop over moves, as at any stage we only try stand pat or the capture to the given target with the lowest attacker:
Code: Select all
int SEE(int apha, int beta, int eval)
{
if(eval >= beta) return beta; // stand pat produces (fail-hard) cutoff
if(eval > alpha) alpha = eval; // this is the crucial alpha update
// FOR ALL MOVES
MakeNextCapture();
score = -SEE(-beta, -alpha, -(eval + PieceValue[victim]));
UnMake();
if(score > alpha) alpha = score;
// NEXT MOVE
return alpha;
}
Code: Select all
int SEE(int apha, int beta, int eval)
{
if(eval >= beta) return beta; // stand pat produces (fail-hard) cutoff
if(eval > alpha) alpha = eval; // this is the crucial alpha update
MakeNextCapture();
alpha = -SEE(-beta, -alpha, -(eval + PieceValue[victim]));
UnMake();
return alpha;
}
Code: Select all
int SEE(int apha, int beta, int eval, int victim)
{
if(eval >= beta) return beta; // stand pat produces (fail-hard) cutoff
if(eval > alpha) alpha = eval; // this is the crucial alpha update
eval += PieceValue[victim];
victim = NextPieceOfAttackersList(); // attacker is now on target square
alpha = -SEE(-beta, -alpha, -eval, victim);
return alpha;
}
Code: Select all
int MySEE(int apha, int beta, int eval, int victim)
{
if(eval >= beta) return beta; // stand pat produces (fail-hard) cutoff
if(eval > alpha) alpha = eval; // this is the crucial alpha update
eval += PieceValue[victim];
victim = NextPieceOfMyAttackersList(); // attacker is now on target square
return HisSEE(beta, alpha, eval, victim);
}
int HisSEE(int apha, int beta, int eval, int victim)
{
if(eval <= beta) return beta; // stand pat produces (fail-hard) cutoff
if(eval < alpha) alpha = eval; // this is the crucial alpha update
eval -= PieceValue[victim];
victim = NextPieceOfHisAttackersList(); // attacker is now on target square
return MySEE(beta, alpha, eval, victim);
}
Code: Select all
int HisSEE(int beta, int alpha, int eval, int victim)
{
if(eval <= alpha) return alpha; // stand pat produces (fail-hard) cutoff
if(eval < beta) beta = eval; // this is the crucial alpha update
eval -= PieceValue[victim];
victim = NextPieceOfHisAttackersList(); // attacker is now on target square
return MySEE(alpha, beta, eval, victim);
}
Code: Select all
eval = 0;
while(1)
{
// MySEE part
if(eval >= beta) {result = beta; break; }// stand pat produces (fail-hard) cutoff
if(eval > alpha) alpha = eval; // this is the crucial alpha update
eval += PieceValue[victim];
victim = NextPieceOfMyAttackersList(); // attacker is now on target square
// HisSee part
if(eval <= alpha) { result = alpha; break; } // stand pat produces (fail-hard) cutoff
if(eval < beta) beta = eval; // this is the crucial alpha update
eval -= PieceValue[victim];
victim = NextPieceOfHisAttackersList(); // attacker is now on target square
}
Code: Select all
eval = 0;
while(1)
{
// MySEE part
if(eval >= beta) {result = beta; break; }// stand pat produces (fail-hard) cutoff
victim = NextPieceOfHisAttackersList(); // attacker is now on target square
if(eval > alpha) alpha = eval; // this is the crucial alpha update
eval += PieceValue[victim];
// HisSee part
if(eval <= alpha) { result = alpha; break; } // stand pat produces (fail-hard) cutoff
victim = NextPieceOfMyAttackersList(); // attacker is now on target square
if(eval < beta) beta = eval; // this is the crucial alpha update
eval -= PieceValue[victim];
}
Code: Select all
eval = 0;
victim = board[targetSquare];
while(1)
{
eval += PieceValue[victim];
if(eval <= alpha) { result = alpha; break; } // stand pat produces (fail-hard) cutoff
victim = NextPieceOfMyAttackersList(); // attacker is now on target square
if(eval < beta) beta = eval; // this is the crucial alpha update
eval -= PieceValue[victim];
if(eval >= beta) {result = beta; break; }// stand pat produces (fail-hard) cutoff
victim = NextPieceOfHisAttackersList(); // attacker is now on target square
if(eval > alpha) alpha = eval; // this is the crucial alpha update
}
