Skip to content

Commit

Permalink
verify boardstate when collecting PV
Browse files Browse the repository at this point in the history
  • Loading branch information
znxftw committed Dec 23, 2024
1 parent 6bc73e2 commit 407d621
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Rudim/Common/TranspositionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ public static List<Move> CollectPrincipalVariation(BoardState boardState)

if (pv.Contains(entry.BestMove))
break;
pv.Add(entry.BestMove);

boardState.MakeMove(entry.BestMove);
if (boardState.IsInCheck(boardState.SideToMove.Other()))
{
boardState.UnmakeMove(entry.BestMove);
break;
}
pv.Add(entry.BestMove);
}

for (int i = pv.Count - 1; i >= 0; i--)
Expand Down

0 comments on commit 407d621

Please sign in to comment.