diff --git a/Chess-Challenge/src/API/Board.cs b/Chess-Challenge/src/API/Board.cs index 9d09624..418aef6 100644 --- a/Chess-Challenge/src/API/Board.cs +++ b/Chess-Challenge/src/API/Board.cs @@ -97,9 +97,10 @@ namespace ChessChallenge.API } /// - /// Try skip the current turn - /// This will fail and return false if in check - /// Note: skipping a turn is not allowed in the game, but it can be used as a search technique + /// Try skip the current turn. + /// This will fail and return false if in check. + /// Note: skipping a turn is not allowed in the game, but it can be used as a search technique. + /// Skipped turns can be undone with UndoSkipTurn() /// public bool TrySkipTurn() { @@ -113,10 +114,25 @@ namespace ChessChallenge.API return true; } - /// - /// Undo a turn that was succesfully skipped with the TrySkipTurn method - /// - public void UndoSkipTurn() + /// + /// Forcibly skips the current turn. + /// Unlike TrySkipTurn(), this will work even when in check, which has some dangerous side-effects if done: + /// 1) Generating 'legal' moves will now include the illegal capture of the king. + /// 2) If the skipped turn is undone, the board will now incorrectly report that the position is not check. + /// Note: skipping a turn is not allowed in the game, but it can be used as a search technique. + /// Skipped turns can be undone with UndoSkipTurn() + /// + public void ForceSkipTurn() + { + hasCachedMoves = false; + hasCachedCaptureMoves = false; + board.MakeNullMove(); + } + + /// + /// Undo a turn that was succesfully skipped with TrySkipTurn() or ForceSkipTurn() + /// + public void UndoSkipTurn() { hasCachedMoves = false; hasCachedCaptureMoves = false;