B:BD[
5.2229] → [
4.860:924]
const scr = -try negamax(gs, -beta, -alpha, depth - 1);
const scr = blk: {
// PVS
if (found_pv) {
// Once you've found a move with a score that is between alpha and beta,
// the rest of the moves are searched with the goal of proving that they are all bad.
// It's possible to do this a bit faster than a search that worries that one
// of the remaining moves might be good.
const s = -try negamax(gs, -alpha - 1, -alpha, depth - 1);
// If the algorithm finds out that it was wrong, and that one of the
// subsequent moves was better than the first PV move, it has to search again,
// in the normal alpha-beta manner. This happens sometimes, and it's a waste of time,
// but generally not often enough to counteract the savings gained from doing the
// "bad move proof" search referred to earlier.
if (s > alpha and s < beta) {
break :blk -try negamax(gs, -beta, -alpha, depth - 1);
} else {
// Keep the fast search score
break :blk s;
}
} else {
// Normal negamax without PVS
break :blk -try negamax(gs, -beta, -alpha, depth - 1);
}
};