mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-01-30 09:03:50 +01:00
DroidFish: Use helper function MoveGen.legalMoves().
This commit is contained in:
parent
5c161d2101
commit
31d6c0f768
|
@ -612,8 +612,7 @@ public class ChessBoard extends View {
|
|||
}
|
||||
} else {
|
||||
if (oneTouchMoves) {
|
||||
ArrayList<Move> moves = new MoveGen().pseudoLegalMoves(pos);
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<Move> moves = new MoveGen().legalMoves(pos);
|
||||
Move matchingMove = null;
|
||||
int toSq = -1;
|
||||
for (Move m : moves) {
|
||||
|
|
|
@ -87,8 +87,7 @@ public final class DroidBook {
|
|||
if (bookMoves == null)
|
||||
return null;
|
||||
|
||||
ArrayList<Move> legalMoves = new MoveGen().pseudoLegalMoves(pos);
|
||||
legalMoves = MoveGen.removeIllegal(pos, legalMoves);
|
||||
ArrayList<Move> 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<Move> legalMoves = new MoveGen().pseudoLegalMoves(pos);
|
||||
legalMoves = MoveGen.removeIllegal(pos, legalMoves);
|
||||
ArrayList<Move> legalMoves = new MoveGen().legalMoves(pos);
|
||||
for (int i = 0; i < bookMoves.size(); i++) {
|
||||
BookEntry be = bookMoves.get(i);
|
||||
if (!legalMoves.contains(be.move)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Move> moves = new MoveGen().pseudoLegalMoves(pos);
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<Move> moves = new MoveGen().legalMoves(pos);
|
||||
if (moves.size() == 0) {
|
||||
if (MoveGen.inCheck(pos)) {
|
||||
return pos.whiteMove ? GameState.BLACK_MATE : GameState.WHITE_MATE;
|
||||
|
|
|
@ -206,8 +206,7 @@ public class TextIO {
|
|||
public static final void fixupEPSquare(Position pos) {
|
||||
int epSquare = pos.getEpSquare();
|
||||
if (epSquare >= 0) {
|
||||
ArrayList<Move> moves = MoveGen.instance.pseudoLegalMoves(pos);
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<Move> 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<Move> nextMoves = MoveGen.instance.pseudoLegalMoves(pos);
|
||||
nextMoves = MoveGen.removeIllegal(pos, nextMoves);
|
||||
ArrayList<Move> 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<Move> moves = new MoveGen().pseudoLegalMoves(pos);
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<Move> moves = new MoveGen().legalMoves(pos);
|
||||
for (int i = 0; i < moves.size(); i++)
|
||||
if (move.equals(moves.get(i)))
|
||||
return true;
|
||||
|
|
|
@ -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<Move> findOptimal(Position pos) {
|
||||
ArrayList<Move> moveList = new MoveGen().pseudoLegalMoves(pos);
|
||||
moveList = MoveGen.removeIllegal(pos, moveList);
|
||||
ArrayList<Move> moveList = new MoveGen().legalMoves(pos);
|
||||
ArrayList<Move> optimalMoves = new ArrayList<Move>();
|
||||
ArrayList<Move> unknownMoves = new ArrayList<Move>();
|
||||
final int MATE0 = 100000;
|
||||
|
@ -226,8 +225,7 @@ public class Probe {
|
|||
return null;
|
||||
ArrayList<Pair<Integer,Integer>> ret = new ArrayList<Pair<Integer,Integer>>();
|
||||
|
||||
ArrayList<Move> moveList = new MoveGen().pseudoLegalMoves(pos);
|
||||
moveList = MoveGen.removeIllegal(pos, moveList);
|
||||
ArrayList<Move> moveList = new MoveGen().legalMoves(pos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
for (Move m : moveList) {
|
||||
if (m.from != fromSq)
|
||||
|
|
|
@ -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<Move> moveList = new MoveGen().pseudoLegalMoves(pos);
|
||||
moveList = MoveGen.removeIllegal(pos, moveList);
|
||||
ArrayList<Move> moveList = new MoveGen().legalMoves(pos);
|
||||
assertTrue(moveList.contains(move));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user