diff --git a/DroidFish/src/org/petero/droidfish/ChessBoard.java b/DroidFish/src/org/petero/droidfish/ChessBoard.java index acfd36b..07a20f4 100644 --- a/DroidFish/src/org/petero/droidfish/ChessBoard.java +++ b/DroidFish/src/org/petero/droidfish/ChessBoard.java @@ -612,8 +612,7 @@ public class ChessBoard extends View { } } else { if (oneTouchMoves) { - ArrayList moves = new MoveGen().pseudoLegalMoves(pos); - moves = MoveGen.removeIllegal(pos, moves); + ArrayList moves = new MoveGen().legalMoves(pos); Move matchingMove = null; int toSq = -1; for (Move m : moves) { diff --git a/DroidFish/src/org/petero/droidfish/book/DroidBook.java b/DroidFish/src/org/petero/droidfish/book/DroidBook.java index 575c9c5..57894b8 100644 --- a/DroidFish/src/org/petero/droidfish/book/DroidBook.java +++ b/DroidFish/src/org/petero/droidfish/book/DroidBook.java @@ -87,8 +87,7 @@ public final class DroidBook { if (bookMoves == null) return null; - ArrayList legalMoves = new MoveGen().pseudoLegalMoves(pos); - legalMoves = MoveGen.removeIllegal(pos, legalMoves); + ArrayList legalMoves = new MoveGen().legalMoves(pos); double sum = 0; final int nMoves = bookMoves.size(); for (int i = 0; i < nMoves; i++) { @@ -122,8 +121,7 @@ public final class DroidBook { // Check legality if (bookMoves != null) { - ArrayList legalMoves = new MoveGen().pseudoLegalMoves(pos); - legalMoves = MoveGen.removeIllegal(pos, legalMoves); + ArrayList legalMoves = new MoveGen().legalMoves(pos); for (int i = 0; i < bookMoves.size(); i++) { BookEntry be = bookMoves.get(i); if (!legalMoves.contains(be.move)) { diff --git a/DroidFish/src/org/petero/droidfish/engine/DroidComputerPlayer.java b/DroidFish/src/org/petero/droidfish/engine/DroidComputerPlayer.java index 70c500b..1bd2886 100644 --- a/DroidFish/src/org/petero/droidfish/engine/DroidComputerPlayer.java +++ b/DroidFish/src/org/petero/droidfish/engine/DroidComputerPlayer.java @@ -336,8 +336,7 @@ public class DroidComputerPlayer { if (moves != null) { sr.searchMoves = moves; } else { - moves = new MoveGen().pseudoLegalMoves(sr.currPos); - moves = MoveGen.removeIllegal(sr.currPos, moves); + moves = new MoveGen().legalMoves(sr.currPos); sr.searchMoves = null; } return moves; diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/GameTree.java b/DroidFish/src/org/petero/droidfish/gamelogic/GameTree.java index 2ad6a5e..3fd346c 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/GameTree.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/GameTree.java @@ -839,8 +839,7 @@ public class GameTree { // Player made null move to resign, causing whiteMove to toggle return pos.whiteMove ? GameState.RESIGN_BLACK : GameState.RESIGN_WHITE; } - ArrayList moves = new MoveGen().pseudoLegalMoves(pos); - moves = MoveGen.removeIllegal(pos, moves); + ArrayList moves = new MoveGen().legalMoves(pos); if (moves.size() == 0) { if (MoveGen.inCheck(pos)) { return pos.whiteMove ? GameState.BLACK_MATE : GameState.WHITE_MATE; diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java b/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java index 05baa7d..e643dba 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java @@ -206,8 +206,7 @@ public class TextIO { public static final void fixupEPSquare(Position pos) { int epSquare = pos.getEpSquare(); if (epSquare >= 0) { - ArrayList moves = MoveGen.instance.pseudoLegalMoves(pos); - moves = MoveGen.removeIllegal(pos, moves); + ArrayList moves = MoveGen.instance.legalMoves(pos); boolean epValid = false; for (Move m : moves) { if (m.to == epSquare) { @@ -417,8 +416,7 @@ public class TextIO { pos.makeMove(move, ui); boolean givesCheck = MoveGen.inCheck(pos); if (givesCheck) { - ArrayList nextMoves = MoveGen.instance.pseudoLegalMoves(pos); - nextMoves = MoveGen.removeIllegal(pos, nextMoves); + ArrayList nextMoves = MoveGen.instance.legalMoves(pos); if (nextMoves.size() == 0) { ret.append('#'); } else { @@ -453,8 +451,7 @@ public class TextIO { public static final boolean isValid(Position pos, Move move) { if (move == null) return false; - ArrayList moves = new MoveGen().pseudoLegalMoves(pos); - moves = MoveGen.removeIllegal(pos, moves); + ArrayList moves = new MoveGen().legalMoves(pos); for (int i = 0; i < moves.size(); i++) if (move.equals(moves.get(i))) return true; diff --git a/DroidFish/src/org/petero/droidfish/gtb/Probe.java b/DroidFish/src/org/petero/droidfish/gtb/Probe.java index 2fe4772..cada149 100644 --- a/DroidFish/src/org/petero/droidfish/gtb/Probe.java +++ b/DroidFish/src/org/petero/droidfish/gtb/Probe.java @@ -180,8 +180,7 @@ public class Probe { /** Return a list of all legal moves that are not known to be non-optimal. * Returns null if no legal move could be excluded. */ public final ArrayList findOptimal(Position pos) { - ArrayList moveList = new MoveGen().pseudoLegalMoves(pos); - moveList = MoveGen.removeIllegal(pos, moveList); + ArrayList moveList = new MoveGen().legalMoves(pos); ArrayList optimalMoves = new ArrayList(); ArrayList unknownMoves = new ArrayList(); final int MATE0 = 100000; @@ -226,8 +225,7 @@ public class Probe { return null; ArrayList> ret = new ArrayList>(); - ArrayList moveList = new MoveGen().pseudoLegalMoves(pos); - moveList = MoveGen.removeIllegal(pos, moveList); + ArrayList moveList = new MoveGen().legalMoves(pos); UndoInfo ui = new UndoInfo(); for (Move m : moveList) { if (m.from != fromSq) diff --git a/DroidFishTest/src/org/petero/droidfish/book/BookTest.java b/DroidFishTest/src/org/petero/droidfish/book/BookTest.java index 75adb3e..9b37bdc 100644 --- a/DroidFishTest/src/org/petero/droidfish/book/BookTest.java +++ b/DroidFishTest/src/org/petero/droidfish/book/BookTest.java @@ -72,8 +72,7 @@ public class BookTest extends TestCase { /** Check that move is a legal move in position pos. */ private void checkValid(Position pos, Move move) { assertTrue(move != null); - ArrayList moveList = new MoveGen().pseudoLegalMoves(pos); - moveList = MoveGen.removeIllegal(pos, moveList); + ArrayList moveList = new MoveGen().legalMoves(pos); assertTrue(moveList.contains(move)); } }