Following Finn's reply to my post "The Road to 3000" I've been re-writing my entire negamax search routine. I've come across a weird bug where the search will loop infinitely when extensions are enabled. Extensions/reductions and PVS is written in a similar fashion to Ethereal/Berserk's routine, and are also outlined here:
Code: Select all
// extensions:
extension = 0;
if (MOVE_IS_CASTLE(move) || b.is_check() || recapture)
if (!root) extension = 1;
new_depth = depth + extension;
b.make_move(move);
// reductions:
R = 1;
if (depth > 2 && non_pruned_moves > 1) {
if (!tactical) {
if (!b.is_check()) R += 2;
if (!pv) R++;
if (!improving) R++;
if (is_killer) R -= 2;
}
else R -= pv ? 2 : 1;
R = std::min(depth - 1, std::max(R, 1));
}
// PVS:
if (pv && non_pruned_moves == 1) {
score = -negamax(depth - 1, -beta, -alpha, forward_ply + 1);
}
else {
score = -negamax(new_depth - R, -alpha - 1, -alpha, forward_ply + 1);
if (R != 1 && score > alpha) {
score = -negamax(new_depth - 1, -alpha - 1, -alpha, forward_ply + 1);
}
if ((score > alpha) && (score < beta)) {
score = -negamax(new_depth - 1, -beta, -alpha, forward_ply + 1);
}
}
What do you think, and how should I go about fixing this? Also, if anyone would be willing to look over my code and review it I would really appreciate it!
Thank you, I hope you're having an incredible day!!
- Ori Yonay