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 =
|
boolean allowNullMove =
|
||||||
gameMode.analysisMode() ||
|
(gameMode.analysisMode() ||
|
||||||
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive());
|
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive())) &&
|
||||||
|
!ctrl.inCheck();
|
||||||
if (allowNullMove) {
|
if (allowNullMove) {
|
||||||
lst.add(getString(R.string.add_null_move)); actions.add(ADD_NULL_MOVE);
|
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. */
|
/** Undo last move. Does not truncate game tree. */
|
||||||
public final synchronized void undoMove() {
|
public final synchronized void undoMove() {
|
||||||
if (game.getLastMove() != null) {
|
if (game.getLastMove() != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user