mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 09:02:41 +01:00
DroidFish: Don't allow adding a null move to the game tree when the side to move is in check.
This commit is contained in:
@@ -2457,8 +2457,9 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
}
|
||||
|
||||
boolean allowNullMove =
|
||||
gameMode.analysisMode() ||
|
||||
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive());
|
||||
(gameMode.analysisMode() ||
|
||||
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive())) &&
|
||||
!ctrl.inCheck();
|
||||
if (allowNullMove) {
|
||||
lst.add(getString(R.string.add_null_move)); actions.add(ADD_NULL_MOVE);
|
||||
}
|
||||
|
||||
@@ -382,6 +382,11 @@ public class DroidChessController {
|
||||
}
|
||||
}
|
||||
|
||||
/** Return true if the player to move in the current position is in check. */
|
||||
public final synchronized boolean inCheck() {
|
||||
return MoveGen.inCheck(game.tree.currentPos);
|
||||
}
|
||||
|
||||
/** Undo last move. Does not truncate game tree. */
|
||||
public final synchronized void undoMove() {
|
||||
if (game.getLastMove() != null) {
|
||||
|
||||
Reference in New Issue
Block a user