Add board.ForceSkipTurn() to skip a turn even when in check (use at own peril)
This commit is contained in:
parent
779c7f8fb1
commit
0d6abe1ff0
1 changed files with 23 additions and 7 deletions
|
@ -97,9 +97,10 @@ namespace ChessChallenge.API
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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()
|
||||
/// </summary>
|
||||
public bool TrySkipTurn()
|
||||
{
|
||||
|
@ -113,10 +114,25 @@ namespace ChessChallenge.API
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undo a turn that was succesfully skipped with the TrySkipTurn method
|
||||
/// </summary>
|
||||
public void UndoSkipTurn()
|
||||
/// <summary>
|
||||
/// 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()
|
||||
/// </summary>
|
||||
public void ForceSkipTurn()
|
||||
{
|
||||
hasCachedMoves = false;
|
||||
hasCachedCaptureMoves = false;
|
||||
board.MakeNullMove();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undo a turn that was succesfully skipped with TrySkipTurn() or ForceSkipTurn()
|
||||
/// </summary>
|
||||
public void UndoSkipTurn()
|
||||
{
|
||||
hasCachedMoves = false;
|
||||
hasCachedCaptureMoves = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue