In this position:
r1k5/1p5p/p1b2p2/P5p1/3R4/R1P5/2P1rBPP/6K1 w - - 2 33
FEN does not get rendered for some reason, hence sorry for string representation
If I run search without null move pruning the pv would be:
a3a2 f6f5 h2h3 h7h5 d4d6
But with null move pruning the pv is:
d4d8 c8d8 f2b6 d8d7 b6f2
Engine sacs a rook thinking that 3 fold repetition is forced.
Here's my null move pruning code:
Code: Select all
let inCheck = isSquareAttacked(kingSquare[side], side ^ 1);
// check extension
if (inCheck) depth++;
// null move pruning
if (searchPly && depth >= 3 && inCheck == 0) {
makeNullMove();
score = -negamax(-beta, -beta + 1, depth - 1 - 2);
takeNullMove();
if (timing.stopped == 1) return 0;
if (score >= beta) return beta;
}
let moveList = [];
generateMoves(moveList);
// sort PV move
sortPvMove(moveList);
// loop over moves
for (let count = 0; count < moveList.length; count++) {
sortMoves(count, moveList);
Could you please point out why this is happening and how to prevent this weird behavior?