DroidFish: Simplified TextIO.isValid() method.

This commit is contained in:
Peter Osterlund 2012-07-22 09:30:18 +00:00
parent 1f5f5c9522
commit 29f0b8766c
4 changed files with 7 additions and 9 deletions

View File

@ -764,13 +764,13 @@ public class DroidComputerPlayer {
if (canPonder) {
Move bestM = TextIO.stringToMove(sr.currPos, bestMove);
if ((bestM == null) || !TextIO.isValid(sr.currPos, bestM, null))
if ((bestM == null) || !TextIO.isValid(sr.currPos, bestM))
canPonder = false;
if (canPonder) {
Position tmpPos = new Position(sr.currPos);
UndoInfo ui = new UndoInfo();
tmpPos.makeMove(bestM, ui);
if (!TextIO.isValid(tmpPos, nextPonderMove, null))
if (!TextIO.isValid(tmpPos, nextPonderMove))
canPonder = false;
}
}

View File

@ -678,7 +678,7 @@ public class DroidChessController {
for (Move m : pv.pv) {
if (m == null)
break;
if (!TextIO.isValid(tmpPos, m, null))
if (!TextIO.isValid(tmpPos, m))
break;
String moveStr = TextIO.moveToString(tmpPos, m, false);
buf.append(String.format(" %s", moveStr));

View File

@ -125,7 +125,7 @@ public class Game {
Move m = TextIO.UCIstringToMove(str);
if (m != null)
if (!TextIO.isValid(currPos(), m, null))
if (!TextIO.isValid(currPos(), m))
m = null;
if (m == null)
m = TextIO.stringToMove(currPos(), str);

View File

@ -429,13 +429,11 @@ public class TextIO {
* @param moves If non-null, list of valid moves in position pos.
* @return True if move is valid in position pos, false otherwise.
*/
public static final boolean isValid(Position pos, Move move, ArrayList<Move> moves) {
public static final boolean isValid(Position pos, Move move) {
if (move == null)
return false;
if (moves == null) {
moves = new MoveGen().pseudoLegalMoves(pos);
ArrayList<Move> moves = new MoveGen().pseudoLegalMoves(pos);
moves = MoveGen.removeIllegal(pos, moves);
}
for (int i = 0; i < moves.size(); i++)
if (move.equals(moves.get(i)))
return true;