}
stats->ply--;
legal_moves++;
searched++;
if (score >= beta) {
if (!move_capture(move)) {
stats->killer_moves[1][ply] = stats->killer_moves[0][ply];
stats->killer_moves[0][ply] = move;
}
return beta;
}
if (score > alpha) {
if (!move_capture(move))
stats->history_moves[piece_index(move_piece(move))]
[move_target(move)] += depth;
alpha = score;
stats->pv_table[ply][ply] = move;
for (int i = stats->ply + 1; i < stats->pv_length[ply + 1]; i++)
stats->pv_table[ply][i] = stats->pv_table[ply + 1][i];
stats->pv_length[ply] = stats->pv_length[ply + 1];
stats->pv_table[stats->ply][stats->ply] = move;
for (int i = stats->ply + 1; i < stats->pv_length[stats->ply + 1];
i++)
stats->pv_table[stats->ply][i] =
stats->pv_table[stats->ply + 1][i];
stats->pv_length[stats->ply] = stats->pv_length[stats->ply + 1];
if (score >= beta) {
if (!move_capture(move)) {
stats->killer_moves[1][stats->ply] =
stats->killer_moves[0][stats->ply];
stats->killer_moves[0][stats->ply] = move;
}
return beta;
}
}
}
if (legal_moves == 0) {
if (isCheck)
return -49000 + stats->ply;
else
if (isCheck) {
return -MATE_VALUE + stats->ply;
} else
return 0;
}