mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 19:34:08 +01:00
DroidFish: Simplified TextIO.isValid() method.
This commit is contained in:
parent
1f5f5c9522
commit
29f0b8766c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
}
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user