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>
|
/// <summary>
|
||||||
/// Try skip the current turn
|
/// Try skip the current turn.
|
||||||
/// This will fail and return false if in check
|
/// 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
|
/// 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>
|
/// </summary>
|
||||||
public bool TrySkipTurn()
|
public bool TrySkipTurn()
|
||||||
{
|
{
|
||||||
|
@ -114,7 +115,22 @@ namespace ChessChallenge.API
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Undo a turn that was succesfully skipped with the TrySkipTurn method
|
/// 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>
|
/// </summary>
|
||||||
public void UndoSkipTurn()
|
public void UndoSkipTurn()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue