mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
Fix some Android Studio warnings.
This commit is contained in:
parent
bd99154def
commit
eaadffa6b0
|
@ -127,7 +127,7 @@ public class ChessBoardPainter extends JLabel {
|
|||
}
|
||||
}
|
||||
|
||||
private final void drawPiece(Graphics2D g, int xCrd, int yCrd, int p) {
|
||||
private void drawPiece(Graphics2D g, int xCrd, int yCrd, int p) {
|
||||
g.setColor(Piece.isWhite(p) ? Color.WHITE : Color.BLACK);
|
||||
String ps;
|
||||
switch (p) {
|
||||
|
@ -195,10 +195,10 @@ public class ChessBoardPainter extends JLabel {
|
|||
}
|
||||
}
|
||||
|
||||
private final int getXCrd(int x) {
|
||||
private int getXCrd(int x) {
|
||||
return x0 + sqSize * (flipped ? 7 - x : x);
|
||||
}
|
||||
private final int getYCrd(int y) {
|
||||
private int getYCrd(int y) {
|
||||
return y0 + sqSize * (flipped ? y : (7 - y));
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ public class EngineControl {
|
|||
engineThread.start();
|
||||
}
|
||||
|
||||
private final void stopThread() {
|
||||
private void stopThread() {
|
||||
Thread myThread;
|
||||
Search mySearch;
|
||||
synchronized (threadMutex) {
|
||||
|
@ -295,13 +295,13 @@ public class EngineControl {
|
|||
}
|
||||
|
||||
|
||||
private final void setupTT() {
|
||||
private void setupTT() {
|
||||
int nEntries = hashSizeMB > 0 ? hashSizeMB * (1 << 20) / 24 : 1024;
|
||||
int logSize = (int) Math.floor(Math.log(nEntries) / Math.log(2));
|
||||
tt = new TranspositionTable(logSize);
|
||||
}
|
||||
|
||||
private final void setupPosition(Position pos, List<Move> moves) {
|
||||
private void setupPosition(Position pos, List<Move> moves) {
|
||||
UndoInfo ui = new UndoInfo();
|
||||
posHashList = new long[200 + moves.size()];
|
||||
posHashListSize = 0;
|
||||
|
@ -315,7 +315,7 @@ public class EngineControl {
|
|||
/**
|
||||
* Try to find a move to ponder from the transposition table.
|
||||
*/
|
||||
private final Move getPonderMove(Position pos, Move m) {
|
||||
private Move getPonderMove(Position pos, Move m) {
|
||||
if (m == null) return null;
|
||||
Move ret = null;
|
||||
UndoInfo ui = new UndoInfo();
|
||||
|
|
|
@ -37,6 +37,6 @@ public class SearchParams {
|
|||
boolean infinite;
|
||||
|
||||
public SearchParams() {
|
||||
searchMoves = new ArrayList<Move>();
|
||||
searchMoves = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class UCIProtocol {
|
|||
|
||||
public UCIProtocol() {
|
||||
pos = null;
|
||||
moves = new ArrayList<Move>();
|
||||
moves = new ArrayList<>();
|
||||
quit = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ public class ChessBoard extends View {
|
|||
}
|
||||
}
|
||||
|
||||
private final void drawPiece(Canvas canvas, int xCrd, int yCrd, int p) {
|
||||
private void drawPiece(Canvas canvas, int xCrd, int yCrd, int p) {
|
||||
String ps;
|
||||
switch (p) {
|
||||
case Piece.EMPTY:
|
||||
|
@ -218,10 +218,10 @@ public class ChessBoard extends View {
|
|||
}
|
||||
}
|
||||
|
||||
private final int getXCrd(int x) {
|
||||
private int getXCrd(int x) {
|
||||
return x0 + sqSize * (flipped ? 7 - x : x);
|
||||
}
|
||||
private final int getYCrd(int y) {
|
||||
private int getYCrd(int y) {
|
||||
return y0 + sqSize * (flipped ? y : (7 - y));
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ public class CuckooChess extends Activity implements GUIInterface {
|
|||
tmp = settings.getString("numUndo", null);
|
||||
if (tmp != null) numUndo = tmp;
|
||||
}
|
||||
List<String> posHistStr = new ArrayList<String>();
|
||||
List<String> posHistStr = new ArrayList<>();
|
||||
posHistStr.add(fen);
|
||||
posHistStr.add(moves);
|
||||
posHistStr.add(numUndo);
|
||||
|
|
|
@ -54,13 +54,13 @@ public class Book {
|
|||
if (numBookMoves >= 0)
|
||||
return;
|
||||
long t0 = System.currentTimeMillis();
|
||||
bookMap = new HashMap<Long, List<BookEntry>>();
|
||||
bookMap = new HashMap<>();
|
||||
rndGen = new SecureRandom();
|
||||
rndGen.setSeed(System.currentTimeMillis());
|
||||
numBookMoves = 0;
|
||||
try {
|
||||
InputStream inStream = getClass().getResourceAsStream("/book.bin");
|
||||
List<Byte> buf = new ArrayList<Byte>(8192);
|
||||
List<Byte> buf = new ArrayList<>(8192);
|
||||
byte[] tmpBuf = new byte[1024];
|
||||
while (true) {
|
||||
int len = inStream.read(tmpBuf);
|
||||
|
@ -106,7 +106,7 @@ public class Book {
|
|||
private void addToBook(Position pos, Move moveToAdd) {
|
||||
List<BookEntry> ent = bookMap.get(pos.zobristHash());
|
||||
if (ent == null) {
|
||||
ent = new ArrayList<BookEntry>();
|
||||
ent = new ArrayList<>();
|
||||
bookMap.put(pos.zobristHash(), ent);
|
||||
}
|
||||
for (int i = 0; i < ent.size(); i++) {
|
||||
|
|
|
@ -210,7 +210,7 @@ public class ComputerPlayer implements Player {
|
|||
// tt.printStats();
|
||||
|
||||
// Return best move and PV
|
||||
return new TwoReturnValues<Move, String>(bestM, PV);
|
||||
return new TwoReturnValues<>(bestM, PV);
|
||||
}
|
||||
|
||||
private Move findSemiRandomMove(Search sc, MoveGen.MoveList moves) {
|
||||
|
@ -237,7 +237,7 @@ public class ComputerPlayer implements Player {
|
|||
return null;
|
||||
}
|
||||
|
||||
private final static int moveProbWeight(int moveScore, int bestScore) {
|
||||
private static int moveProbWeight(int moveScore, int bestScore) {
|
||||
double d = (bestScore - moveScore) / 100.0;
|
||||
double w = 100*Math.exp(-d*d/2);
|
||||
return (int)Math.ceil(w);
|
||||
|
|
|
@ -290,12 +290,12 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute white_material - black_material. */
|
||||
static final int material(Position pos) {
|
||||
static int material(Position pos) {
|
||||
return pos.wMtrl - pos.bMtrl;
|
||||
}
|
||||
|
||||
/** Compute score based on piece square tables. Positive values are good for white. */
|
||||
private final int pieceSquareEval(Position pos) {
|
||||
private int pieceSquareEval(Position pos) {
|
||||
int score = 0;
|
||||
final int wMtrl = pos.wMtrl;
|
||||
final int bMtrl = pos.bMtrl;
|
||||
|
@ -405,7 +405,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Implement the "when ahead trade pieces, when behind trade pawns" rule. */
|
||||
private final int tradeBonus(Position pos) {
|
||||
private int tradeBonus(Position pos) {
|
||||
final int wM = pos.wMtrl;
|
||||
final int bM = pos.bMtrl;
|
||||
final int wPawn = pos.wMtrlPawns;
|
||||
|
@ -436,7 +436,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Score castling ability. */
|
||||
private final int castleBonus(Position pos) {
|
||||
private int castleBonus(Position pos) {
|
||||
if (pos.getCastleMask() == 0) return 0;
|
||||
|
||||
final int k1 = kt1b[7*8+6] - kt1b[7*8+4];
|
||||
|
@ -464,7 +464,7 @@ public class Evaluate {
|
|||
return wBonus - bBonus;
|
||||
}
|
||||
|
||||
private final int pawnBonus(Position pos) {
|
||||
private int pawnBonus(Position pos) {
|
||||
long key = pos.pawnZobristHash();
|
||||
PawnHashData phd = pawnHash[(int)key & (pawnHash.length - 1)];
|
||||
if (phd.key != key)
|
||||
|
@ -562,7 +562,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute pawn hash data for pos. */
|
||||
private final void computePawnHashData(Position pos, PawnHashData ph) {
|
||||
private void computePawnHashData(Position pos, PawnHashData ph) {
|
||||
int score = 0;
|
||||
|
||||
// Evaluate double pawns and pawn islands
|
||||
|
@ -658,7 +658,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute rook bonus. Rook on open/half-open file. */
|
||||
private final int rookBonus(Position pos) {
|
||||
private int rookBonus(Position pos) {
|
||||
int score = 0;
|
||||
final long wPawns = pos.pieceTypeBB[Piece.WPAWN];
|
||||
final long bPawns = pos.pieceTypeBB[Piece.BPAWN];
|
||||
|
@ -703,7 +703,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute bishop evaluation. */
|
||||
private final int bishopEval(Position pos, int oldScore) {
|
||||
private int bishopEval(Position pos, int oldScore) {
|
||||
int score = 0;
|
||||
final long occupied = pos.whiteBB | pos.blackBB;
|
||||
long wBishops = pos.pieceTypeBB[Piece.WBISHOP];
|
||||
|
@ -828,7 +828,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute king safety for both kings. */
|
||||
private final int kingSafety(Position pos) {
|
||||
private int kingSafety(Position pos) {
|
||||
final int minM = rV + bV;
|
||||
final int m = (pos.wMtrl - pos.wMtrlPawns + pos.bMtrl - pos.bMtrlPawns) / 2;
|
||||
if (m <= minM)
|
||||
|
@ -884,7 +884,7 @@ public class Evaluate {
|
|||
}
|
||||
}
|
||||
|
||||
private final int kingSafetyKPPart(Position pos) {
|
||||
private int kingSafetyKPPart(Position pos) {
|
||||
final long key = pos.pawnZobristHash() ^ pos.kingZobristHash();
|
||||
KingSafetyHashData ksh = kingSafetyHash[(int)key & (kingSafetyHash.length - 1)];
|
||||
if (ksh.key != key) {
|
||||
|
@ -958,7 +958,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Implements special knowledge for some endgame situations. */
|
||||
private final int endGameEval(Position pos, int oldScore) {
|
||||
private int endGameEval(Position pos, int oldScore) {
|
||||
int score = oldScore;
|
||||
if (pos.wMtrl + pos.bMtrl > 6 * rV)
|
||||
return score;
|
||||
|
|
|
@ -182,9 +182,9 @@ public class Game {
|
|||
*/
|
||||
protected boolean handleCommand(String moveStr) {
|
||||
if (moveStr.equals("new")) {
|
||||
moveList = new ArrayList<Move>();
|
||||
uiInfoList = new ArrayList<UndoInfo>();
|
||||
drawOfferList = new ArrayList<Boolean>();
|
||||
moveList = new ArrayList<>();
|
||||
uiInfoList = new ArrayList<>();
|
||||
drawOfferList = new ArrayList<>();
|
||||
currentMove = 0;
|
||||
pendingDrawOffer = false;
|
||||
drawState = GameState.ALIVE;
|
||||
|
@ -305,7 +305,7 @@ public class Game {
|
|||
}
|
||||
|
||||
public List<String> getPosHistory() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
List<String> ret = new ArrayList<>();
|
||||
|
||||
Position pos = new Position(this.pos);
|
||||
for (int i = currentMove; i > 0; i--) {
|
||||
|
@ -423,7 +423,7 @@ public class Game {
|
|||
|
||||
/** Return a list of previous positions in this game, back to the last "zeroing" move. */
|
||||
public ArrayList<Position> getHistory() {
|
||||
ArrayList<Position> posList = new ArrayList<Position>();
|
||||
ArrayList<Position> posList = new ArrayList<>();
|
||||
Position pos = new Position(this.pos);
|
||||
for (int i = currentMove; i > 0; i--) {
|
||||
if (pos.halfMoveClock == 0)
|
||||
|
@ -446,7 +446,7 @@ public class Game {
|
|||
boolean valid;
|
||||
if (rep) {
|
||||
valid = false;
|
||||
List<Position> oldPositions = new ArrayList<Position>();
|
||||
List<Position> oldPositions = new ArrayList<>();
|
||||
if (m != null) {
|
||||
UndoInfo ui = new UndoInfo();
|
||||
Position tmpPos = new Position(pos);
|
||||
|
|
|
@ -366,7 +366,7 @@ public final class MoveGen {
|
|||
{
|
||||
ArrayList<Move> allMoves = pseudoLegalMoves(pos);
|
||||
allMoves = MoveGen.removeIllegal(pos, allMoves);
|
||||
HashSet<String> evMoves = new HashSet<String>();
|
||||
HashSet<String> evMoves = new HashSet<>();
|
||||
for (Move m : moveList)
|
||||
evMoves.add(TextIO.moveToUCIString(m));
|
||||
for (Move m : allMoves)
|
||||
|
@ -967,8 +967,8 @@ public final class MoveGen {
|
|||
moveList.size = length;
|
||||
}
|
||||
|
||||
private final static boolean addPawnMovesByMask(MoveList moveList, Position pos, long mask,
|
||||
int delta, boolean allPromotions) {
|
||||
private static boolean addPawnMovesByMask(MoveList moveList, Position pos, long mask,
|
||||
int delta, boolean allPromotions) {
|
||||
if (mask == 0)
|
||||
return false;
|
||||
long oKingMask = pos.pieceTypeBB[pos.whiteMove ? Piece.BKING : Piece.WKING];
|
||||
|
@ -1008,8 +1008,8 @@ public final class MoveGen {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final static void addPawnDoubleMovesByMask(MoveList moveList, Position pos,
|
||||
long mask, int delta) {
|
||||
private static void addPawnDoubleMovesByMask(MoveList moveList, Position pos,
|
||||
long mask, int delta) {
|
||||
while (mask != 0) {
|
||||
int sq = BitBoard.numberOfTrailingZeros(mask);
|
||||
setMove(moveList, sq + delta, sq, Piece.EMPTY);
|
||||
|
@ -1017,7 +1017,7 @@ public final class MoveGen {
|
|||
}
|
||||
}
|
||||
|
||||
private final static boolean addMovesByMask(MoveList moveList, Position pos, int sq0, long mask) {
|
||||
private static boolean addMovesByMask(MoveList moveList, Position pos, int sq0, long mask) {
|
||||
long oKingMask = pos.pieceTypeBB[pos.whiteMove ? Piece.BKING : Piece.WKING];
|
||||
if ((mask & oKingMask) != 0) {
|
||||
int sq = BitBoard.numberOfTrailingZeros(mask & oKingMask);
|
||||
|
@ -1033,7 +1033,7 @@ public final class MoveGen {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final static void setMove(MoveList moveList, int from, int to, int promoteTo) {
|
||||
private static void setMove(MoveList moveList, int from, int to, int promoteTo) {
|
||||
Move m = moveList.m[moveList.size++];
|
||||
m.from = from;
|
||||
m.to = to;
|
||||
|
@ -1047,7 +1047,7 @@ public final class MoveGen {
|
|||
|
||||
private static final int MAX_MOVES = 256;
|
||||
|
||||
private final MoveList getMoveListObj() {
|
||||
private MoveList getMoveListObj() {
|
||||
MoveList ml;
|
||||
if (moveListsInCache > 0) {
|
||||
ml = (MoveList)moveListCache[--moveListsInCache];
|
||||
|
|
|
@ -85,7 +85,7 @@ public class Parameters {
|
|||
return inst;
|
||||
}
|
||||
public final String[] getParamNames() {
|
||||
ArrayList<String> parNames = new ArrayList<String>();
|
||||
ArrayList<String> parNames = new ArrayList<>();
|
||||
for (Map.Entry<String, ParamBase> e : params.entrySet())
|
||||
if (e.getValue().visible)
|
||||
parNames.add(e.getKey());
|
||||
|
@ -97,7 +97,7 @@ public class Parameters {
|
|||
}
|
||||
|
||||
private static final Parameters inst = new Parameters();
|
||||
private Map<String, ParamBase> params = new TreeMap<String, ParamBase>();
|
||||
private Map<String, ParamBase> params = new TreeMap<>();
|
||||
|
||||
private Parameters() {
|
||||
addPar(new SpinParam("qV", false, -200, 200, 0));
|
||||
|
@ -107,7 +107,7 @@ public class Parameters {
|
|||
addPar(new SpinParam("pV", false, -200, 200, 0));
|
||||
}
|
||||
|
||||
private final void addPar(ParamBase p) {
|
||||
private void addPar(ParamBase p) {
|
||||
params.put(p.name.toLowerCase(), p);
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class Position {
|
|||
}
|
||||
|
||||
/** Move a non-pawn piece to an empty square. */
|
||||
private final void movePieceNotPawn(int from, int to) {
|
||||
private void movePieceNotPawn(int from, int to) {
|
||||
final int piece = squares[from];
|
||||
hashKey ^= psHashKeys[piece][from];
|
||||
hashKey ^= psHashKeys[piece][to];
|
||||
|
@ -562,7 +562,7 @@ public class Position {
|
|||
}
|
||||
}
|
||||
|
||||
private final void removeCastleRights(int square) {
|
||||
private void removeCastleRights(int square) {
|
||||
if (square == Position.getSquare(0, 0)) {
|
||||
setCastleMask(castleMask & ~(1 << Position.A1_CASTLE));
|
||||
} else if (square == Position.getSquare(7, 0)) {
|
||||
|
@ -620,7 +620,7 @@ public class Position {
|
|||
return hash;
|
||||
}
|
||||
|
||||
private final static long getRandomHashVal(int rndNo) {
|
||||
private static long getRandomHashVal(int rndNo) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
byte[] input = new byte[4];
|
||||
|
|
|
@ -418,7 +418,7 @@ public class Search {
|
|||
return bestMove;
|
||||
}
|
||||
|
||||
private final void notifyPV(int depth, int score, boolean uBound, boolean lBound, Move m) {
|
||||
private void notifyPV(int depth, int score, boolean uBound, boolean lBound, Move m) {
|
||||
if (listener != null) {
|
||||
boolean isMate = false;
|
||||
if (score > MATE0 / 2) {
|
||||
|
@ -436,7 +436,7 @@ public class Search {
|
|||
}
|
||||
}
|
||||
|
||||
private final void notifyStats() {
|
||||
private void notifyStats() {
|
||||
long tNow = System.currentTimeMillis();
|
||||
if (listener != null) {
|
||||
int time = (int) (tNow - tStart);
|
||||
|
@ -876,7 +876,7 @@ public class Search {
|
|||
}
|
||||
|
||||
/** Return true if move m2 was made possible by move m1. */
|
||||
private final boolean relatedMoves(Move m1, Move m2) {
|
||||
private boolean relatedMoves(Move m1, Move m2) {
|
||||
if ((m1.from == m1.to) || (m2.from == m2.to))
|
||||
return false;
|
||||
if ((m1.to == m2.from) || (m1.from == m2.to) ||
|
||||
|
@ -886,7 +886,7 @@ public class Search {
|
|||
}
|
||||
|
||||
/** Return true if move should be skipped in order to make engine play weaker. */
|
||||
private final boolean weakPlaySkipMove(Position pos, Move m, int ply) {
|
||||
private boolean weakPlaySkipMove(Position pos, Move m, int ply) {
|
||||
long rndL = pos.zobristHash() ^ Position.psHashKeys[0][m.from] ^
|
||||
Position.psHashKeys[0][m.to] ^ randomSeed;
|
||||
double rnd = ((rndL & 0x7fffffffffffffffL) % 1000000000) / 1e9;
|
||||
|
@ -1207,7 +1207,7 @@ public class Search {
|
|||
m.score = score;
|
||||
}
|
||||
}
|
||||
private final void scoreMoveListMvvLva(MoveGen.MoveList moves) {
|
||||
private void scoreMoveListMvvLva(MoveGen.MoveList moves) {
|
||||
for (int i = 0; i < moves.size; i++) {
|
||||
Move m = moves.m[i];
|
||||
int v = pos.getPiece(m.to);
|
||||
|
@ -1271,7 +1271,7 @@ public class Search {
|
|||
return (reps >= 2);
|
||||
}
|
||||
|
||||
private final void initNodeStats() {
|
||||
private void initNodeStats() {
|
||||
nodes = qNodes = 0;
|
||||
nodesPlyVec = new int[20];
|
||||
nodesDepthVec = new int[20];
|
||||
|
|
|
@ -218,9 +218,9 @@ public class TranspositionTable {
|
|||
public final ArrayList<Move> extractPVMoves(Position rootPos, Move m) {
|
||||
Position pos = new Position(rootPos);
|
||||
m = new Move(m);
|
||||
ArrayList<Move> ret = new ArrayList<Move>();
|
||||
ArrayList<Move> ret = new ArrayList<>();
|
||||
UndoInfo ui = new UndoInfo();
|
||||
List<Long> hashHistory = new ArrayList<Long>();
|
||||
List<Long> hashHistory = new ArrayList<>();
|
||||
MoveGen moveGen = new MoveGen();
|
||||
while (true) {
|
||||
ret.add(m);
|
||||
|
@ -256,7 +256,7 @@ public class TranspositionTable {
|
|||
boolean first = true;
|
||||
TTEntry ent = probe(pos.historyHash());
|
||||
UndoInfo ui = new UndoInfo();
|
||||
ArrayList<Long> hashHistory = new ArrayList<Long>();
|
||||
ArrayList<Long> hashHistory = new ArrayList<>();
|
||||
boolean repetition = false;
|
||||
MoveGen moveGen = MoveGen.instance;
|
||||
while (ent.type != TTEntry.T_EMPTY) {
|
||||
|
@ -301,7 +301,7 @@ public class TranspositionTable {
|
|||
public final void printStats() {
|
||||
int unused = 0;
|
||||
int thisGen = 0;
|
||||
List<Integer> depHist = new ArrayList<Integer>();
|
||||
List<Integer> depHist = new ArrayList<>();
|
||||
final int maxDepth = 20*8;
|
||||
for (int i = 0; i < maxDepth; i++) {
|
||||
depHist.add(0);
|
||||
|
@ -328,11 +328,11 @@ public class TranspositionTable {
|
|||
}
|
||||
}
|
||||
|
||||
private final int h0(long key) {
|
||||
private int h0(long key) {
|
||||
return (int)(key & (table.length - 1));
|
||||
}
|
||||
|
||||
private final int h1(long key) {
|
||||
private int h1(long key) {
|
||||
return (int)((key >> 32) & (table.length - 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public final class TreeLogger {
|
|||
}
|
||||
}
|
||||
|
||||
private final void writeHeader(Position pos) {
|
||||
private void writeHeader(Position pos) {
|
||||
try {
|
||||
byte[] fen = TextIO.toFEN(pos).getBytes();
|
||||
bos.write((byte)(fen.length));
|
||||
|
@ -196,7 +196,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Compute endIndex for all StartNode entries. */
|
||||
private final void computeForwardPointers() {
|
||||
private void computeForwardPointers() {
|
||||
if ((mapBuf.get(127) & (1<<7)) != 0)
|
||||
return;
|
||||
System.out.printf("Computing forward pointers...\n");
|
||||
|
@ -215,7 +215,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Get FEN string for root node position. */
|
||||
private final String getRootNodeFEN() {
|
||||
private String getRootNodeFEN() {
|
||||
int len = mapBuf.get(0);
|
||||
byte[] fenB = new byte[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
|
@ -243,7 +243,7 @@ public final class TreeLogger {
|
|||
|
||||
/** Read a start/end entry.
|
||||
* @return True if entry was a start entry, false if it was an end entry. */
|
||||
private final boolean readEntry(int index, StartEntry se, EndEntry ee) {
|
||||
private boolean readEntry(int index, StartEntry se, EndEntry ee) {
|
||||
int offs = indexToFileOffs(index);
|
||||
for (int i = 0; i < 16; i++)
|
||||
bb.put(i, mapBuf.get(offs + i));
|
||||
|
@ -286,7 +286,7 @@ public final class TreeLogger {
|
|||
an.close();
|
||||
}
|
||||
|
||||
private final void mainLoop(Position rootPos) throws IOException {
|
||||
private void mainLoop(Position rootPos) throws IOException {
|
||||
int currIndex = -1;
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
String prevStr = "";
|
||||
|
@ -326,7 +326,7 @@ public final class TreeLogger {
|
|||
String m = cmdStr;
|
||||
StartEntry se = new StartEntry();
|
||||
EndEntry ee = new EndEntry();
|
||||
ArrayList<Integer> found = new ArrayList<Integer>();
|
||||
ArrayList<Integer> found = new ArrayList<>();
|
||||
for (Integer c : children) {
|
||||
readEntries(c, se, ee);
|
||||
if (TextIO.moveToUCIString(se.move).equals(m))
|
||||
|
@ -392,7 +392,7 @@ public final class TreeLogger {
|
|||
}
|
||||
}
|
||||
|
||||
private final boolean isMove(String cmdStr) {
|
||||
private boolean isMove(String cmdStr) {
|
||||
if (cmdStr.length() != 4)
|
||||
return false;
|
||||
cmdStr = cmdStr.toLowerCase();
|
||||
|
@ -410,9 +410,9 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Return all nodes with a given hash key. */
|
||||
private final ArrayList<Integer> getNodeForHashKey(long hashKey) {
|
||||
private ArrayList<Integer> getNodeForHashKey(long hashKey) {
|
||||
hashKey &= 0x0000ffffffffffffL;
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>();
|
||||
ArrayList<Integer> ret = new ArrayList<>();
|
||||
StartEntry se = new StartEntry();
|
||||
EndEntry ee = new EndEntry();
|
||||
for (int index = 0; index < numEntries; index++) {
|
||||
|
@ -429,7 +429,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Get hash key from an input string. */
|
||||
private final long getHashKey(String s, long defKey) {
|
||||
private long getHashKey(String s, long defKey) {
|
||||
long key = defKey;
|
||||
int idx = s.indexOf(' ');
|
||||
if (idx > 0) {
|
||||
|
@ -458,7 +458,7 @@ public final class TreeLogger {
|
|||
|
||||
/** Get a list of integer parameters from an input string. */
|
||||
final ArrayList<Integer> getArgs(String s, int defVal) {
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>();
|
||||
ArrayList<Integer> ret = new ArrayList<>();
|
||||
String[] split = s.split(" ");
|
||||
try {
|
||||
for (int i = 1; i < split.length; i++)
|
||||
|
@ -479,7 +479,7 @@ public final class TreeLogger {
|
|||
return defVal;
|
||||
}
|
||||
|
||||
private final void printHelp() {
|
||||
private void printHelp() {
|
||||
System.out.printf(" p - Print move sequence\n");
|
||||
System.out.printf(" n - Print node info corresponding to move sequence\n");
|
||||
System.out.printf(" l [move] - List child nodes, optionally only for one move\n");
|
||||
|
@ -493,7 +493,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Read start/end entries for a tree node. Return true if the end entry exists. */
|
||||
private final boolean readEntries(int index, StartEntry se, EndEntry ee) {
|
||||
private boolean readEntries(int index, StartEntry se, EndEntry ee) {
|
||||
boolean isStart = readEntry(index, se, ee);
|
||||
if (isStart) {
|
||||
int eIdx = se.endIndex;
|
||||
|
@ -510,7 +510,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Find the parent node to a node. */
|
||||
private final int findParent(int index) {
|
||||
private int findParent(int index) {
|
||||
if (index >= 0) {
|
||||
StartEntry se = new StartEntry();
|
||||
EndEntry ee = new EndEntry();
|
||||
|
@ -521,8 +521,8 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Find all children of a node. */
|
||||
private final ArrayList<Integer> findChildren(int index) {
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>();
|
||||
private ArrayList<Integer> findChildren(int index) {
|
||||
ArrayList<Integer> ret = new ArrayList<>();
|
||||
StartEntry se = new StartEntry();
|
||||
EndEntry ee = new EndEntry();
|
||||
int child = index + 1;
|
||||
|
@ -542,7 +542,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Get node position in parents children list. */
|
||||
private final int getChildNo(int index) {
|
||||
private int getChildNo(int index) {
|
||||
ArrayList<Integer> childs = findChildren(findParent(index));
|
||||
for (int i = 0; i < childs.size(); i++)
|
||||
if (childs.get(i) == index)
|
||||
|
@ -551,8 +551,8 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Get list of nodes from root position to a node. */
|
||||
private final ArrayList<Integer> getNodeSequence(int index) {
|
||||
ArrayList<Integer> nodes = new ArrayList<Integer>();
|
||||
private ArrayList<Integer> getNodeSequence(int index) {
|
||||
ArrayList<Integer> nodes = new ArrayList<>();
|
||||
nodes.add(index);
|
||||
while (index >= 0) {
|
||||
index = findParent(index);
|
||||
|
@ -563,8 +563,8 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Find list of moves from root node to a node. */
|
||||
private final ArrayList<Move> getMoveSequence(int index) {
|
||||
ArrayList<Move> moves = new ArrayList<Move>();
|
||||
private ArrayList<Move> getMoveSequence(int index) {
|
||||
ArrayList<Move> moves = new ArrayList<>();
|
||||
StartEntry se = new StartEntry();
|
||||
EndEntry ee = new EndEntry();
|
||||
while (index >= 0) {
|
||||
|
@ -577,7 +577,7 @@ public final class TreeLogger {
|
|||
}
|
||||
|
||||
/** Find the position corresponding to a node. */
|
||||
private final Position getPosition(Position rootPos, int index) {
|
||||
private Position getPosition(Position rootPos, int index) {
|
||||
ArrayList<Move> moves = getMoveSequence(index);
|
||||
Position ret = new Position(rootPos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
|
@ -586,10 +586,10 @@ public final class TreeLogger {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final void printNodeInfo(Position rootPos, int index) {
|
||||
private void printNodeInfo(Position rootPos, int index) {
|
||||
printNodeInfo(rootPos, index, "");
|
||||
}
|
||||
private final void printNodeInfo(Position rootPos, int index, String filterMove) {
|
||||
private void printNodeInfo(Position rootPos, int index, String filterMove) {
|
||||
if (index < 0) { // Root node
|
||||
System.out.printf("%8d entries:%d\n", index, numEntries);
|
||||
} else {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ComputerPlayerTest {
|
|||
@Test
|
||||
public void testGetCommand() throws ChessParseError {
|
||||
System.out.println("getCommand");
|
||||
ArrayList<Position> nullHist = new ArrayList<Position>();
|
||||
ArrayList<Position> nullHist = new ArrayList<>();
|
||||
|
||||
Position pos = TextIO.readFEN("7k/5Q2/p5K1/8/8/8/8/8 b - - 99 80");
|
||||
ComputerPlayer cp = new ComputerPlayer();
|
||||
|
|
|
@ -514,7 +514,7 @@ public class EvaluateTest {
|
|||
}
|
||||
|
||||
/** Compute change in eval score for white after making "moveStr" in position "pos". */
|
||||
private final int moveScore(Position pos, String moveStr) {
|
||||
private int moveScore(Position pos, String moveStr) {
|
||||
int score1 = evalWhite(pos);
|
||||
Position tmpPos = new Position(pos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
|
|
|
@ -434,7 +434,7 @@ public class MoveGenTest {
|
|||
MoveGen.MoveList moves = moveGen.pseudoLegalMoves(pos);
|
||||
if (onlyLegal)
|
||||
MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<String> strMoves = new ArrayList<String>();
|
||||
ArrayList<String> strMoves = new ArrayList<>();
|
||||
for (int mi = 0; mi < moves.size; mi++) {
|
||||
Move m = moves.m[mi];
|
||||
String mStr = TextIO.moveToUCIString(m);
|
||||
|
@ -512,7 +512,7 @@ public class MoveGenTest {
|
|||
}
|
||||
if (onlyLegal)
|
||||
MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<String> strMoves = new ArrayList<String>();
|
||||
ArrayList<String> strMoves = new ArrayList<>();
|
||||
for (int mi = 0; mi < moves.size; mi++) {
|
||||
Move m = moves.m[mi];
|
||||
String mStr = TextIO.moveToUCIString(m);
|
||||
|
@ -527,7 +527,7 @@ public class MoveGenTest {
|
|||
MoveGen.MoveList moves = new MoveGen().checkEvasions(pos);
|
||||
if (onlyLegal)
|
||||
MoveGen.removeIllegal(pos, moves);
|
||||
ArrayList<String> strMoves = new ArrayList<String>();
|
||||
ArrayList<String> strMoves = new ArrayList<>();
|
||||
for (int mi = 0; mi < moves.size; mi++) {
|
||||
Move m = moves.m[mi];
|
||||
String mStr = TextIO.moveToUCIString(m);
|
||||
|
|
|
@ -395,9 +395,9 @@ public class PositionTest {
|
|||
"b5", "Nc3", "Nf6", "Nb1", "Ng8", "Nc3", "Nf6", "Nb1", "Ng8", "Nc3", "d5",
|
||||
"cxd6", "Qxd6", "h4", "Be6", "h5", "Nc6", "h6", "o-o-o", "hxg7", "Nf6", "gxh8Q", "Be7"
|
||||
};
|
||||
List<UndoInfo> uiList = new ArrayList<UndoInfo>();
|
||||
List<Long> hashList = new ArrayList<Long>();
|
||||
List<Move> moveList = new ArrayList<Move>();
|
||||
List<UndoInfo> uiList = new ArrayList<>();
|
||||
List<Long> hashList = new ArrayList<>();
|
||||
List<Move> moveList = new ArrayList<>();
|
||||
for (int i = 0; i < moves.length; i++) {
|
||||
uiList.add(new UndoInfo());
|
||||
Move m = TextIO.stringToMove(pos, moves[i]);
|
||||
|
@ -413,7 +413,7 @@ public class PositionTest {
|
|||
pos.unMakeMove(moveList.get(i), uiList.get(i));
|
||||
long h = pos.zobristHash();
|
||||
assertEquals(h, pos.computeZobristHash());
|
||||
assertEquals(h, i > 0 ? hashList.get(i - 1) : h1);
|
||||
assertEquals(h, i > 0 ? (long)hashList.get(i - 1) : h1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.petero.droidfish.gamelogic.TimeControlData.TimeControlField;
|
|||
public class GameTreeTest extends TestCase {
|
||||
|
||||
/** Add a move to the game tree, with no comments or annotations. */
|
||||
private final int addStdMove(GameTree gt, String moveStr) {
|
||||
private int addStdMove(GameTree gt, String moveStr) {
|
||||
return gt.addMove(moveStr, "", 0, "", "");
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class GameTreeTest extends TestCase {
|
|||
assertEquals(2, varList.size());
|
||||
}
|
||||
|
||||
private final String getMoveListAsString(GameTree gt) {
|
||||
private String getMoveListAsString(GameTree gt) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
Pair<List<Node>, Integer> ml = gt.getMoveList();
|
||||
List<Node> lst = ml.first;
|
||||
|
@ -318,9 +318,9 @@ public class GameTreeTest extends TestCase {
|
|||
assertEquals(initialTime, gt.getRemainingTime(false, initialTime));
|
||||
}
|
||||
|
||||
private final List<PgnToken> getAllTokens(String s) {
|
||||
private List<PgnToken> getAllTokens(String s) {
|
||||
PgnScanner sc = new PgnScanner(s);
|
||||
List<PgnToken> ret = new ArrayList<PgnToken>();
|
||||
List<PgnToken> ret = new ArrayList<>();
|
||||
while (true) {
|
||||
PgnToken tok = sc.nextToken();
|
||||
if (tok.type == PgnToken.EOF)
|
||||
|
@ -729,7 +729,7 @@ public class GameTreeTest extends TestCase {
|
|||
assertTrue(tcData2.isSymmetric());
|
||||
assertTrue(tcData.equals(tcData2));
|
||||
|
||||
Map<String,String> headers = new TreeMap<String,String>();
|
||||
Map<String,String> headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals("35/180", headers.get("TimeControl"));
|
||||
assertEquals(null, headers.get("WhiteTimeControl"));
|
||||
|
@ -741,7 +741,7 @@ public class GameTreeTest extends TestCase {
|
|||
tcData2 = gt.getTimeControlData();
|
||||
assertTrue(tcData2.isSymmetric());
|
||||
assertEquals(tcData, tcData2);
|
||||
headers = new TreeMap<String,String>();
|
||||
headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals("35/180", headers.get("TimeControl"));
|
||||
assertEquals(null, headers.get("WhiteTimeControl"));
|
||||
|
@ -757,7 +757,7 @@ public class GameTreeTest extends TestCase {
|
|||
tcData.tcB.add(new TimeControlField(60*1000,20,3004));
|
||||
tcData.tcB.add(new TimeControlField(30*1000,0,0));
|
||||
gt.setTimeControlData(tcData);
|
||||
headers = new TreeMap<String,String>();
|
||||
headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals(null, headers.get("TimeControl"));
|
||||
assertEquals("40/900:20/300.345:10/0+1:0+5", headers.get("WhiteTimeControl"));
|
||||
|
@ -773,7 +773,7 @@ public class GameTreeTest extends TestCase {
|
|||
tcData2 = gt.getTimeControlData();
|
||||
assertTrue(!tcData2.isSymmetric());
|
||||
assertEquals(tcData, tcData2);
|
||||
headers = new TreeMap<String,String>();
|
||||
headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals(null, headers.get("TimeControl"));
|
||||
assertEquals("40/900:20/300.345:10/0+1:0+5", headers.get("WhiteTimeControl"));
|
||||
|
@ -782,7 +782,7 @@ public class GameTreeTest extends TestCase {
|
|||
tcData = new TimeControlData();
|
||||
tcData.setTimeControl(2*60*1000, 0, 12000);
|
||||
gt.setTimeControlData(tcData);
|
||||
headers = new TreeMap<String,String>();
|
||||
headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals("120+12", headers.get("TimeControl"));
|
||||
assertEquals(null, headers.get("WhiteTimeControl"));
|
||||
|
@ -815,10 +815,10 @@ public class GameTreeTest extends TestCase {
|
|||
boolean res = gt.readPGN("[White \"a\"][Black \"b\"] f4 *", options);
|
||||
assertEquals(true, res);
|
||||
|
||||
TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
TreeMap<String,String> headers = new TreeMap<>();
|
||||
headers.put("Event", "test");
|
||||
gt.setHeaders(headers);
|
||||
TreeMap<String,String> newHeaders = new TreeMap<String,String>();
|
||||
TreeMap<String,String> newHeaders = new TreeMap<>();
|
||||
gt.getHeaders(newHeaders);
|
||||
assertEquals("test", newHeaders.get("Event"));
|
||||
|
||||
|
@ -836,7 +836,7 @@ public class GameTreeTest extends TestCase {
|
|||
{
|
||||
GameTree gt = new GameTree(null);
|
||||
gt.readPGN("f3 e5 g4 Qh4", options);
|
||||
TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
TreeMap<String,String> headers = new TreeMap<>();
|
||||
gt.getHeaders(headers);
|
||||
assertEquals("0-1", headers.get("Result"));
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ public class MoveGenTest extends TestCase {
|
|||
if (onlyLegal) {
|
||||
moves = MoveGen.removeIllegal(pos, moves);
|
||||
}
|
||||
ArrayList<String> strMoves = new ArrayList<String>();
|
||||
ArrayList<String> strMoves = new ArrayList<>();
|
||||
for (Move m : moves) {
|
||||
String mStr = TextIO.moveToString(pos, m, true, false);
|
||||
strMoves.add(mStr);
|
||||
|
|
|
@ -347,9 +347,9 @@ public class PositionTest extends TestCase {
|
|||
"b5", "Nc3", "Nf6", "Nb1", "Ng8", "Nc3", "Nf6", "Nb1", "Ng8", "Nc3", "d5",
|
||||
"cxd6", "Qxd6", "h4", "Be6", "h5", "Nc6", "h6", "o-o-o", "hxg7", "Nf6", "gxh8Q", "Be7"
|
||||
};
|
||||
List<UndoInfo> uiList = new ArrayList<UndoInfo>();
|
||||
List<Long> hashList = new ArrayList<Long>();
|
||||
List<Move> moveList = new ArrayList<Move>();
|
||||
List<UndoInfo> uiList = new ArrayList<>();
|
||||
List<Long> hashList = new ArrayList<>();
|
||||
List<Move> moveList = new ArrayList<>();
|
||||
for (int i = 0; i < moves.length; i++) {
|
||||
uiList.add(new UndoInfo());
|
||||
Move m = TextIO.stringToMove(pos, moves[i]);
|
||||
|
@ -365,7 +365,7 @@ public class PositionTest extends TestCase {
|
|||
pos.unMakeMove(moveList.get(i), uiList.get(i));
|
||||
long h = pos.zobristHash();
|
||||
assertEquals(h, pos.computeZobristHash());
|
||||
assertEquals(h, i > 0 ? hashList.get(i - 1) : h1);
|
||||
assertEquals(h, i > 0 ? (long)hashList.get(i - 1) : h1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public class TextIOTest extends TestCase {
|
|||
return wasError;
|
||||
}
|
||||
|
||||
private final static String moveToString(Position pos, Move move, boolean longForm) {
|
||||
private static String moveToString(Position pos, Move move, boolean longForm) {
|
||||
return TextIO.moveToString(pos, move, longForm, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,11 +126,11 @@ public class TimeControlTest extends TestCase {
|
|||
public void testMultiTimeControl() {
|
||||
TimeControl tc = new TimeControl();
|
||||
TimeControlData tcData = new TimeControlData();
|
||||
tcData.tcW = new ArrayList<TimeControlField>();
|
||||
tcData.tcW = new ArrayList<>();
|
||||
tcData.tcW.add(tcf(120*60*1000, 40, 0));
|
||||
tcData.tcW.add(tcf(60*60*1000, 20, 0));
|
||||
tcData.tcW.add(tcf(30*60*1000, 0, 15*1000));
|
||||
tcData.tcB = new ArrayList<TimeControlField>();
|
||||
tcData.tcB = new ArrayList<>();
|
||||
tcData.tcB.add(tcf(5*60*1000, 60, 1000));
|
||||
tc.setTimeControl(tcData);
|
||||
|
||||
|
@ -236,11 +236,11 @@ public class TimeControlTest extends TestCase {
|
|||
public void testSerialize() throws IOException {
|
||||
TimeControl tc = new TimeControl();
|
||||
TimeControlData tcData = new TimeControlData();
|
||||
tcData.tcW = new ArrayList<TimeControlField>();
|
||||
tcData.tcW = new ArrayList<>();
|
||||
tcData.tcW.add(tcf(120*60*1000, 40, 0));
|
||||
tcData.tcW.add(tcf(60*60*1000, 20, 0));
|
||||
tcData.tcW.add(tcf(30*60*1000, 0, 15*1000));
|
||||
tcData.tcB = new ArrayList<TimeControlField>();
|
||||
tcData.tcB = new ArrayList<>();
|
||||
tcData.tcB.add(tcf(5*60*1000, 60, 1000));
|
||||
tc.setTimeControl(tcData);
|
||||
|
||||
|
|
|
@ -13,25 +13,25 @@ public class ProbeResultTest extends TestCase {
|
|||
assertEquals(0, ProbeResult.compareScore(0, 0, 0, 0));
|
||||
assertEquals(0, ProbeResult.compareScore(1, 3, 1, 3));
|
||||
assertEquals(0, ProbeResult.compareScore(-1, 4, -1, 4));
|
||||
assertEquals(true, ProbeResult.compareScore(0, 0, 1, 1) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(1, 1, 1, 2) > 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 1, 0, 0) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 20, -1, 10) > 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 20, 1, 21) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 20, 1, 19) < 0);
|
||||
assertTrue(ProbeResult.compareScore(0, 0, 1, 1) < 0);
|
||||
assertTrue(ProbeResult.compareScore(1, 1, 1, 2) > 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 1, 0, 0) < 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 20, -1, 10) > 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 20, 1, 21) < 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 20, 1, 19) < 0);
|
||||
|
||||
assertEquals(true, ProbeResult.compareScore(1, 0, 0, 0) > 0);
|
||||
assertEquals(true, ProbeResult.compareScore(1, 0, 1, 1) > 0);
|
||||
assertEquals(true, ProbeResult.compareScore(0, 0, 1, 0) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(1, 1, 1, 0) < 0);
|
||||
assertTrue(ProbeResult.compareScore(1, 0, 0, 0) > 0);
|
||||
assertTrue(ProbeResult.compareScore(1, 0, 1, 1) > 0);
|
||||
assertTrue(ProbeResult.compareScore(0, 0, 1, 0) < 0);
|
||||
assertTrue(ProbeResult.compareScore(1, 1, 1, 0) < 0);
|
||||
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 0, 0, 0) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 0, -1, 1) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(0, 0, -1, 0) > 0);
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 1, -1, 0) > 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 0, 0, 0) < 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 0, -1, 1) < 0);
|
||||
assertTrue(ProbeResult.compareScore(0, 0, -1, 0) > 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 1, -1, 0) > 0);
|
||||
|
||||
assertEquals(true, ProbeResult.compareScore(-1, 0, 1, 0) < 0);
|
||||
assertEquals(true, ProbeResult.compareScore(1, 0, -1, 0) > 0);
|
||||
assertTrue(ProbeResult.compareScore(-1, 0, 1, 0) < 0);
|
||||
assertTrue(ProbeResult.compareScore(1, 0, -1, 0) > 0);
|
||||
}
|
||||
|
||||
public void testCompareProbeResult() {
|
||||
|
@ -43,173 +43,173 @@ public class ProbeResultTest extends TestCase {
|
|||
assertEquals(0, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 2)));
|
||||
|
||||
// NONE vs DTM,DTZ,WDL
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, 0, 0)) < 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, 1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, 1, 1)) < 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.NONE, -1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.NONE, -1, 1)) < 0);
|
||||
|
||||
// DTM vs DTM
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTM, 1, 10)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTM, 1, 11)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 3).compareTo(new ProbeResult(Type.DTM, -1, 3)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 3).compareTo(new ProbeResult(Type.DTM, -1, 5)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 5).compareTo(new ProbeResult(Type.DTM, -1, 3)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTM, 1, 10)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTM, 1, 11)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.DTM, -1, 1)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 3).compareTo(new ProbeResult(Type.DTM, -1, 3)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 3).compareTo(new ProbeResult(Type.DTM, -1, 5)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 5).compareTo(new ProbeResult(Type.DTM, -1, 3)) < 0);
|
||||
|
||||
// DTZ vs DTZ
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 10)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 11)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 11).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 3).compareTo(new ProbeResult(Type.DTZ, -1, 3)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 3).compareTo(new ProbeResult(Type.DTZ, -1, 5)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 5).compareTo(new ProbeResult(Type.DTZ, -1, 3)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 10)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 11)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 11).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.DTZ, -1, 1)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 3).compareTo(new ProbeResult(Type.DTZ, -1, 3)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 3).compareTo(new ProbeResult(Type.DTZ, -1, 5)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 5).compareTo(new ProbeResult(Type.DTZ, -1, 3)) < 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) == 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) == 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.WDL, 1, 1)) == 0);
|
||||
|
||||
// DTM vs DTZ
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 11)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 9)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, -1, 11)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, -1, 9)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 9).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 9).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 11)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 1, 9)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, -1, 11)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.DTZ, -1, 9)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 9).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 11).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 9).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 3)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 4)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 3).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 4).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 3)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 4)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 3).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 4).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, -1, 7)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, -1, 9)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 1, 7)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 1, 9)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, -1, 7)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, -1, 9)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 1, 7)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.DTZ, 1, 9)) > 0);
|
||||
|
||||
// DTM vs WDL
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 10).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTM, 1, 10)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 8).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
|
||||
// DTZ vs WDL
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, 1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, 1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 10).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTZ, 1, 10)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.WDL, -1, 1)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 0, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) == 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, 1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.WDL, -1, 1).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, -1, 1)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 8).compareTo(new ProbeResult(Type.WDL, 1, 1)) > 0);
|
||||
|
||||
// Win-in-zero and loss-in-zero
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 1, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, -1, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 1, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, 1, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, -1, 0).compareTo(new ProbeResult(Type.DTM, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTM, 0, 0).compareTo(new ProbeResult(Type.DTM, -1, 0)) < 0);
|
||||
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 1, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, -1, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertEquals(true, new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 1, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) < 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, 1, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, -1, 0).compareTo(new ProbeResult(Type.DTZ, 0, 0)) > 0);
|
||||
assertTrue(new ProbeResult(Type.DTZ, 0, 0).compareTo(new ProbeResult(Type.DTZ, -1, 0)) < 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ChessEngineResolver {
|
|||
}
|
||||
|
||||
public List<ChessEngine> resolveEngines() {
|
||||
List<ChessEngine> result = new ArrayList<ChessEngine>();
|
||||
List<ChessEngine> result = new ArrayList<>();
|
||||
final Intent intent = new Intent(ENGINE_PROVIDER_MARKER);
|
||||
List<ResolveInfo> list = context.getPackageManager()
|
||||
.queryIntentActivities(intent, PackageManager.GET_META_DATA);
|
||||
|
|
|
@ -201,7 +201,7 @@ public class SVGParser {
|
|||
//Util.debug("Parsing numbers from: '" + s + "'");
|
||||
int n = s.length();
|
||||
int p = 0;
|
||||
ArrayList<Float> numbers = new ArrayList<Float>();
|
||||
ArrayList<Float> numbers = new ArrayList<>();
|
||||
boolean skipChar = false;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (skipChar) {
|
||||
|
@ -649,8 +649,8 @@ public class SVGParser {
|
|||
boolean isLinear;
|
||||
float x1, y1, x2, y2;
|
||||
float x, y, radius;
|
||||
ArrayList<Float> positions = new ArrayList<Float>();
|
||||
ArrayList<Integer> colors = new ArrayList<Integer>();
|
||||
ArrayList<Float> positions = new ArrayList<>();
|
||||
ArrayList<Integer> colors = new ArrayList<>();
|
||||
Matrix matrix = null;
|
||||
|
||||
public Gradient createChild(Gradient g) {
|
||||
|
@ -682,7 +682,7 @@ public class SVGParser {
|
|||
}
|
||||
|
||||
private static class StyleSet {
|
||||
HashMap<String, String> styleMap = new HashMap<String, String>();
|
||||
HashMap<String, String> styleMap = new HashMap<>();
|
||||
|
||||
private StyleSet(String string) {
|
||||
String[] styles = string.split(";");
|
||||
|
@ -783,8 +783,8 @@ public class SVGParser {
|
|||
|
||||
boolean whiteMode = false;
|
||||
|
||||
HashMap<String, Shader> gradientMap = new HashMap<String, Shader>();
|
||||
HashMap<String, Gradient> gradientRefMap = new HashMap<String, Gradient>();
|
||||
HashMap<String, Shader> gradientMap = new HashMap<>();
|
||||
HashMap<String, Gradient> gradientRefMap = new HashMap<>();
|
||||
Gradient gradient = null;
|
||||
|
||||
private SVGHandler(Picture picture) {
|
||||
|
|
|
@ -316,8 +316,7 @@ public class ColorPickerPreference
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final Creator<SavedState> CREATOR =
|
||||
new Creator<SavedState>() {
|
||||
public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ButtonActions {
|
|||
private int menuTitle;
|
||||
|
||||
private UIAction mainAction = null;
|
||||
private ArrayList<UIAction> menuActions = new ArrayList<UIAction>();
|
||||
private ArrayList<UIAction> menuActions = new ArrayList<>();
|
||||
|
||||
private static final int maxMenuActions = 6;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ChessBoardPlay extends ChessBoard {
|
|||
protected void drawExtraSquares(Canvas canvas) {
|
||||
}
|
||||
|
||||
private final boolean myColor(int piece) {
|
||||
private boolean myColor(int piece) {
|
||||
return (piece != Piece.EMPTY) && (Piece.isWhite(piece) == pos.whiteMove);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class ChessBoardPlay extends ChessBoard {
|
|||
* @return Matching move if unique.
|
||||
* Boolean indicating if there was at least one match.
|
||||
*/
|
||||
private final Pair<Move, Boolean> matchingMove(int sq1, int sq2, ArrayList<Move> moves) {
|
||||
private Pair<Move, Boolean> matchingMove(int sq1, int sq2, ArrayList<Move> moves) {
|
||||
Move matchingMove = null;
|
||||
boolean anyMatch = false;
|
||||
for (Move m : moves) {
|
||||
|
@ -198,6 +198,6 @@ public class ChessBoardPlay extends ChessBoard {
|
|||
}
|
||||
}
|
||||
}
|
||||
return new Pair<Move, Boolean>(matchingMove, anyMatch);
|
||||
return new Pair<>(matchingMove, anyMatch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ public class DroidFish extends Activity
|
|||
}
|
||||
|
||||
{
|
||||
actions = new HashMap<String, UIAction>();
|
||||
actions = new HashMap<>();
|
||||
addAction(new UIAction() {
|
||||
public String getId() { return "flipboard"; }
|
||||
public int getName() { return R.string.flip_board; }
|
||||
|
@ -613,7 +613,7 @@ public class DroidFish extends Activity
|
|||
return;
|
||||
|
||||
tourGuide = TourGuide.init(this);
|
||||
ArrayList<TourGuide> guides = new ArrayList<TourGuide>();
|
||||
ArrayList<TourGuide> guides = new ArrayList<>();
|
||||
|
||||
TourGuide tg = TourGuide.init(this);
|
||||
tg.setToolTip(new ToolTip()
|
||||
|
@ -821,7 +821,7 @@ public class DroidFish extends Activity
|
|||
} catch (SecurityException e) {
|
||||
DroidFishApp.toast(e.getMessage(), Toast.LENGTH_LONG);
|
||||
}
|
||||
return new Pair<String,String>(pgnOrFen,filename);
|
||||
return new Pair<>(pgnOrFen,filename);
|
||||
}
|
||||
|
||||
private byte[] strToByteArr(String str) {
|
||||
|
@ -1617,7 +1617,7 @@ public class DroidFish extends Activity
|
|||
return;
|
||||
}
|
||||
|
||||
ArrayList<SquareDecoration> sd = new ArrayList<SquareDecoration>();
|
||||
ArrayList<SquareDecoration> sd = new ArrayList<>();
|
||||
for (Pair<Integer,ProbeResult> p : x)
|
||||
sd.add(new SquareDecoration(p.first, p.second));
|
||||
cb.setSquareDecorations(sd);
|
||||
|
@ -1665,9 +1665,9 @@ public class DroidFish extends Activity
|
|||
new DrawerItem(ITEM_SETTINGS, R.string.option_settings),
|
||||
new DrawerItem(ITEM_ABOUT, R.string.option_about)
|
||||
};
|
||||
leftDrawer.setAdapter(new ArrayAdapter<DrawerItem>(this,
|
||||
R.layout.drawer_list_item,
|
||||
leftItems));
|
||||
leftDrawer.setAdapter(new ArrayAdapter<>(this,
|
||||
R.layout.drawer_list_item,
|
||||
leftItems));
|
||||
leftDrawer.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
|
@ -1683,9 +1683,9 @@ public class DroidFish extends Activity
|
|||
new DrawerItem(ITEM_FORCE_MOVE, R.string.option_force_computer_move),
|
||||
new DrawerItem(ITEM_DRAW, R.string.option_draw)
|
||||
};
|
||||
rightDrawer.setAdapter(new ArrayAdapter<DrawerItem>(this,
|
||||
R.layout.drawer_list_item,
|
||||
rightItems));
|
||||
rightDrawer.setAdapter(new ArrayAdapter<>(this,
|
||||
R.layout.drawer_list_item,
|
||||
rightItems));
|
||||
rightDrawer.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
|
@ -1940,7 +1940,7 @@ public class DroidFish extends Activity
|
|||
private void setBoardFlip(boolean matchPlayerNames) {
|
||||
boolean flipped = boardFlipped;
|
||||
if (playerNameFlip && matchPlayerNames && (ctrl != null)) {
|
||||
final TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
final TreeMap<String,String> headers = new TreeMap<>();
|
||||
ctrl.getHeaders(headers);
|
||||
int whiteMatch = nameMatchScore(headers.get("White"), playerName);
|
||||
int blackMatch = nameMatchScore(headers.get("Black"), playerName);
|
||||
|
@ -2085,7 +2085,7 @@ public class DroidFish extends Activity
|
|||
private String ecoInfoStr = "";
|
||||
private int distToEcoTree = 0;
|
||||
private String variantStr = "";
|
||||
private ArrayList<ArrayList<Move>> pvMoves = new ArrayList<ArrayList<Move>>();
|
||||
private ArrayList<ArrayList<Move>> pvMoves = new ArrayList<>();
|
||||
private ArrayList<Move> bookMoves = null;
|
||||
private ArrayList<Move> variantMoves = null;
|
||||
|
||||
|
@ -2178,7 +2178,7 @@ public class DroidFish extends Activity
|
|||
if (pvMovesTmp.size() == 1) {
|
||||
hints = pvMovesTmp.get(0);
|
||||
} else if (pvMovesTmp.size() > 1) {
|
||||
hints = new ArrayList<Move>();
|
||||
hints = new ArrayList<>();
|
||||
for (ArrayList<Move> pv : pvMovesTmp)
|
||||
if (!pv.isEmpty())
|
||||
hints.add(pv.get(0));
|
||||
|
@ -2330,8 +2330,8 @@ public class DroidFish extends Activity
|
|||
final int PASTE = 2;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.copy_game)); actions.add(COPY_GAME);
|
||||
lst.add(getString(R.string.copy_position)); actions.add(COPY_POSITION);
|
||||
lst.add(getString(R.string.paste)); actions.add(PASTE);
|
||||
|
@ -2389,8 +2389,8 @@ public class DroidFish extends Activity
|
|||
final int REPEAT_LAST_MOVE = 6;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.clipboard)); actions.add(CLIPBOARD);
|
||||
if (storageAvailable()) {
|
||||
lst.add(getString(R.string.option_file)); actions.add(FILEMENU);
|
||||
|
@ -2434,8 +2434,7 @@ public class DroidFish extends Activity
|
|||
}
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
return alert;
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private void shareGameOrText(boolean game) {
|
||||
|
@ -2515,8 +2514,8 @@ public class DroidFish extends Activity
|
|||
final int SAVE_GAME = 4;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
if (currFileType() != FT_NONE) {
|
||||
lst.add(getString(R.string.load_last_file)); actions.add(LOAD_LAST_FILE);
|
||||
}
|
||||
|
@ -2659,8 +2658,8 @@ public class DroidFish extends Activity
|
|||
}
|
||||
|
||||
private Dialog selectEngineDialog(final boolean abortOnCancel) {
|
||||
final ArrayList<String> items = new ArrayList<String>();
|
||||
final ArrayList<String> ids = new ArrayList<String>();
|
||||
final ArrayList<String> items = new ArrayList<>();
|
||||
final ArrayList<String> ids = new ArrayList<>();
|
||||
ids.add("stockfish"); items.add(getString(R.string.stockfish_engine));
|
||||
ids.add("cuckoochess"); items.add(getString(R.string.cuckoochess_engine));
|
||||
|
||||
|
@ -2670,11 +2669,11 @@ public class DroidFish extends Activity
|
|||
{
|
||||
ChessEngineResolver resolver = new ChessEngineResolver(this);
|
||||
List<ChessEngine> engines = resolver.resolveEngines();
|
||||
ArrayList<Pair<String,String>> oexEngines = new ArrayList<Pair<String,String>>();
|
||||
ArrayList<Pair<String,String>> oexEngines = new ArrayList<>();
|
||||
for (ChessEngine engine : engines) {
|
||||
if ((engine.getName() != null) && (engine.getFileName() != null) &&
|
||||
(engine.getPackageName() != null)) {
|
||||
oexEngines.add(new Pair<String,String>(EngineUtil.openExchangeFileName(engine),
|
||||
oexEngines.add(new Pair<>(EngineUtil.openExchangeFileName(engine),
|
||||
engine.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -2938,8 +2937,8 @@ public class DroidFish extends Activity
|
|||
final int ADD_NULL_MOVE = 6;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.edit_headers)); actions.add(EDIT_HEADERS);
|
||||
if (ctrl.humansTurn()) {
|
||||
lst.add(getString(R.string.edit_comments)); actions.add(EDIT_COMMENTS);
|
||||
|
@ -2997,7 +2996,7 @@ public class DroidFish extends Activity
|
|||
|
||||
/** Let the user edit the PGN headers. */
|
||||
private void editHeaders() {
|
||||
final TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
final TreeMap<String,String> headers = new TreeMap<>();
|
||||
ctrl.getHeaders(headers);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this);
|
||||
|
@ -3098,8 +3097,8 @@ public class DroidFish extends Activity
|
|||
final int TRUNCATE_VARS = 3;
|
||||
final int HIDE_STATISTICS = 4;
|
||||
final int SHOW_STATISTICS = 5;
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.add_analysis)); actions.add(ADD_ANALYSIS);
|
||||
int numPV = this.numPV;
|
||||
final int maxPV = ctrl.maxPV();
|
||||
|
@ -3289,8 +3288,8 @@ public class DroidFish extends Activity
|
|||
final int AUTO_BACKWARD = 4;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.goto_start_game)); actions.add(GOTO_START_GAME);
|
||||
lst.add(getString(R.string.goto_start_variation)); actions.add(GOTO_START_VAR);
|
||||
if (ctrl.currVariation() > 0) {
|
||||
|
@ -3331,8 +3330,8 @@ public class DroidFish extends Activity
|
|||
final int AUTO_FORWARD = 3;
|
||||
|
||||
setAutoMode(AutoMode.OFF);
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.goto_end_variation)); actions.add(GOTO_END_VAR);
|
||||
if (ctrl.currVariation() < ctrl.numVariations() - 1) {
|
||||
lst.add(getString(R.string.goto_next_variation)); actions.add(GOTO_NEXT_VAR);
|
||||
|
@ -3365,10 +3364,10 @@ public class DroidFish extends Activity
|
|||
}
|
||||
|
||||
private Dialog makeButtonDialog(ButtonActions buttonActions) {
|
||||
List<CharSequence> names = new ArrayList<CharSequence>();
|
||||
final List<UIAction> actions = new ArrayList<UIAction>();
|
||||
List<CharSequence> names = new ArrayList<>();
|
||||
final List<UIAction> actions = new ArrayList<>();
|
||||
|
||||
HashSet<String> used = new HashSet<String>();
|
||||
HashSet<String> used = new HashSet<>();
|
||||
for (UIAction a : buttonActions.getMenuActions()) {
|
||||
if ((a != null) && a.enabled() && !used.contains(a.getId())) {
|
||||
names.add(getString(a.getName()));
|
||||
|
@ -3391,8 +3390,8 @@ public class DroidFish extends Activity
|
|||
final int SELECT_ENGINE = 0;
|
||||
final int SET_ENGINE_OPTIONS = 1;
|
||||
final int CONFIG_NET_ENGINE = 2;
|
||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||
final List<Integer> actions = new ArrayList<Integer>();
|
||||
List<CharSequence> lst = new ArrayList<>();
|
||||
final List<Integer> actions = new ArrayList<>();
|
||||
lst.add(getString(R.string.select_engine)); actions.add(SELECT_ENGINE);
|
||||
if (canSetEngineOptions()) {
|
||||
lst.add(getString(R.string.set_engine_options));
|
||||
|
@ -3998,7 +3997,7 @@ public class DroidFish extends Activity
|
|||
whiteTitleText.setText(getString(R.string.white_square_character) + " " + timeToString(wTime));
|
||||
blackTitleText.setText(getString(R.string.black_square_character) + " " + timeToString(bTime));
|
||||
} else {
|
||||
TreeMap<String,String> headers = new TreeMap<String,String>();
|
||||
TreeMap<String,String> headers = new TreeMap<>();
|
||||
ctrl.getHeaders(headers);
|
||||
whiteTitleText.setText(headers.get("White"));
|
||||
blackTitleText.setText(headers.get("Black"));
|
||||
|
@ -4052,7 +4051,7 @@ public class DroidFish extends Activity
|
|||
static class PgnScreenText implements PgnToken.PgnTokenReceiver,
|
||||
MoveListView.OnLinkClickListener {
|
||||
private SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
private TreeMap<Integer,Node> offs2Node = new TreeMap<Integer,Node>();
|
||||
private TreeMap<Integer,Node> offs2Node = new TreeMap<>();
|
||||
private int prevType = PgnToken.EOF;
|
||||
int nestLevel = 0;
|
||||
boolean col0 = true;
|
||||
|
@ -4074,7 +4073,7 @@ public class DroidFish extends Activity
|
|||
|
||||
PgnScreenText(DroidFish df, PGNOptions options) {
|
||||
this.df = df;
|
||||
nodeToCharPos = new HashMap<Node, NodeInfo>();
|
||||
nodeToCharPos = new HashMap<>();
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
|||
public class FileUtil {
|
||||
/** Read a text file. Return string array with one string per line. */
|
||||
public static String[] readFile(String filename) throws IOException {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
InputStream inStream = new FileInputStream(filename);
|
||||
InputStreamReader inFile = new InputStreamReader(inStream, "UTF-8");
|
||||
BufferedReader inBuf = new BufferedReader(inFile);
|
||||
|
|
|
@ -87,7 +87,7 @@ final class BufferedRandomAccessFileReader {
|
|||
return new String(lineBuf, 0, lineLen);
|
||||
}
|
||||
|
||||
private final int getByte() throws IOException {
|
||||
private int getByte() throws IOException {
|
||||
if (bufPos >= bufLen) {
|
||||
bufStartFilePos = f.getFilePointer();
|
||||
bufLen = f.read(buffer);
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ChessBoardEdit extends ChessBoard {
|
|||
landScape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
|
||||
private final static int getGap(int sqSize) {
|
||||
private static int getGap(int sqSize) {
|
||||
return sqSize / 4;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class ChessBoardEdit extends ChessBoard {
|
|||
y0 = landScape ? 0 : (height - getHeight(sqSize)) / 2;
|
||||
}
|
||||
|
||||
private final int extraPieces(int x, int y) {
|
||||
private int extraPieces(int x, int y) {
|
||||
if (landScape) {
|
||||
if (x == 8) {
|
||||
switch (y) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class EditBoard extends Activity {
|
|||
checkValidAndUpdateMaterialDiff();
|
||||
}
|
||||
|
||||
private final void initUI() {
|
||||
private void initUI() {
|
||||
setContentView(R.layout.editboard);
|
||||
Util.overrideViewAttribs(findViewById(R.id.main));
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class EditBoard extends Activity {
|
|||
final int PASTE_POSITION = 7;
|
||||
final int GET_FEN = 8;
|
||||
|
||||
final ArrayList<DrawerItem> leftItems = new ArrayList<DrawerItem>();
|
||||
final ArrayList<DrawerItem> leftItems = new ArrayList<>();
|
||||
leftItems.add(new DrawerItem(SIDE_TO_MOVE, R.string.side_to_move));
|
||||
leftItems.add(new DrawerItem(CLEAR_BOARD, R.string.clear_board));
|
||||
leftItems.add(new DrawerItem(INITIAL_POS, R.string.initial_position));
|
||||
|
@ -293,9 +293,9 @@ public class EditBoard extends Activity {
|
|||
if (DroidFish.hasFenProvider(getPackageManager()))
|
||||
leftItems.add(new DrawerItem(GET_FEN, R.string.get_fen));
|
||||
|
||||
leftDrawer.setAdapter(new ArrayAdapter<DrawerItem>(this,
|
||||
R.layout.drawer_list_item,
|
||||
leftItems.toArray(new DrawerItem[0])));
|
||||
leftDrawer.setAdapter(new ArrayAdapter<>(this,
|
||||
R.layout.drawer_list_item,
|
||||
leftItems.toArray(new DrawerItem[0])));
|
||||
leftDrawer.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
|
@ -381,12 +381,12 @@ public class EditBoard extends Activity {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final void setSelection(int sq) {
|
||||
private void setSelection(int sq) {
|
||||
cb.setSelection(sq);
|
||||
setEgtbHints(sq);
|
||||
}
|
||||
|
||||
private final void setEgtbHints(int sq) {
|
||||
private void setEgtbHints(int sq) {
|
||||
if (!egtbHints || (sq < 0)) {
|
||||
cb.setSquareDecorations(null);
|
||||
return;
|
||||
|
@ -399,7 +399,7 @@ public class EditBoard extends Activity {
|
|||
return;
|
||||
}
|
||||
|
||||
ArrayList<SquareDecoration> sd = new ArrayList<SquareDecoration>();
|
||||
ArrayList<SquareDecoration> sd = new ArrayList<>();
|
||||
for (Pair<Integer,ProbeResult> p : x)
|
||||
sd.add(new SquareDecoration(p.first, p.second));
|
||||
cb.setSquareDecorations(sd);
|
||||
|
@ -447,7 +447,7 @@ public class EditBoard extends Activity {
|
|||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private final void sendBackResult() {
|
||||
private void sendBackResult() {
|
||||
if (checkValidAndUpdateMaterialDiff()) {
|
||||
setPosFields();
|
||||
String fen = TextIO.toFEN(cb.pos);
|
||||
|
@ -458,19 +458,19 @@ public class EditBoard extends Activity {
|
|||
finish();
|
||||
}
|
||||
|
||||
private final void setPosFields() {
|
||||
private void setPosFields() {
|
||||
setEPFile(getEPFile()); // To handle sideToMove change
|
||||
TextIO.fixupEPSquare(cb.pos);
|
||||
TextIO.removeBogusCastleFlags(cb.pos);
|
||||
}
|
||||
|
||||
private final int getEPFile() {
|
||||
private int getEPFile() {
|
||||
int epSquare = cb.pos.getEpSquare();
|
||||
if (epSquare < 0) return 8;
|
||||
return Position.getX(epSquare);
|
||||
}
|
||||
|
||||
private final void setEPFile(int epFile) {
|
||||
private void setEPFile(int epFile) {
|
||||
int epSquare = -1;
|
||||
if ((epFile >= 0) && (epFile < 8)) {
|
||||
int epRank = cb.pos.whiteMove ? 5 : 2;
|
||||
|
@ -480,7 +480,7 @@ public class EditBoard extends Activity {
|
|||
}
|
||||
|
||||
/** Test if a position is valid and update material diff display. */
|
||||
private final boolean checkValidAndUpdateMaterialDiff() {
|
||||
private boolean checkValidAndUpdateMaterialDiff() {
|
||||
try {
|
||||
MaterialDiff md = Util.getMaterialDiff(cb.pos);
|
||||
whiteFigText.setText(md.white);
|
||||
|
@ -496,7 +496,7 @@ public class EditBoard extends Activity {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final String getParseErrString(ChessParseError e) {
|
||||
private String getParseErrString(ChessParseError e) {
|
||||
if (e.resourceId == -1)
|
||||
return e.getMessage();
|
||||
else
|
||||
|
@ -637,7 +637,7 @@ public class EditBoard extends Activity {
|
|||
return null;
|
||||
}
|
||||
|
||||
private final void setFEN(String fen) {
|
||||
private void setFEN(String fen) {
|
||||
if (fen == null)
|
||||
return;
|
||||
try {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class EditOptions extends Activity {
|
|||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private final void initUI() {
|
||||
private void initUI() {
|
||||
String title = getString(R.string.edit_options_title);
|
||||
if (engineName != null)
|
||||
title = title + ": " + engineName;
|
||||
|
@ -272,9 +272,9 @@ public class EditOptions extends Activity {
|
|||
});
|
||||
}
|
||||
|
||||
private final void sendBackResult() {
|
||||
private void sendBackResult() {
|
||||
if (uciOpts != null) {
|
||||
TreeMap<String, String> uciMap = new TreeMap<String,String>();
|
||||
TreeMap<String, String> uciMap = new TreeMap<>();
|
||||
for (String name : uciOpts.getOptionNames()) {
|
||||
UCIOptions.OptionBase o = uciOpts.getOption(name);
|
||||
if (o != null) {
|
||||
|
|
|
@ -59,7 +59,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
|
||||
public class EditPGN extends ListActivity {
|
||||
static ArrayList<GameInfo> gamesInFile = new ArrayList<GameInfo>();
|
||||
static ArrayList<GameInfo> gamesInFile = new ArrayList<>();
|
||||
static boolean cacheValid = false;
|
||||
PGNFile pgnFile;
|
||||
ProgressDialog progress;
|
||||
|
@ -246,7 +246,7 @@ public class EditPGN extends ListActivity {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final void showList() {
|
||||
private void showList() {
|
||||
progress = null;
|
||||
removeDialog(PROGRESS_DIALOG);
|
||||
setContentView(R.layout.select_game);
|
||||
|
@ -422,7 +422,7 @@ public class EditPGN extends ListActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final boolean readFile() {
|
||||
private boolean readFile() {
|
||||
String fileName = pgnFile.getName();
|
||||
if (!fileName.equals(lastFileName))
|
||||
defaultItem = 0;
|
||||
|
@ -431,7 +431,7 @@ public class EditPGN extends ListActivity {
|
|||
return true;
|
||||
Pair<GameInfoResult, ArrayList<GameInfo>> p = pgnFile.getGameInfo(this, progress);
|
||||
if (p.first != GameInfoResult.OK) {
|
||||
gamesInFile = new ArrayList<GameInfo>();
|
||||
gamesInFile = new ArrayList<>();
|
||||
switch (p.first) {
|
||||
case OUT_OF_MEMORY:
|
||||
runOnUiThread(new Runnable() {
|
||||
|
@ -462,7 +462,7 @@ public class EditPGN extends ListActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
private final void sendBackResult(GameInfo gi) {
|
||||
private void sendBackResult(GameInfo gi) {
|
||||
String pgn = pgnFile.readOneGame(gi);
|
||||
if (pgn != null) {
|
||||
String pgnToken = (new ObjectCache()).storeString(pgn);
|
||||
|
@ -474,19 +474,18 @@ public class EditPGN extends ListActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final void deleteGame(GameInfo gi) {
|
||||
private void deleteGame(GameInfo gi) {
|
||||
if (pgnFile.deleteGame(gi, gamesInFile)) {
|
||||
ListView lv = getListView();
|
||||
int pos = lv.pointToPosition(0,0);
|
||||
aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile);
|
||||
aa = new ArrayAdapter<>(this, R.layout.select_game_list_item, gamesInFile);
|
||||
setListAdapter(aa);
|
||||
String s = filterText.getText().toString();
|
||||
aa.getFilter().filter(s);
|
||||
lv.setSelection(pos);
|
||||
// Update lastModTime, since current change has already been handled
|
||||
String fileName = pgnFile.getName();
|
||||
long modTime = new File(fileName).lastModified();
|
||||
lastModTime = modTime;
|
||||
lastModTime = new File(fileName).lastModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FENFile {
|
|||
/** Read all FEN strings (one per line) in a file. */
|
||||
public final Pair<FenInfoResult,ArrayList<FenInfo>> getFenInfo(Activity activity,
|
||||
final ProgressDialog progress) {
|
||||
ArrayList<FenInfo> fensInFile = new ArrayList<FenInfo>();
|
||||
ArrayList<FenInfo> fensInFile = new ArrayList<>();
|
||||
try {
|
||||
int percent = -1;
|
||||
fensInFile.clear();
|
||||
|
@ -94,15 +94,15 @@ public class FENFile {
|
|||
}
|
||||
}
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
return new Pair<FenInfoResult,ArrayList<FenInfo>>(FenInfoResult.CANCEL, null);
|
||||
return new Pair<>(FenInfoResult.CANCEL, null);
|
||||
}
|
||||
f.close();
|
||||
} catch (IOException e) {
|
||||
} catch (OutOfMemoryError e) {
|
||||
fensInFile.clear();
|
||||
fensInFile = null;
|
||||
return new Pair<FenInfoResult,ArrayList<FenInfo>>(FenInfoResult.OUT_OF_MEMORY, null);
|
||||
return new Pair<>(FenInfoResult.OUT_OF_MEMORY, null);
|
||||
}
|
||||
return new Pair<FenInfoResult,ArrayList<FenInfo>>(FenInfoResult.OK, fensInFile);
|
||||
return new Pair<>(FenInfoResult.OK, fensInFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
|
||||
public class LoadFEN extends ListActivity {
|
||||
private static ArrayList<FenInfo> fensInFile = new ArrayList<FenInfo>();
|
||||
private static ArrayList<FenInfo> fensInFile = new ArrayList<>();
|
||||
private static boolean cacheValid = false;
|
||||
private FENFile fenFile;
|
||||
private ProgressDialog progress;
|
||||
|
@ -197,7 +197,7 @@ public class LoadFEN extends ListActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
private final void showList() {
|
||||
private void showList() {
|
||||
progress = null;
|
||||
removeProgressDialog();
|
||||
setContentView(R.layout.load_fen);
|
||||
|
@ -323,7 +323,7 @@ public class LoadFEN extends ListActivity {
|
|||
((DialogFragment)f).dismiss();
|
||||
}
|
||||
|
||||
private final boolean readFile() {
|
||||
private boolean readFile() {
|
||||
String fileName = fenFile.getName();
|
||||
if (!fileName.equals(lastFileName))
|
||||
defaultItem = 0;
|
||||
|
@ -333,7 +333,7 @@ public class LoadFEN extends ListActivity {
|
|||
fenFile = new FENFile(fileName);
|
||||
Pair<FenInfoResult, ArrayList<FenInfo>> p = fenFile.getFenInfo(this, progress);
|
||||
if (p.first != FenInfoResult.OK) {
|
||||
fensInFile = new ArrayList<FenInfo>();
|
||||
fensInFile = new ArrayList<>();
|
||||
if (p.first == FenInfoResult.OUT_OF_MEMORY) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -352,7 +352,7 @@ public class LoadFEN extends ListActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
private final void sendBackResult(FenInfo fi, boolean toast) {
|
||||
private void sendBackResult(FenInfo fi, boolean toast) {
|
||||
String fen = fi.fen;
|
||||
if (fen != null) {
|
||||
if (toast)
|
||||
|
|
|
@ -68,7 +68,7 @@ public class LoadScid extends ListActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private static Vector<GameInfo> gamesInFile = new Vector<GameInfo>();
|
||||
private static Vector<GameInfo> gamesInFile = new Vector<>();
|
||||
private static boolean cacheValid = false;
|
||||
private String fileName;
|
||||
private ProgressDialog progress;
|
||||
|
@ -229,7 +229,7 @@ public class LoadScid extends ListActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
private final void showList() {
|
||||
private void showList() {
|
||||
progress = null;
|
||||
removeProgressDialog();
|
||||
final ArrayAdapter<GameInfo> aa =
|
||||
|
@ -294,7 +294,7 @@ public class LoadScid extends ListActivity {
|
|||
((DialogFragment)f).dismiss();
|
||||
}
|
||||
|
||||
private final boolean readFile(Cursor cursor) {
|
||||
private boolean readFile(Cursor cursor) {
|
||||
if (!fileName.equals(lastFileName))
|
||||
defaultItem = 0;
|
||||
long modTime = new File(fileName).lastModified();
|
||||
|
@ -346,7 +346,7 @@ public class LoadScid extends ListActivity {
|
|||
gamesInFile.add(gi);
|
||||
}
|
||||
|
||||
private final void sendBackResult(final GameInfo gi) {
|
||||
private void sendBackResult(final GameInfo gi) {
|
||||
if (resultSentBack)
|
||||
return;
|
||||
resultSentBack = true;
|
||||
|
|
|
@ -169,7 +169,7 @@ public class PGNFile {
|
|||
public final Pair<GameInfoResult,ArrayList<GameInfo>> getGameInfo(Activity activity,
|
||||
final ProgressDialog progress,
|
||||
int maxGames) {
|
||||
ArrayList<GameInfo> gamesInFile = new ArrayList<GameInfo>();
|
||||
ArrayList<GameInfo> gamesInFile = new ArrayList<>();
|
||||
gamesInFile.clear();
|
||||
long fileLen = 0;
|
||||
BufferedInput f = null;
|
||||
|
@ -350,7 +350,7 @@ public class PGNFile {
|
|||
}
|
||||
}
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
return new Pair<GameInfoResult,ArrayList<GameInfo>>(GameInfoResult.CANCEL, null);
|
||||
return new Pair<>(GameInfoResult.CANCEL, null);
|
||||
}
|
||||
gi = new GameInfo();
|
||||
gi.startPos = filePos;
|
||||
|
@ -368,18 +368,18 @@ public class PGNFile {
|
|||
} catch (OutOfMemoryError e) {
|
||||
gamesInFile.clear();
|
||||
gamesInFile = null;
|
||||
return new Pair<GameInfoResult,ArrayList<GameInfo>>(GameInfoResult.OUT_OF_MEMORY, null);
|
||||
return new Pair<>(GameInfoResult.OUT_OF_MEMORY, null);
|
||||
} finally {
|
||||
if (f != null)
|
||||
f.close();
|
||||
}
|
||||
if ((gamesInFile.size() == 0) && (fileLen > 0))
|
||||
return new Pair<GameInfoResult,ArrayList<GameInfo>>(GameInfoResult.NOT_PGN, null);
|
||||
return new Pair<>(GameInfoResult.NOT_PGN, null);
|
||||
|
||||
return new Pair<GameInfoResult,ArrayList<GameInfo>>(GameInfoResult.OK, gamesInFile);
|
||||
return new Pair<>(GameInfoResult.OK, gamesInFile);
|
||||
}
|
||||
|
||||
private final void mkDirs() {
|
||||
private void mkDirs() {
|
||||
File dirFile = fileName.getParentFile();
|
||||
dirFile.mkdirs();
|
||||
}
|
||||
|
@ -465,9 +465,9 @@ public class PGNFile {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final static void copyData(RandomAccessFile fileReader,
|
||||
RandomAccessFile fileWriter,
|
||||
long nBytes) throws IOException {
|
||||
private static void copyData(RandomAccessFile fileReader,
|
||||
RandomAccessFile fileWriter,
|
||||
long nBytes) throws IOException {
|
||||
byte[] buffer = new byte[8192];
|
||||
while (nBytes > 0) {
|
||||
int nRead = fileReader.read(buffer, 0, Math.min(buffer.length, (int)nBytes));
|
||||
|
|
|
@ -178,7 +178,7 @@ public class SeekBarPreference extends Preference
|
|||
return layout;
|
||||
}
|
||||
|
||||
private final String valToString() {
|
||||
private String valToString() {
|
||||
return String.format(Locale.US, "%.1f%%", currVal*0.1);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
/** Read len bytes from offs in file f. */
|
||||
private final static byte[] readBytes(RandomAccessFile f, long offs, int len) throws IOException {
|
||||
private static byte[] readBytes(RandomAccessFile f, long offs, int len) throws IOException {
|
||||
byte[] ret = new byte[len];
|
||||
f.seek(offs);
|
||||
f.readFully(ret);
|
||||
|
@ -135,7 +135,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
/** Convert len bytes starting at offs in buf to an integer. */
|
||||
private final static int extractInt(byte[] buf, int offs, int len) {
|
||||
private static int extractInt(byte[] buf, int offs, int len) {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
int b = buf[offs + i];
|
||||
|
@ -156,7 +156,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
private final static class BitVector {
|
||||
private List<Byte> buf = new ArrayList<Byte>();
|
||||
private List<Byte> buf = new ArrayList<>();
|
||||
private int length = 0;
|
||||
|
||||
void addBit(boolean value) {
|
||||
|
@ -191,7 +191,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
/** Converts a position to a byte array. */
|
||||
private final static byte[] positionToByteArray(Position pos) {
|
||||
private static byte[] positionToByteArray(Position pos) {
|
||||
BitVector bits = new BitVector();
|
||||
bits.addBits(0, 8); // Header byte
|
||||
for (int x = 0; x < 8; x++) {
|
||||
|
@ -251,7 +251,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
final static ArrayList<Integer> getHashIndices(byte[] encodedPos, CtbFile ctb) throws IOException {
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>();
|
||||
ArrayList<Integer> ret = new ArrayList<>();
|
||||
int hash = getHashValue(encodedPos);
|
||||
for (int n = 0; n < 0x7fffffff; n = 2*n + 1) {
|
||||
int c = (hash & n) + n;
|
||||
|
@ -289,7 +289,7 @@ class CtgBook implements IOpeningBook {
|
|||
0x274c7e7c, 0x1e8be65c, 0x2fa0b0bb, 0x1eb6c371
|
||||
};
|
||||
|
||||
private final static int getHashValue(byte[] encodedPos) {
|
||||
private static int getHashValue(byte[] encodedPos) {
|
||||
int hash = 0;
|
||||
int tmp = 0;
|
||||
for (int i = 0; i < encodedPos.length; i++) {
|
||||
|
@ -349,7 +349,7 @@ class CtgBook implements IOpeningBook {
|
|||
return pd;
|
||||
}
|
||||
|
||||
private final PositionData findInPage(int page, byte[] encodedPos) throws IOException {
|
||||
private PositionData findInPage(int page, byte[] encodedPos) throws IOException {
|
||||
byte[] pageBuf = readBytes(f, (page+1)*4096L, 4096);
|
||||
try {
|
||||
int nPos = extractInt(pageBuf, 0, 2);
|
||||
|
@ -400,7 +400,7 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
final ArrayList<BookEntry> getBookMoves() {
|
||||
ArrayList<BookEntry> entries = new ArrayList<BookEntry>();
|
||||
ArrayList<BookEntry> entries = new ArrayList<>();
|
||||
int nMoves = (moveBytes - 1) / 2;
|
||||
for (int mi = 0; mi < nMoves; mi++) {
|
||||
int move = extractInt(buf, posLen + 1 + mi * 2, 1);
|
||||
|
@ -448,7 +448,7 @@ class CtgBook implements IOpeningBook {
|
|||
int dy;
|
||||
}
|
||||
|
||||
private final static MoveInfo MI(int piece, int pieceNo, int dx, int dy) {
|
||||
private static MoveInfo MI(int piece, int pieceNo, int dx, int dy) {
|
||||
MoveInfo mi = new MoveInfo();
|
||||
mi.piece = piece;
|
||||
mi.pieceNo = pieceNo;
|
||||
|
@ -627,7 +627,7 @@ class CtgBook implements IOpeningBook {
|
|||
moveInfo[0xfe] = MI(Piece.WQUEEN , 1, -3, +3);
|
||||
}
|
||||
|
||||
private final static int findPiece(Position pos, int piece, int pieceNo) {
|
||||
private static int findPiece(Position pos, int piece, int pieceNo) {
|
||||
for (int x = 0; x < 8; x++)
|
||||
for (int y = 0; y < 8; y++) {
|
||||
int sq = Position.getSquare(x, y);
|
||||
|
@ -638,7 +638,7 @@ class CtgBook implements IOpeningBook {
|
|||
return -1;
|
||||
}
|
||||
|
||||
private final Move decodeMove(Position pos, int moveCode) {
|
||||
private Move decodeMove(Position pos, int moveCode) {
|
||||
MoveInfo mi = moveInfo[moveCode];
|
||||
if (mi == null)
|
||||
return null;
|
||||
|
@ -656,13 +656,13 @@ class CtgBook implements IOpeningBook {
|
|||
}
|
||||
}
|
||||
|
||||
private final static int mirrorSquareColor(int sq) {
|
||||
private static int mirrorSquareColor(int sq) {
|
||||
int x = Position.getX(sq);
|
||||
int y = 7 - Position.getY(sq);
|
||||
return Position.getSquare(x, y);
|
||||
}
|
||||
|
||||
private final static int mirrorPieceColor(int piece) {
|
||||
private static int mirrorPieceColor(int piece) {
|
||||
if (Piece.isWhite(piece)) {
|
||||
piece = Piece.makeBlack(piece);
|
||||
} else {
|
||||
|
@ -671,7 +671,7 @@ class CtgBook implements IOpeningBook {
|
|||
return piece;
|
||||
}
|
||||
|
||||
private final static Position mirrorPosColor(Position pos) {
|
||||
private static Position mirrorPosColor(Position pos) {
|
||||
Position ret = new Position(pos);
|
||||
for (int sq = 0; sq < 64; sq++) {
|
||||
int mSq = mirrorSquareColor(sq);
|
||||
|
@ -696,7 +696,7 @@ class CtgBook implements IOpeningBook {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final static Move mirrorMoveColor(Move m) {
|
||||
private static Move mirrorMoveColor(Move m) {
|
||||
if (m == null) return null;
|
||||
Move ret = new Move(m);
|
||||
ret.from = mirrorSquareColor(m.from);
|
||||
|
@ -705,13 +705,13 @@ class CtgBook implements IOpeningBook {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final static int mirrorSquareLeftRight(int sq) {
|
||||
private static int mirrorSquareLeftRight(int sq) {
|
||||
int x = 7 - Position.getX(sq);
|
||||
int y = Position.getY(sq);
|
||||
return Position.getSquare(x, y);
|
||||
}
|
||||
|
||||
private final static Position mirrorPosLeftRight(Position pos) {
|
||||
private static Position mirrorPosLeftRight(Position pos) {
|
||||
Position ret = new Position(pos);
|
||||
for (int sq = 0; sq < 64; sq++) {
|
||||
int mSq = mirrorSquareLeftRight(sq);
|
||||
|
@ -728,7 +728,7 @@ class CtgBook implements IOpeningBook {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final static Move mirrorMoveLeftRight(Move m) {
|
||||
private static Move mirrorMoveLeftRight(Move m) {
|
||||
if (m == null) return null;
|
||||
Move ret = new Move(m);
|
||||
ret.from = mirrorSquareLeftRight(m.from);
|
||||
|
|
|
@ -119,7 +119,7 @@ public final class DroidBook {
|
|||
public final synchronized Pair<String,ArrayList<Move>> getAllBookMoves(Position pos,
|
||||
boolean localized) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ArrayList<Move> bookMoveList = new ArrayList<Move>();
|
||||
ArrayList<Move> bookMoveList = new ArrayList<>();
|
||||
ArrayList<BookEntry> bookMoves = getBook().getBookEntries(pos);
|
||||
|
||||
// Check legality
|
||||
|
@ -165,10 +165,10 @@ public final class DroidBook {
|
|||
ret.append(percent);
|
||||
}
|
||||
}
|
||||
return new Pair<String, ArrayList<Move>>(ret.toString(), bookMoveList);
|
||||
return new Pair<>(ret.toString(), bookMoveList);
|
||||
}
|
||||
|
||||
private final double scaleWeight(double w) {
|
||||
private double scaleWeight(double w) {
|
||||
if (w <= 0)
|
||||
return 0;
|
||||
if (options == null)
|
||||
|
@ -176,7 +176,7 @@ public final class DroidBook {
|
|||
return Math.pow(w, Math.exp(-options.random));
|
||||
}
|
||||
|
||||
private final IOpeningBook getBook() {
|
||||
private IOpeningBook getBook() {
|
||||
if (externalBook.enabled()) {
|
||||
return externalBook;
|
||||
} else if (ecoBook.enabled()) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class EcoBook implements IOpeningBook {
|
|||
@Override
|
||||
public ArrayList<BookEntry> getBookEntries(Position pos) {
|
||||
ArrayList<Move> moves = EcoDb.getInstance().getMoves(pos);
|
||||
ArrayList<BookEntry> entries = new ArrayList<BookEntry>();
|
||||
ArrayList<BookEntry> entries = new ArrayList<>();
|
||||
for (int i = 0; i < moves.size(); i++) {
|
||||
BookEntry be = new BookEntry(moves.get(i));
|
||||
be.weight = 10000 - i;
|
||||
|
|
|
@ -74,8 +74,8 @@ public class EcoDb {
|
|||
|
||||
/** Get ECO classification for a given tree node. Also returns distance in plies to "ECO tree". */
|
||||
public Result getEco(GameTree gt) {
|
||||
ArrayList<Integer> treePath = new ArrayList<Integer>(); // Path to restore gt to original node
|
||||
ArrayList<Pair<GameTree.Node,Boolean>> toCache = new ArrayList<Pair<GameTree.Node,Boolean>>();
|
||||
ArrayList<Integer> treePath = new ArrayList<>(); // Path to restore gt to original node
|
||||
ArrayList<Pair<GameTree.Node,Boolean>> toCache = new ArrayList<>();
|
||||
|
||||
int nodeIdx = -1;
|
||||
int distToEcoTree = 0;
|
||||
|
@ -93,7 +93,7 @@ public class EcoDb {
|
|||
}
|
||||
Short idx = posHashToNodeIdx.get(gt.currentPos.zobristHash());
|
||||
boolean inEcoTree = idx != null;
|
||||
toCache.add(new Pair<GameTree.Node,Boolean>(node, inEcoTree));
|
||||
toCache.add(new Pair<>(node, inEcoTree));
|
||||
|
||||
if (idx != null) {
|
||||
Node ecoNode = readNode(idx);
|
||||
|
@ -181,7 +181,7 @@ public class EcoDb {
|
|||
|
||||
/** Get all moves in the ECO tree from a given position. */
|
||||
public ArrayList<Move> getMoves(Position pos) {
|
||||
ArrayList<Move> moves = new ArrayList<Move>();
|
||||
ArrayList<Move> moves = new ArrayList<>();
|
||||
long hash = pos.zobristHash();
|
||||
Short idx = posHashToNodeIdx.get(hash);
|
||||
if (idx != null) {
|
||||
|
@ -248,9 +248,9 @@ public class EcoDb {
|
|||
|
||||
/** Constructor. */
|
||||
private EcoDb() {
|
||||
posHashToNodeIdx = new HashMap<Long, Short>();
|
||||
posHashToNodeIdx2 = new HashMap<Long, ArrayList<Short>>();
|
||||
gtNodeToIdx = new WeakLRUCache<GameTree.Node, CacheEntry>(50);
|
||||
posHashToNodeIdx = new HashMap<>();
|
||||
posHashToNodeIdx2 = new HashMap<>();
|
||||
gtNodeToIdx = new WeakLRUCache<>(50);
|
||||
try {
|
||||
ByteArrayOutputStream bufStream = new ByteArrayOutputStream();
|
||||
InputStream inStream = DroidFishApp.getContext().getAssets().open("eco.dat");
|
||||
|
@ -275,7 +275,7 @@ public class EcoDb {
|
|||
nodesBuffer = new byte[nNodes * 12];
|
||||
System.arraycopy(buf, 0, nodesBuffer, 0, nNodes * 12);
|
||||
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
ArrayList<String> names = new ArrayList<>();
|
||||
int idx = (nNodes + 1) * 12;
|
||||
int start = idx;
|
||||
for (int i = idx; i < buf.length; i++) {
|
||||
|
@ -308,7 +308,7 @@ public class EcoDb {
|
|||
} else if (node.ecoIdx != -1) {
|
||||
ArrayList<Short> lst = null;
|
||||
if (posHashToNodeIdx2.get(hash) == null) {
|
||||
lst = new ArrayList<Short>();
|
||||
lst = new ArrayList<>();
|
||||
posHashToNodeIdx2.put(hash, lst);
|
||||
} else {
|
||||
lst = posHashToNodeIdx2.get(hash);
|
||||
|
|
|
@ -64,7 +64,7 @@ final class InternalBook implements IOpeningBook {
|
|||
ArrayList<BookEntry> ents = bookMap.get(pos.zobristHash());
|
||||
if (ents == null)
|
||||
return null;
|
||||
ArrayList<BookEntry> ret = new ArrayList<BookEntry>();
|
||||
ArrayList<BookEntry> ret = new ArrayList<>();
|
||||
for (BookEntry be : ents) {
|
||||
BookEntry be2 = new BookEntry(be.move);
|
||||
be2.weight = (float)(Math.sqrt(be.weight) * 100 + 1);
|
||||
|
@ -82,13 +82,13 @@ final class InternalBook implements IOpeningBook {
|
|||
if (numBookMoves >= 0)
|
||||
return;
|
||||
// long t0 = System.currentTimeMillis();
|
||||
bookMap = new HashMap<Long, ArrayList<BookEntry>>();
|
||||
bookMap = new HashMap<>();
|
||||
numBookMoves = 0;
|
||||
try {
|
||||
InputStream inStream = getClass().getResourceAsStream("/book.bin");
|
||||
if (inStream == null)
|
||||
throw new IOException();
|
||||
List<Byte> buf = new ArrayList<Byte>(8192);
|
||||
List<Byte> buf = new ArrayList<>(8192);
|
||||
byte[] tmpBuf = new byte[1024];
|
||||
while (true) {
|
||||
int len = inStream.read(tmpBuf);
|
||||
|
@ -131,10 +131,10 @@ final class InternalBook implements IOpeningBook {
|
|||
|
||||
|
||||
/** Add a move to a position in the opening book. */
|
||||
private final void addToBook(Position pos, Move moveToAdd) {
|
||||
private void addToBook(Position pos, Move moveToAdd) {
|
||||
ArrayList<BookEntry> ent = bookMap.get(pos.zobristHash());
|
||||
if (ent == null) {
|
||||
ent = new ArrayList<BookEntry>();
|
||||
ent = new ArrayList<>();
|
||||
bookMap.put(pos.zobristHash(), ent);
|
||||
}
|
||||
for (int i = 0; i < ent.size(); i++) {
|
||||
|
|
|
@ -66,7 +66,7 @@ class PolyglotBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
// Castle flags
|
||||
if (pos.h1Castle()) key ^= hashRandoms[768 + 0];
|
||||
if (pos.h1Castle()) key ^= hashRandoms[768];
|
||||
if (pos.a1Castle()) key ^= hashRandoms[768 + 1];
|
||||
if (pos.h8Castle()) key ^= hashRandoms[768 + 2];
|
||||
if (pos.a8Castle()) key ^= hashRandoms[768 + 3];
|
||||
|
@ -300,7 +300,7 @@ class PolyglotBook implements IOpeningBook {
|
|||
data = new byte[16];
|
||||
}
|
||||
|
||||
private final long getBytes(int start, int len) {
|
||||
private long getBytes(int start, int len) {
|
||||
long ret = 0;
|
||||
int stop = start + len;
|
||||
for (int i = start; i < stop; i++) {
|
||||
|
@ -326,7 +326,7 @@ class PolyglotBook implements IOpeningBook {
|
|||
|
||||
int from = Position.getSquare(fromFile, fromRow);
|
||||
int to = Position.getSquare(toFile, toRow);
|
||||
int promoteTo = Piece.EMPTY;
|
||||
int promoteTo;
|
||||
switch (prom) {
|
||||
case 1: promoteTo = wtm ? Piece.WKNIGHT : Piece.BKNIGHT; break;
|
||||
case 2: promoteTo = wtm ? Piece.WBISHOP : Piece.BBISHOP; break;
|
||||
|
@ -345,17 +345,16 @@ class PolyglotBook implements IOpeningBook {
|
|||
if ((from == 60) && (pos.getPiece(from) == Piece.BKING)) {
|
||||
if (to == 56+7)
|
||||
to = 56+6;
|
||||
else if (to == 56+0)
|
||||
else if (to == 56)
|
||||
to = 56+2;
|
||||
}
|
||||
|
||||
Move m = new Move(from, to, promoteTo);
|
||||
return m;
|
||||
return new Move(from, to, promoteTo);
|
||||
}
|
||||
final int getWeight() { return (int)getBytes(10, 2); }
|
||||
}
|
||||
|
||||
private final void readEntry(RandomAccessFile f, long entNo, PGBookEntry ent) throws IOException {
|
||||
private void readEntry(RandomAccessFile f, long entNo, PGBookEntry ent) throws IOException {
|
||||
f.seek(entNo * 16);
|
||||
if (f.read(ent.data) != 16) {
|
||||
for (int i = 0; i < 16; i++) ent.data[i] = 0;
|
||||
|
@ -363,7 +362,7 @@ class PolyglotBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
/** Return true if key1 < key2, when compared as unsigned longs. */
|
||||
private final boolean keyLess(long key1, long key2) {
|
||||
private boolean keyLess(long key1, long key2) {
|
||||
if ((key1 < 0) == (key2 < 0)) { // Same sign, normal compare
|
||||
return key1 < key2;
|
||||
} else { // The negative number is largest
|
||||
|
@ -395,7 +394,7 @@ class PolyglotBook implements IOpeningBook {
|
|||
}
|
||||
|
||||
// Read all entries with matching hash key
|
||||
ArrayList<BookEntry> ret = new ArrayList<BookEntry>();
|
||||
ArrayList<BookEntry> ret = new ArrayList<>();
|
||||
long entNo = hi;
|
||||
while (entNo < numEntries) {
|
||||
readEntry(f, entNo, ent);
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DroidComputerPlayer {
|
|||
private final DroidBook book;
|
||||
private EngineOptions engineOptions = new EngineOptions();
|
||||
/** Pending UCI options to send when engine becomes idle. */
|
||||
private Map<String,String> pendingOptions = new TreeMap<String,String>();
|
||||
private Map<String,String> pendingOptions = new TreeMap<>();
|
||||
|
||||
/** Set when "ucinewgame" needs to be sent. */
|
||||
private boolean newGame = false;
|
||||
|
@ -365,7 +365,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Decide what moves to search. Filters out non-optimal moves if tablebases are used. */
|
||||
private final ArrayList<Move> movesToSearch(SearchRequest sr) {
|
||||
private ArrayList<Move> movesToSearch(SearchRequest sr) {
|
||||
ArrayList<Move> moves = null;
|
||||
ArrayList<Move> legalMoves = new MoveGen().legalMoves(sr.currPos);
|
||||
if (engineOptions.rootProbe)
|
||||
|
@ -450,7 +450,7 @@ public class DroidComputerPlayer {
|
|||
handleQueue();
|
||||
}
|
||||
|
||||
private final void handleQueue() {
|
||||
private void handleQueue() {
|
||||
if (engineState.state == MainState.DEAD) {
|
||||
engineState.engine = "";
|
||||
engineState.setState(MainState.IDLE);
|
||||
|
@ -519,7 +519,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Determine what to do next when in idle state. */
|
||||
private final void handleIdleState() {
|
||||
private void handleIdleState() {
|
||||
SearchRequest sr = searchRequest;
|
||||
if (sr == null)
|
||||
return;
|
||||
|
@ -640,7 +640,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
private final void startEngine() {
|
||||
private void startEngine() {
|
||||
myAssert(uciEngine == null);
|
||||
myAssert(engineMonitor == null);
|
||||
myAssert(engineState.state == MainState.DEAD);
|
||||
|
@ -678,7 +678,7 @@ public class DroidComputerPlayer {
|
|||
private final static long guiUpdateInterval = 100;
|
||||
private long lastGUIUpdate = 0;
|
||||
|
||||
private final void monitorLoop(UCIEngine uci) {
|
||||
private void monitorLoop(UCIEngine uci) {
|
||||
while (true) {
|
||||
int timeout = getReadTimeout();
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
|
@ -706,7 +706,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Process one line of data from the engine. */
|
||||
private final synchronized void processEngineOutput(UCIEngine uci, String s) {
|
||||
private synchronized void processEngineOutput(UCIEngine uci, String s) {
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
return;
|
||||
|
||||
|
@ -775,7 +775,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Handle reading of UCI options. Return true when finished. */
|
||||
private final boolean readUCIOption(UCIEngine uci, String s) {
|
||||
private boolean readUCIOption(UCIEngine uci, String s) {
|
||||
String[] tokens = tokenize(s);
|
||||
if (tokens[0].equals("uciok"))
|
||||
return true;
|
||||
|
@ -799,7 +799,7 @@ public class DroidComputerPlayer {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final void reportMove(String bestMove, Move nextPonderMove) {
|
||||
private void reportMove(String bestMove, Move nextPonderMove) {
|
||||
SearchRequest sr = searchRequest;
|
||||
boolean canPonder = true;
|
||||
|
||||
|
@ -836,7 +836,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Convert a string to tokens by splitting at whitespace characters. */
|
||||
private final String[] tokenize(String cmdLine) {
|
||||
private String[] tokenize(String cmdLine) {
|
||||
cmdLine = cmdLine.trim();
|
||||
return cmdLine.split("\\s+");
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ public class DroidComputerPlayer {
|
|||
* @param move The move that may have to be made before claiming draw.
|
||||
* @return The draw string that claims the draw, or empty string if draw claim not valid.
|
||||
*/
|
||||
private final static String canClaimDraw(Position pos, long[] posHashList, int posHashListSize, Move move) {
|
||||
private static String canClaimDraw(Position pos, long[] posHashList, int posHashListSize, Move move) {
|
||||
String drawStr = "";
|
||||
if (canClaimDraw50(pos)) {
|
||||
drawStr = "draw 50";
|
||||
|
@ -866,11 +866,11 @@ public class DroidComputerPlayer {
|
|||
return drawStr;
|
||||
}
|
||||
|
||||
private final static boolean canClaimDraw50(Position pos) {
|
||||
private static boolean canClaimDraw50(Position pos) {
|
||||
return (pos.halfMoveClock >= 100);
|
||||
}
|
||||
|
||||
private final static boolean canClaimDrawRep(Position pos, long[] posHashList, int posHashListSize, int posHashFirstNew) {
|
||||
private static boolean canClaimDrawRep(Position pos, long[] posHashList, int posHashListSize, int posHashFirstNew) {
|
||||
int reps = 0;
|
||||
for (int i = posHashListSize - 4; i >= 0; i -= 2) {
|
||||
if (pos.zobristHash() == posHashList[i]) {
|
||||
|
@ -897,18 +897,18 @@ public class DroidComputerPlayer {
|
|||
private int statHash = 0;
|
||||
private int statSelDepth = 0;
|
||||
private int statNps = 0;
|
||||
private ArrayList<String> statPV = new ArrayList<String>();
|
||||
private ArrayList<String> statPV = new ArrayList<>();
|
||||
private String statCurrMove = "";
|
||||
private int statCurrMoveNr = 0;
|
||||
|
||||
private ArrayList<PvInfo> statPvInfo = new ArrayList<PvInfo>();
|
||||
private ArrayList<PvInfo> statPvInfo = new ArrayList<>();
|
||||
|
||||
private boolean depthModified = false;
|
||||
private boolean currMoveModified = false;
|
||||
private boolean pvModified = false;
|
||||
private boolean statsModified = false;
|
||||
|
||||
private final void clearInfo() {
|
||||
private void clearInfo() {
|
||||
statCurrDepth = statPVDepth = statScore = 0;
|
||||
statIsMate = statUpperBound = statLowerBound = false;
|
||||
statTime = 0;
|
||||
|
@ -925,7 +925,7 @@ public class DroidComputerPlayer {
|
|||
statCurrMoveNr = 0;
|
||||
}
|
||||
|
||||
private final synchronized int getReadTimeout() {
|
||||
private synchronized int getReadTimeout() {
|
||||
boolean needGuiUpdate = depthModified || currMoveModified || pvModified || statsModified;
|
||||
int timeout = 2000000000;
|
||||
if (needGuiUpdate) {
|
||||
|
@ -936,7 +936,7 @@ public class DroidComputerPlayer {
|
|||
return timeout;
|
||||
}
|
||||
|
||||
private final void parseInfoCmd(String[] tokens) {
|
||||
private void parseInfoCmd(String[] tokens) {
|
||||
try {
|
||||
boolean havePvData = false;
|
||||
int nTokens = tokens.length;
|
||||
|
@ -1003,7 +1003,7 @@ public class DroidComputerPlayer {
|
|||
statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, 0, 0, 0, false, false, false, new ArrayList<Move>()));
|
||||
while (statPvInfo.size() <= pvNum)
|
||||
statPvInfo.add(null);
|
||||
ArrayList<Move> moves = new ArrayList<Move>();
|
||||
ArrayList<Move> moves = new ArrayList<>();
|
||||
int nMoves = statPV.size();
|
||||
for (i = 0; i < nMoves; i++)
|
||||
moves.add(TextIO.UCIstringToMove(statPV.get(i)));
|
||||
|
@ -1019,7 +1019,7 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
|
||||
/** Notify GUI about search statistics. */
|
||||
private final synchronized void notifyGUI() {
|
||||
private synchronized void notifyGUI() {
|
||||
if (Thread.currentThread().isInterrupted())
|
||||
return;
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ public class DroidComputerPlayer {
|
|||
lastGUIUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private final static void myAssert(boolean b) {
|
||||
private static void myAssert(boolean b) {
|
||||
if (!b)
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class ExternalEngine extends UCIEngineBase {
|
|||
}
|
||||
|
||||
/** Reduce too large hash sizes. */
|
||||
private final static int getHashMB(EngineOptions engineOptions) {
|
||||
private static int getHashMB(EngineOptions engineOptions) {
|
||||
int hashMB = engineOptions.hashMB;
|
||||
if (hashMB > 16 && !engineOptions.unSafeHash) {
|
||||
int maxMem = (int)(Runtime.getRuntime().maxMemory() / (1024*1024));
|
||||
|
@ -332,7 +332,7 @@ public class ExternalEngine extends UCIEngineBase {
|
|||
return to.getAbsolutePath();
|
||||
}
|
||||
|
||||
private final void chmod(String exePath) throws IOException {
|
||||
private void chmod(String exePath) throws IOException {
|
||||
if (!EngineUtil.chmod(exePath))
|
||||
throw new IOException("chmod failed");
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class InternalStockFish extends ExternalEngine {
|
|||
setOption("Skill Level", strength/50);
|
||||
}
|
||||
|
||||
private final long readCheckSum(File f) {
|
||||
private long readCheckSum(File f) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(f);
|
||||
|
@ -75,7 +75,7 @@ public class InternalStockFish extends ExternalEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private final void writeCheckSum(File f, long checkSum) {
|
||||
private void writeCheckSum(File f, long checkSum) {
|
||||
DataOutputStream dos = null;
|
||||
try {
|
||||
OutputStream os = new FileOutputStream(f);
|
||||
|
@ -87,7 +87,7 @@ public class InternalStockFish extends ExternalEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private final long computeAssetsCheckSum(String sfExe) {
|
||||
private long computeAssetsCheckSum(String sfExe) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = context.getAssets().open(sfExe);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Locale;
|
|||
|
||||
/** Implements line-based text communication between threads. */
|
||||
public class LocalPipe {
|
||||
private LinkedList<String> lines = new LinkedList<String>();
|
||||
private LinkedList<String> lines = new LinkedList<>();
|
||||
private boolean closed = false;
|
||||
|
||||
/** Write a line to the pipe. */
|
||||
|
|
|
@ -65,7 +65,7 @@ public class NetworkEngine extends UCIEngineBase {
|
|||
}
|
||||
|
||||
/** Create socket connection to remote server. */
|
||||
private final synchronized void connect() {
|
||||
private synchronized void connect() {
|
||||
if (socket == null) {
|
||||
String host = null;
|
||||
String port = null;
|
||||
|
|
|
@ -181,7 +181,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
|||
String defVal = null;
|
||||
String minVal = null;
|
||||
String maxVal = null;
|
||||
ArrayList<String> var = new ArrayList<String>();
|
||||
ArrayList<String> var = new ArrayList<>();
|
||||
try {
|
||||
for (; i < tokens.length; i++) {
|
||||
if (tokens[i].equals("default")) {
|
||||
|
|
|
@ -223,18 +223,18 @@ public class UCIOptions implements Serializable, Cloneable {
|
|||
}
|
||||
|
||||
UCIOptions() {
|
||||
names = new ArrayList<String>();
|
||||
options = new TreeMap<String, OptionBase>();
|
||||
names = new ArrayList<>();
|
||||
options = new TreeMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UCIOptions clone() throws CloneNotSupportedException {
|
||||
UCIOptions copy = new UCIOptions();
|
||||
|
||||
copy.names = new ArrayList<String>();
|
||||
copy.names = new ArrayList<>();
|
||||
copy.names.addAll(names);
|
||||
|
||||
copy.options = new TreeMap<String, OptionBase>();
|
||||
copy.options = new TreeMap<>();
|
||||
for (Map.Entry<String, OptionBase> e : options.entrySet())
|
||||
copy.options.put(e.getKey(), e.getValue().clone());
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class CuckooChessEngine extends UCIEngineBase {
|
|||
|
||||
public CuckooChessEngine(Report report) {
|
||||
pos = null;
|
||||
moves = new ArrayList<Move>();
|
||||
moves = new ArrayList<>();
|
||||
quit = false;
|
||||
guiToEngine = new LocalPipe();
|
||||
engineToGui = new LocalPipe();
|
||||
|
@ -100,7 +100,7 @@ public class CuckooChessEngine extends UCIEngineBase {
|
|||
setOption("strength", strength);
|
||||
}
|
||||
|
||||
private final void mainLoop(LocalPipe is, LocalPipe os) {
|
||||
private void mainLoop(LocalPipe is, LocalPipe os) {
|
||||
String line;
|
||||
while ((line = is.readLine()) != null) {
|
||||
handleCommand(line, os);
|
||||
|
@ -137,7 +137,7 @@ public class CuckooChessEngine extends UCIEngineBase {
|
|||
guiToEngine.addLine(data);
|
||||
}
|
||||
|
||||
private final void handleCommand(String cmdLine, LocalPipe os) {
|
||||
private void handleCommand(String cmdLine, LocalPipe os) {
|
||||
String[] tokens = tokenize(cmdLine);
|
||||
try {
|
||||
String cmd = tokens[0];
|
||||
|
@ -269,14 +269,14 @@ public class CuckooChessEngine extends UCIEngineBase {
|
|||
}
|
||||
}
|
||||
|
||||
private final void initEngine(LocalPipe os) {
|
||||
private void initEngine(LocalPipe os) {
|
||||
if (engine == null) {
|
||||
engine = new DroidEngineControl(os);
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert a string to tokens by splitting at whitespace characters. */
|
||||
private final String[] tokenize(String cmdLine) {
|
||||
private String[] tokenize(String cmdLine) {
|
||||
cmdLine = cmdLine.trim();
|
||||
return cmdLine.split("\\s+");
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ public class DroidEngineControl {
|
|||
}
|
||||
|
||||
|
||||
private final void setupTT() {
|
||||
private void setupTT() {
|
||||
int nEntries = hashSizeMB > 0 ? hashSizeMB * (1 << 20) / 24 : 1024;
|
||||
int logSize = (int) Math.floor(Math.log(nEntries) / Math.log(2));
|
||||
tt = new TranspositionTable(logSize);
|
||||
|
|
|
@ -37,6 +37,6 @@ public class SearchParams {
|
|||
boolean infinite;
|
||||
|
||||
public SearchParams() {
|
||||
searchMoves = new ArrayList<Move>();
|
||||
searchMoves = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -636,7 +636,7 @@ public class DroidChessController {
|
|||
/** Add ECO classification headers. */
|
||||
public final synchronized void addECO() {
|
||||
EcoDb.Result r = game.tree.getGameECO();
|
||||
Map<String,String> headers = new TreeMap<String,String>();
|
||||
Map<String,String> headers = new TreeMap<>();
|
||||
headers.put("ECO", r.eco.isEmpty() ? null : r.eco);
|
||||
headers.put("Opening", r.opn.isEmpty() ? null : r.opn);
|
||||
headers.put("Variation", r.var.isEmpty() ? null : r.var);
|
||||
|
@ -674,7 +674,7 @@ public class DroidChessController {
|
|||
}
|
||||
|
||||
/** Return true if localized piece names should be used. */
|
||||
private final boolean localPt() {
|
||||
private boolean localPt() {
|
||||
switch (pgnOptions.view.pieceType) {
|
||||
case PGNOptions.PT_ENGLISH:
|
||||
return false;
|
||||
|
@ -705,7 +705,7 @@ public class DroidChessController {
|
|||
private int distToEcoTree = 0; // Number of plies since game was in the "ECO tree".
|
||||
|
||||
private Move ponderMove = null;
|
||||
private ArrayList<PvInfo> pvInfoV = new ArrayList<PvInfo>();
|
||||
private ArrayList<PvInfo> pvInfoV = new ArrayList<>();
|
||||
private int pvInfoSearchId = -1; // Search ID corresponding to pvInfoV
|
||||
|
||||
public final void clearSearchInfo(int id) {
|
||||
|
@ -720,7 +720,7 @@ public class DroidChessController {
|
|||
setSearchInfo(id);
|
||||
}
|
||||
|
||||
private final void setSearchInfo(final int id) {
|
||||
private void setSearchInfo(final int id) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < pvInfoV.size(); i++) {
|
||||
PvInfo pvi = pvInfoV.get(i);
|
||||
|
@ -770,10 +770,10 @@ public class DroidChessController {
|
|||
}
|
||||
final String statStr = statStrTmp.toString();
|
||||
final String newPV = buf.toString();
|
||||
final ArrayList<ArrayList<Move>> pvMoves = new ArrayList<ArrayList<Move>>();
|
||||
final ArrayList<ArrayList<Move>> pvMoves = new ArrayList<>();
|
||||
for (int i = 0; i < pvInfoV.size(); i++) {
|
||||
if (ponderMove != null) {
|
||||
ArrayList<Move> tmp = new ArrayList<Move>();
|
||||
ArrayList<Move> tmp = new ArrayList<>();
|
||||
tmp.add(ponderMove);
|
||||
for (Move m : pvInfoV.get(i).pv)
|
||||
tmp.add(m);
|
||||
|
@ -934,7 +934,7 @@ public class DroidChessController {
|
|||
}
|
||||
|
||||
/** Discard current search. Return true if GUI update needed. */
|
||||
private final boolean abortSearch() {
|
||||
private boolean abortSearch() {
|
||||
ponderMove = null;
|
||||
searchId++;
|
||||
if (computerPlayer == null)
|
||||
|
@ -946,7 +946,7 @@ public class DroidChessController {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final void updateBookHints() {
|
||||
private void updateBookHints() {
|
||||
if (game != null) {
|
||||
Pair<String, ArrayList<Move>> bi = computerPlayer.getBookHints(game.currPos(), localPt());
|
||||
EcoDb.Result ecoData = EcoDb.getInstance().getEco(game.tree);
|
||||
|
@ -955,7 +955,7 @@ public class DroidChessController {
|
|||
}
|
||||
}
|
||||
|
||||
private final void updateGameMode() {
|
||||
private void updateGameMode() {
|
||||
if (game != null) {
|
||||
boolean gamePaused = !gameMode.clocksActive() || (humansTurn() && guiPaused);
|
||||
game.setGamePaused(gamePaused);
|
||||
|
@ -972,7 +972,7 @@ public class DroidChessController {
|
|||
}
|
||||
|
||||
/** Start/stop computer thinking/analysis as appropriate. */
|
||||
private final void updateComputeThreads() {
|
||||
private void updateComputeThreads() {
|
||||
boolean alive = game.tree.getGameState() == GameState.ALIVE;
|
||||
boolean analysis = gameMode.analysisMode() && alive;
|
||||
boolean computersTurn = !humansTurn() && alive;
|
||||
|
@ -1021,7 +1021,7 @@ public class DroidChessController {
|
|||
}
|
||||
}
|
||||
|
||||
private final synchronized void makeComputerMove(int id, final String cmd, final Move ponder) {
|
||||
private synchronized void makeComputerMove(int id, final String cmd, final Move ponder) {
|
||||
if (searchId != id)
|
||||
return;
|
||||
searchId++;
|
||||
|
@ -1043,7 +1043,7 @@ public class DroidChessController {
|
|||
gui.movePlayed(game.prevPos(), game.tree.currentNode.move, true);
|
||||
}
|
||||
|
||||
private final void setPlayerNames(Game game) {
|
||||
private void setPlayerNames(Game game) {
|
||||
if (game != null) {
|
||||
String engine = "Computer";
|
||||
if (computerPlayer != null) {
|
||||
|
@ -1058,7 +1058,7 @@ public class DroidChessController {
|
|||
}
|
||||
}
|
||||
|
||||
private final synchronized void updatePlayerNames(String engineName) {
|
||||
private synchronized void updatePlayerNames(String engineName) {
|
||||
if (game != null) {
|
||||
if (strength < 1000)
|
||||
engineName += String.format(Locale.US, " (%.1f%%)", strength * 0.1);
|
||||
|
@ -1069,7 +1069,7 @@ public class DroidChessController {
|
|||
}
|
||||
}
|
||||
|
||||
private final boolean undoMoveNoUpdate() {
|
||||
private boolean undoMoveNoUpdate() {
|
||||
if (game.getLastMove() == null)
|
||||
return false;
|
||||
searchId++;
|
||||
|
@ -1093,7 +1093,7 @@ public class DroidChessController {
|
|||
return true;
|
||||
}
|
||||
|
||||
private final void redoMoveNoUpdate() {
|
||||
private void redoMoveNoUpdate() {
|
||||
if (game.canRedoMove()) {
|
||||
searchId++;
|
||||
game.redoMove();
|
||||
|
@ -1109,7 +1109,7 @@ public class DroidChessController {
|
|||
* Move a piece from one square to another.
|
||||
* @return True if the move was legal, false otherwise.
|
||||
*/
|
||||
private final boolean doMove(Move move) {
|
||||
private boolean doMove(Move move) {
|
||||
Position pos = game.currPos();
|
||||
ArrayList<Move> moves = new MoveGen().legalMoves(pos);
|
||||
int promoteTo = move.promoteTo;
|
||||
|
@ -1132,7 +1132,7 @@ public class DroidChessController {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final void updateGUI() {
|
||||
private void updateGUI() {
|
||||
GUIInterface.GameStatus s = new GUIInterface.GameStatus();
|
||||
s.state = game.getGameState();
|
||||
if (s.state == GameState.ALIVE) {
|
||||
|
@ -1180,12 +1180,12 @@ public class DroidChessController {
|
|||
gui.updateMaterialDifferenceTitle(Util.getMaterialDiff(game.currPos()));
|
||||
}
|
||||
|
||||
private final synchronized void setThinkingInfo(ThinkingInfo ti) {
|
||||
private synchronized void setThinkingInfo(ThinkingInfo ti) {
|
||||
if ((ti.id == searchId) && (ti == latestThinkingInfo))
|
||||
gui.setThinkingInfo(ti);
|
||||
}
|
||||
|
||||
private final void updateMoveList() {
|
||||
private void updateMoveList() {
|
||||
if (game == null)
|
||||
return;
|
||||
if (!gameTextListener.isUpToDate()) {
|
||||
|
@ -1205,7 +1205,7 @@ public class DroidChessController {
|
|||
}
|
||||
|
||||
/** Mark last played move in the GUI. */
|
||||
private final void setSelection() {
|
||||
private void setSelection() {
|
||||
Move m = game.getLastMove();
|
||||
int sq = ((m != null) && (m.from != m.to)) ? m.to : -1;
|
||||
gui.setSelection(sq);
|
||||
|
@ -1215,7 +1215,7 @@ public class DroidChessController {
|
|||
gui.setAnimMove(sourcePos, move, forward);
|
||||
}
|
||||
|
||||
private final boolean findValidDrawClaim(String ms) {
|
||||
private boolean findValidDrawClaim(String ms) {
|
||||
if (!ms.isEmpty())
|
||||
ms = " " + ms;
|
||||
if (game.getGameState() != GameState.ALIVE) return true;
|
||||
|
|
|
@ -134,14 +134,14 @@ public class Game {
|
|||
* Second item is move played, or null if no move was played. */
|
||||
public final Pair<Boolean, Move> processString(String str) {
|
||||
if (getGameState() != GameState.ALIVE)
|
||||
return new Pair<Boolean,Move>(false, null);
|
||||
return new Pair<>(false, null);
|
||||
if (str.startsWith("draw ")) {
|
||||
String drawCmd = str.substring(str.indexOf(" ") + 1);
|
||||
Move m = handleDrawCmd(drawCmd, true);
|
||||
return new Pair<Boolean,Move>(true, m);
|
||||
return new Pair<>(true, m);
|
||||
} else if (str.equals("resign")) {
|
||||
addToGameTree(new Move(0, 0, 0), "resign");
|
||||
return new Pair<Boolean,Move>(true, null);
|
||||
return new Pair<>(true, null);
|
||||
}
|
||||
|
||||
Move m = TextIO.UCIstringToMove(str);
|
||||
|
@ -154,10 +154,10 @@ public class Game {
|
|||
m = null;
|
||||
}
|
||||
if (m == null)
|
||||
return new Pair<Boolean,Move>(false, null);
|
||||
return new Pair<>(false, null);
|
||||
|
||||
addToGameTree(m, pendingDrawOffer ? "draw offer" : "");
|
||||
return new Pair<Boolean,Move>(true, m);
|
||||
return new Pair<>(true, m);
|
||||
}
|
||||
|
||||
/** Try claim a draw using a command string. Does not play the move involved
|
||||
|
@ -169,7 +169,7 @@ public class Game {
|
|||
}
|
||||
}
|
||||
|
||||
private final void addToGameTree(Move m, String playerAction) {
|
||||
private void addToGameTree(Move m, String playerAction) {
|
||||
if (m.equals(new Move(0, 0, 0))) { // Don't create more than one game-ending move at a node
|
||||
List<Move> varMoves = tree.variations();
|
||||
for (int i = varMoves.size() - 1; i >= 0; i--)
|
||||
|
@ -240,7 +240,7 @@ public class Game {
|
|||
return gameEnd;
|
||||
}
|
||||
|
||||
private final void updateTimeControl(boolean discardElapsed) {
|
||||
private void updateTimeControl(boolean discardElapsed) {
|
||||
Position currPos = currPos();
|
||||
int move = currPos.fullMoveCounter;
|
||||
boolean wtm = currPos.whiteMove;
|
||||
|
@ -454,7 +454,7 @@ public class Game {
|
|||
Pair<List<Node>, Integer> ml = tree.getMoveList();
|
||||
List<Node> moveList = ml.first;
|
||||
Position pos = new Position(tree.startPos);
|
||||
ArrayList<Move> mList = new ArrayList<Move>();
|
||||
ArrayList<Move> mList = new ArrayList<>();
|
||||
Position currPos = new Position(pos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
int nMoves = ml.second;
|
||||
|
@ -467,10 +467,10 @@ public class Game {
|
|||
mList.clear();
|
||||
}
|
||||
}
|
||||
return new Pair<Position, ArrayList<Move>>(pos, mList);
|
||||
return new Pair<>(pos, mList);
|
||||
}
|
||||
|
||||
private final Move handleDrawCmd(String drawCmd, boolean playDrawMove) {
|
||||
private Move handleDrawCmd(String drawCmd, boolean playDrawMove) {
|
||||
Move ret = null;
|
||||
Position pos = tree.currentPos;
|
||||
if (drawCmd.startsWith("rep") || drawCmd.startsWith("50")) {
|
||||
|
|
|
@ -91,14 +91,14 @@ public class GameTree {
|
|||
timeControl = "?";
|
||||
whiteTimeControl = "?";
|
||||
blackTimeControl = "?";
|
||||
tagPairs = new ArrayList<TagPair>();
|
||||
tagPairs = new ArrayList<>();
|
||||
rootNode = new Node();
|
||||
currentNode = rootNode;
|
||||
currentPos = new Position(startPos);
|
||||
updateListener();
|
||||
}
|
||||
|
||||
private final void updateListener() {
|
||||
private void updateListener() {
|
||||
if (gameStateListener != null)
|
||||
gameStateListener.clear();
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class GameTree {
|
|||
|
||||
/** Update moveStrLocal in all game nodes. */
|
||||
public final void translateMoves() {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -234,8 +234,8 @@ public class GameTree {
|
|||
goForward(currPath.get(i), false);
|
||||
}
|
||||
|
||||
private final void translateMovesHelper() {
|
||||
ArrayList<Integer> currPath = new ArrayList<Integer>();
|
||||
private void translateMovesHelper() {
|
||||
ArrayList<Integer> currPath = new ArrayList<>();
|
||||
currPath.add(0);
|
||||
while (!currPath.isEmpty()) {
|
||||
int last = currPath.size() - 1;
|
||||
|
@ -325,7 +325,7 @@ public class GameTree {
|
|||
out.processToken(null, PgnToken.EOF, null);
|
||||
}
|
||||
|
||||
private final void addTagPair(PgnToken.PgnTokenReceiver out, String tagName, String tagValue) {
|
||||
private void addTagPair(PgnToken.PgnTokenReceiver out, String tagName, String tagValue) {
|
||||
out.processToken(null, PgnToken.LEFT_BRACKET, null);
|
||||
out.processToken(null, PgnToken.SYMBOL, tagName);
|
||||
out.processToken(null, PgnToken.STRING, tagValue);
|
||||
|
@ -338,7 +338,7 @@ public class GameTree {
|
|||
List<PgnToken> savedTokens;
|
||||
|
||||
PgnScanner(String pgn) {
|
||||
savedTokens = new ArrayList<PgnToken>();
|
||||
savedTokens = new ArrayList<>();
|
||||
// Skip "escape" lines, ie lines starting with a '%' character
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = pgn.length();
|
||||
|
@ -489,7 +489,7 @@ public class GameTree {
|
|||
PgnToken tok = scanner.nextToken();
|
||||
|
||||
// Parse tag section
|
||||
List<TagPair> tagPairs = new ArrayList<TagPair>();
|
||||
List<TagPair> tagPairs = new ArrayList<>();
|
||||
while (tok.type == PgnToken.LEFT_BRACKET) {
|
||||
TagPair tp = new TagPair();
|
||||
tok = scanner.nextTokenDropComments();
|
||||
|
@ -725,7 +725,7 @@ public class GameTree {
|
|||
public final ArrayList<Move> variations() {
|
||||
if (currentNode.verifyChildren(currentPos))
|
||||
updateListener();
|
||||
ArrayList<Move> ret = new ArrayList<Move>();
|
||||
ArrayList<Move> ret = new ArrayList<>();
|
||||
for (Node child : currentNode.children)
|
||||
ret.add(child.move);
|
||||
return ret;
|
||||
|
@ -798,7 +798,7 @@ public class GameTree {
|
|||
|
||||
/** Get linear game history, using default variations at branch points. */
|
||||
public final Pair<List<Node>, Integer> getMoveList() {
|
||||
List<Node> ret = new ArrayList<Node>();
|
||||
List<Node> ret = new ArrayList<>();
|
||||
Node node = currentNode;
|
||||
while (node != rootNode) {
|
||||
ret.add(node);
|
||||
|
@ -822,7 +822,7 @@ public class GameTree {
|
|||
}
|
||||
if (changed)
|
||||
updateListener();
|
||||
return new Pair<List<Node>, Integer>(ret, numMovesPlayed);
|
||||
return new Pair<>(ret, numMovesPlayed);
|
||||
}
|
||||
|
||||
final void setRemainingTime(int remaining) {
|
||||
|
@ -943,7 +943,7 @@ public class GameTree {
|
|||
|
||||
/** Evaluate PGN result string at the end of the main line. */
|
||||
public final String getPGNResultStringMainLine() {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -1047,7 +1047,7 @@ public class GameTree {
|
|||
this.playerAction = "";
|
||||
this.remainingTime = Integer.MIN_VALUE;
|
||||
this.parent = null;
|
||||
this.children = new ArrayList<Node>();
|
||||
this.children = new ArrayList<>();
|
||||
this.defaultChild = 0;
|
||||
this.nag = 0;
|
||||
this.preComment = "";
|
||||
|
@ -1063,7 +1063,7 @@ public class GameTree {
|
|||
this.playerAction = playerAction;
|
||||
this.remainingTime = remainingTime;
|
||||
this.parent = parent;
|
||||
this.children = new ArrayList<Node>();
|
||||
this.children = new ArrayList<>();
|
||||
this.defaultChild = 0;
|
||||
this.nag = nag;
|
||||
this.preComment = preComment;
|
||||
|
@ -1075,10 +1075,10 @@ public class GameTree {
|
|||
}
|
||||
|
||||
/** nodePos must represent the same position as this Node object. */
|
||||
private final boolean verifyChildren(Position nodePos) {
|
||||
private boolean verifyChildren(Position nodePos) {
|
||||
return verifyChildren(nodePos, null);
|
||||
}
|
||||
private final boolean verifyChildren(Position nodePos, ArrayList<Move> moves) {
|
||||
private boolean verifyChildren(Position nodePos, ArrayList<Move> moves) {
|
||||
boolean anyToRemove = false;
|
||||
for (Node child : children) {
|
||||
if (child.move == null) {
|
||||
|
@ -1096,7 +1096,7 @@ public class GameTree {
|
|||
}
|
||||
}
|
||||
if (anyToRemove) {
|
||||
ArrayList<Node> validChildren = new ArrayList<Node>();
|
||||
ArrayList<Node> validChildren = new ArrayList<>();
|
||||
for (Node child : children)
|
||||
if (child.move != null)
|
||||
validChildren.add(child);
|
||||
|
@ -1106,7 +1106,7 @@ public class GameTree {
|
|||
}
|
||||
|
||||
final ArrayList<Integer> getPathFromRoot() {
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>(64);
|
||||
ArrayList<Integer> ret = new ArrayList<>(64);
|
||||
Node node = this;
|
||||
while (node.parent != null) {
|
||||
ret.add(node.getChildNo());
|
||||
|
@ -1209,8 +1209,8 @@ public class GameTree {
|
|||
}
|
||||
|
||||
/** Export this node in PGN (or display text) format. */
|
||||
private final boolean addPgnDataOneNode(PgnToken.PgnTokenReceiver out, MoveNumber mn,
|
||||
boolean needMoveNr, PGNOptions options) {
|
||||
private boolean addPgnDataOneNode(PgnToken.PgnTokenReceiver out, MoveNumber mn,
|
||||
boolean needMoveNr, PGNOptions options) {
|
||||
if ((preComment.length() > 0) && options.exp.comments) {
|
||||
out.processToken(this, PgnToken.COMMENT, preComment);
|
||||
needMoveNr = true;
|
||||
|
@ -1260,8 +1260,8 @@ public class GameTree {
|
|||
return needMoveNr;
|
||||
}
|
||||
|
||||
private final void addExtendedInfo(PgnToken.PgnTokenReceiver out,
|
||||
String extCmd, String extData) {
|
||||
private void addExtendedInfo(PgnToken.PgnTokenReceiver out,
|
||||
String extCmd, String extData) {
|
||||
out.processToken(this, PgnToken.COMMENT, "[%" + extCmd + " " + extData + "]");
|
||||
}
|
||||
|
||||
|
@ -1289,13 +1289,13 @@ public class GameTree {
|
|||
return ret.toString();
|
||||
}
|
||||
|
||||
private final Node addChild(Node child) {
|
||||
private Node addChild(Node child) {
|
||||
child.parent = this;
|
||||
children.add(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
public static final void parsePgn(PgnScanner scanner, Node node, PGNOptions options) {
|
||||
public static void parsePgn(PgnScanner scanner, Node node, PGNOptions options) {
|
||||
Node nodeToAdd = new Node();
|
||||
boolean moveAdded = false;
|
||||
while (true) {
|
||||
|
@ -1424,7 +1424,7 @@ public class GameTree {
|
|||
param = comment.substring(start + match.length(), end);
|
||||
}
|
||||
}
|
||||
return new Pair<String, String>(remaining, param);
|
||||
return new Pair<>(remaining, param);
|
||||
}
|
||||
|
||||
/** Convert hh:mm:ss to milliseconds */
|
||||
|
@ -1518,7 +1518,7 @@ public class GameTree {
|
|||
else if (tag.equals("White")) white = val;
|
||||
else if (tag.equals("Black")) black = val;
|
||||
else if (tag.equals("Result")) {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -1607,7 +1607,7 @@ public class GameTree {
|
|||
private ArrayList<TimeControlField> stringToTCFields(String tcStr) {
|
||||
String[] fields = tcStr.split(":");
|
||||
int nf = fields.length;
|
||||
ArrayList<TimeControlField> ret = new ArrayList<TimeControlField>(nf);
|
||||
ArrayList<TimeControlField> ret = new ArrayList<>(nf);
|
||||
for (int i = 0; i < nf; i++) {
|
||||
String f = fields[i].trim();
|
||||
if (f.equals("?") || f.equals("-") || f.contains("*")) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MoveGen {
|
|||
* Pseudo-legal means that the moves don't necessarily defend from check threats.
|
||||
*/
|
||||
public final ArrayList<Move> pseudoLegalMoves(Position pos) {
|
||||
ArrayList<Move> moveList = new ArrayList<Move>(60);
|
||||
ArrayList<Move> moveList = new ArrayList<>(60);
|
||||
final boolean wtm = pos.whiteMove;
|
||||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
|
@ -224,7 +224,7 @@ public class MoveGen {
|
|||
* This function removes the moves that don't defend from check threats.
|
||||
*/
|
||||
public static final ArrayList<Move> removeIllegal(Position pos, ArrayList<Move> moveList) {
|
||||
ArrayList<Move> ret = new ArrayList<Move>();
|
||||
ArrayList<Move> ret = new ArrayList<>();
|
||||
UndoInfo ui = new UndoInfo();
|
||||
int mlSize = moveList.size();
|
||||
for (int mi = 0; mi < mlSize; mi++) {
|
||||
|
@ -244,7 +244,7 @@ public class MoveGen {
|
|||
* @param maxSteps Max steps until reaching a border. Set to 1 for non-sliding pieces.
|
||||
* @ return True if the enemy king could be captured, false otherwise.
|
||||
*/
|
||||
private final boolean addDirection(ArrayList<Move> moveList, Position pos, int sq0, int maxSteps, int delta) {
|
||||
private boolean addDirection(ArrayList<Move> moveList, Position pos, int sq0, int maxSteps, int delta) {
|
||||
int sq = sq0;
|
||||
boolean wtm = pos.whiteMove;
|
||||
final int oKing = (wtm ? Piece.BKING : Piece.WKING);
|
||||
|
@ -273,7 +273,7 @@ public class MoveGen {
|
|||
/**
|
||||
* Generate all possible pawn moves from (x0,y0) to (x1,y1), taking pawn promotions into account.
|
||||
*/
|
||||
private final void addPawnMoves(ArrayList<Move> moveList, int sq0, int sq1) {
|
||||
private void addPawnMoves(ArrayList<Move> moveList, int sq0, int sq1) {
|
||||
if (sq1 >= 56) { // White promotion
|
||||
moveList.add(getMoveObj(sq0, sq1, Piece.WQUEEN));
|
||||
moveList.add(getMoveObj(sq0, sq1, Piece.WKNIGHT));
|
||||
|
|
|
@ -359,7 +359,7 @@ public class Position {
|
|||
}
|
||||
}
|
||||
|
||||
private final void removeCastleRights(int square) {
|
||||
private void removeCastleRights(int square) {
|
||||
if (square == Position.getSquare(0, 0)) {
|
||||
setCastleMask(castleMask & ~(1 << Position.A1_CASTLE));
|
||||
} else if (square == Position.getSquare(7, 0)) {
|
||||
|
@ -411,7 +411,7 @@ public class Position {
|
|||
return hash;
|
||||
}
|
||||
|
||||
private final static long getRandomHashVal(int rndNo) {
|
||||
private static long getRandomHashVal(int rndNo) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
byte[] input = new byte[4];
|
||||
|
|
|
@ -456,7 +456,6 @@ public class TextIO {
|
|||
* Decide if move is valid in position pos.
|
||||
* @param pos Position for which to test move.
|
||||
* @param move The move to check for validity.
|
||||
* @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) {
|
||||
|
@ -566,7 +565,7 @@ public class TextIO {
|
|||
if (moves == null)
|
||||
moves = MoveGen.instance.legalMoves(pos);
|
||||
|
||||
ArrayList<Move> matches = new ArrayList<Move>(2);
|
||||
ArrayList<Move> matches = new ArrayList<>(2);
|
||||
for (int i = 0; i < moves.size(); i++) {
|
||||
Move m = moves.get(i);
|
||||
int p = pos.getPiece(m.from);
|
||||
|
@ -755,7 +754,7 @@ public class TextIO {
|
|||
return ret.toString();
|
||||
}
|
||||
|
||||
private final static String pieceToChar(int p) {
|
||||
private static String pieceToChar(int p) {
|
||||
switch (p) {
|
||||
case Piece.WQUEEN: case Piece.BQUEEN: return "Q";
|
||||
case Piece.WROOK: case Piece.BROOK: return "R";
|
||||
|
@ -777,7 +776,7 @@ public class TextIO {
|
|||
return "";
|
||||
}
|
||||
|
||||
private final static int charToPiece(boolean white, char c) {
|
||||
private static int charToPiece(boolean white, char c) {
|
||||
switch (c) {
|
||||
case 'Q': case 'q': return white ? Piece.WQUEEN : Piece.BQUEEN;
|
||||
case 'R': case 'r': return white ? Piece.WROOK : Piece.BROOK;
|
||||
|
|
|
@ -171,14 +171,14 @@ public class TimeControl {
|
|||
currMove++;
|
||||
while (true) {
|
||||
if (tc.get(tcIdx).movesPerSession <= 0)
|
||||
return new Pair<Integer,Integer>(tcIdx, 0);
|
||||
return new Pair<>(tcIdx, 0);
|
||||
nextTC += tc.get(tcIdx).movesPerSession;
|
||||
if (nextTC > currMove)
|
||||
break;
|
||||
if (tcIdx < lastTcIdx)
|
||||
tcIdx++;
|
||||
}
|
||||
return new Pair<Integer,Integer>(tcIdx, nextTC - currMove);
|
||||
return new Pair<>(tcIdx, nextTC - currMove);
|
||||
}
|
||||
|
||||
/** De-serialize from input stream. */
|
||||
|
|
|
@ -40,17 +40,17 @@ public final class TimeControlData {
|
|||
|
||||
/** Constructor. Set a default time control. */
|
||||
public TimeControlData() {
|
||||
tcW = new ArrayList<TimeControlField>();
|
||||
tcW = new ArrayList<>();
|
||||
tcW.add(new TimeControlField(5*60*1000, 60, 0));
|
||||
tcB = new ArrayList<TimeControlField>();
|
||||
tcB = new ArrayList<>();
|
||||
tcB.add(new TimeControlField(5*60*1000, 60, 0));
|
||||
}
|
||||
|
||||
/** Set a single time control for both white and black. */
|
||||
public final void setTimeControl(int time, int moves, int inc) {
|
||||
tcW = new ArrayList<TimeControlField>();
|
||||
tcW = new ArrayList<>();
|
||||
tcW.add(new TimeControlField(time, moves, inc));
|
||||
tcB = new ArrayList<TimeControlField>();
|
||||
tcB = new ArrayList<>();
|
||||
tcB.add(new TimeControlField(time, moves, inc));
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public final class TimeControlData {
|
|||
/** De-serialize from input stream. */
|
||||
public void readFromStream(DataInputStream dis, int version) throws IOException {
|
||||
for (int c = 0; c < 2; c++) {
|
||||
ArrayList<TimeControlField> tc = new ArrayList<TimeControlField>();
|
||||
ArrayList<TimeControlField> tc = new ArrayList<>();
|
||||
if (c == 0)
|
||||
tcW = tc;
|
||||
else
|
||||
|
|
|
@ -29,7 +29,7 @@ class GtbProbe {
|
|||
}
|
||||
|
||||
private String currTbPath = "";
|
||||
private ConcurrentLinkedQueue<String> tbPathQueue = new ConcurrentLinkedQueue<String>();
|
||||
private ConcurrentLinkedQueue<String> tbPathQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
GtbProbe() {
|
||||
}
|
||||
|
@ -106,5 +106,5 @@ class GtbProbe {
|
|||
byte[] blackPieces,
|
||||
int[] result);
|
||||
|
||||
private final native static boolean init(String tbPath);
|
||||
private native static boolean init(String tbPath);
|
||||
}
|
||||
|
|
|
@ -73,10 +73,8 @@ public class Probe {
|
|||
/**
|
||||
* Probe GTB tablebases.
|
||||
* @param pos The position to probe.
|
||||
* @param result Two element array. Set to [tbinfo, plies].
|
||||
* @return True if success.
|
||||
*/
|
||||
private final GtbProbeResult gtbProbe(Position pos) {
|
||||
private GtbProbeResult gtbProbe(Position pos) {
|
||||
GtbProbeResult ret = gtbProbeRaw(pos);
|
||||
if (ret.result == GtbProbeResult.DRAW && pos.getEpSquare() != -1) {
|
||||
ArrayList<Move> moveList = MoveGen.instance.legalMoves(pos);
|
||||
|
@ -109,7 +107,7 @@ public class Probe {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final GtbProbeResult gtbProbeRaw(Position pos) {
|
||||
private GtbProbeResult gtbProbeRaw(Position pos) {
|
||||
int castleMask = 0;
|
||||
if (pos.a1Castle()) castleMask |= GtbProbe.A1_CASTLE;
|
||||
if (pos.h1Castle()) castleMask |= GtbProbe.H1_CASTLE;
|
||||
|
@ -215,7 +213,7 @@ public class Probe {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private final ProbeResult rtbProbe(Position pos) {
|
||||
private ProbeResult rtbProbe(Position pos) {
|
||||
if (pos.nPieces() > 7)
|
||||
return new ProbeResult(ProbeResult.Type.NONE, 0, 0);
|
||||
|
||||
|
@ -273,8 +271,8 @@ public class Probe {
|
|||
/** Return a list of all moves in moveList that are not known to be non-optimal.
|
||||
* Returns null if no legal move could be excluded. */
|
||||
public final ArrayList<Move> removeNonOptimal(Position pos, ArrayList<Move> moveList) {
|
||||
ArrayList<Move> optimalMoves = new ArrayList<Move>();
|
||||
ArrayList<Move> unknownMoves = new ArrayList<Move>();
|
||||
ArrayList<Move> optimalMoves = new ArrayList<>();
|
||||
ArrayList<Move> unknownMoves = new ArrayList<>();
|
||||
final int MATE0 = 100000;
|
||||
int bestScore = -1000000;
|
||||
UndoInfo ui = new UndoInfo();
|
||||
|
@ -323,7 +321,7 @@ public class Probe {
|
|||
int p = pos.getPiece(fromSq);
|
||||
if ((p == Piece.EMPTY) || (pos.whiteMove != Piece.isWhite(p)))
|
||||
return null;
|
||||
ArrayList<Pair<Integer,ProbeResult>> ret = new ArrayList<Pair<Integer,ProbeResult>>();
|
||||
ArrayList<Pair<Integer,ProbeResult>> ret = new ArrayList<>();
|
||||
|
||||
ArrayList<Move> moveList = new MoveGen().legalMoves(pos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
|
@ -342,7 +340,7 @@ public class Probe {
|
|||
} else if (res.type != ProbeResult.Type.WDL) {
|
||||
res.score++;
|
||||
}
|
||||
ret.add(new Pair<Integer,ProbeResult>(m.to, res));
|
||||
ret.add(new Pair<>(m.to, res));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -355,7 +353,7 @@ public class Probe {
|
|||
if (p == Piece.EMPTY)
|
||||
return null;
|
||||
boolean isPawn = (Piece.makeWhite(p) == Piece.WPAWN);
|
||||
ArrayList<Pair<Integer,ProbeResult>> ret = new ArrayList<Pair<Integer,ProbeResult>>();
|
||||
ArrayList<Pair<Integer,ProbeResult>> ret = new ArrayList<>();
|
||||
for (int sq = 0; sq < 64; sq++) {
|
||||
if ((sq != fromSq) && (pos.getPiece(sq) != Piece.EMPTY))
|
||||
continue;
|
||||
|
@ -370,7 +368,7 @@ public class Probe {
|
|||
continue;
|
||||
if (!pos.whiteMove)
|
||||
res.wdl = -res.wdl;
|
||||
ret.add(new Pair<Integer,ProbeResult>(sq, res));
|
||||
ret.add(new Pair<>(sq, res));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RtbProbe {
|
|||
}
|
||||
|
||||
private String currTbPath = "";
|
||||
private ConcurrentLinkedQueue<String> tbPathQueue = new ConcurrentLinkedQueue<String>();
|
||||
private ConcurrentLinkedQueue<String> tbPathQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
RtbProbe() {
|
||||
}
|
||||
|
@ -91,5 +91,5 @@ public class RtbProbe {
|
|||
int fullMoveCounter,
|
||||
int[] result);
|
||||
|
||||
private final native static boolean init(String tbPath);
|
||||
private native static boolean init(String tbPath);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public abstract class ChessBoard extends View {
|
|||
decorationPaint = new Paint();
|
||||
decorationPaint.setAntiAlias(true);
|
||||
|
||||
moveMarkPaint = new ArrayList<Paint>();
|
||||
moveMarkPaint = new ArrayList<>();
|
||||
for (int i = 0; i < ColorTheme.MAX_ARROWS; i++) {
|
||||
Paint p = new Paint();
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
|
@ -174,7 +174,7 @@ public abstract class ChessBoard extends View {
|
|||
now = System.currentTimeMillis();
|
||||
return animActive();
|
||||
}
|
||||
private final boolean animActive() {
|
||||
private boolean animActive() {
|
||||
if (paused || (startTime < 0) || (now >= stopTime) || (posHash != pos.zobristHash()))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -452,7 +452,7 @@ public abstract class ChessBoard extends View {
|
|||
// System.out.printf("draw: %d\n", t1-t0);
|
||||
}
|
||||
|
||||
private final void drawMoveHints(Canvas canvas) {
|
||||
private void drawMoveHints(Canvas canvas) {
|
||||
if ((moveHints == null) || blindMode)
|
||||
return;
|
||||
float h = (float)(sqSize / 2.0);
|
||||
|
@ -550,8 +550,8 @@ public abstract class ChessBoard extends View {
|
|||
|
||||
private Rect labelBounds = null;
|
||||
|
||||
private final void drawLabel(Canvas canvas, int xCrd, int yCrd, boolean right,
|
||||
boolean bottom, char c) {
|
||||
private void drawLabel(Canvas canvas, int xCrd, int yCrd, boolean right,
|
||||
boolean bottom, char c) {
|
||||
String s = Character.toString(c);
|
||||
if (labelBounds == null) {
|
||||
labelBounds = new Rect();
|
||||
|
@ -680,7 +680,7 @@ public abstract class ChessBoard extends View {
|
|||
}
|
||||
}
|
||||
|
||||
private final void drawDecorations(Canvas canvas) {
|
||||
private void drawDecorations(Canvas canvas) {
|
||||
if (decorations == null)
|
||||
return;
|
||||
long decorated = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FrameLayoutWithHole extends FrameLayout {
|
|||
}
|
||||
public void addAnimatorSet(AnimatorSet animatorSet){
|
||||
if (mAnimatorSetArrayList==null){
|
||||
mAnimatorSetArrayList = new ArrayList<AnimatorSet>();
|
||||
mAnimatorSetArrayList = new ArrayList<>();
|
||||
}
|
||||
mAnimatorSetArrayList.add(animatorSet);
|
||||
}
|
||||
|
|
|
@ -51,17 +51,17 @@ public class Book {
|
|||
this.verbose = verbose;
|
||||
}
|
||||
|
||||
private final void initBook() {
|
||||
private void initBook() {
|
||||
if (numBookMoves >= 0)
|
||||
return;
|
||||
long t0 = System.currentTimeMillis();
|
||||
bookMap = new HashMap<Long, List<BookEntry>>();
|
||||
bookMap = new HashMap<>();
|
||||
rndGen = new SecureRandom();
|
||||
rndGen.setSeed(System.currentTimeMillis());
|
||||
numBookMoves = 0;
|
||||
try {
|
||||
InputStream inStream = getClass().getResourceAsStream("/book.bin");
|
||||
List<Byte> buf = new ArrayList<Byte>(8192);
|
||||
List<Byte> buf = new ArrayList<>(8192);
|
||||
byte[] tmpBuf = new byte[1024];
|
||||
while (true) {
|
||||
int len = inStream.read(tmpBuf);
|
||||
|
@ -104,10 +104,10 @@ public class Book {
|
|||
}
|
||||
|
||||
/** Add a move to a position in the opening book. */
|
||||
private final void addToBook(Position pos, Move moveToAdd) {
|
||||
private void addToBook(Position pos, Move moveToAdd) {
|
||||
List<BookEntry> ent = bookMap.get(pos.zobristHash());
|
||||
if (ent == null) {
|
||||
ent = new ArrayList<BookEntry>();
|
||||
ent = new ArrayList<>();
|
||||
bookMap.put(pos.zobristHash(), ent);
|
||||
}
|
||||
for (int i = 0; i < ent.size(); i++) {
|
||||
|
@ -202,7 +202,7 @@ public class Book {
|
|||
}
|
||||
|
||||
public static List<Byte> createBinBook(String inFileName) {
|
||||
List<Byte> binBook = new ArrayList<Byte>(0);
|
||||
List<Byte> binBook = new ArrayList<>(0);
|
||||
try {
|
||||
InputStream inStream = new FileInputStream(inFileName);
|
||||
InputStreamReader inFile = new InputStreamReader(inStream);
|
||||
|
|
|
@ -295,7 +295,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute score based on piece square tables. Positive values are good for white. */
|
||||
private final int pieceSquareEval(Position pos) {
|
||||
private int pieceSquareEval(Position pos) {
|
||||
int score = 0;
|
||||
final int wMtrl = pos.wMtrl;
|
||||
final int bMtrl = pos.bMtrl;
|
||||
|
@ -405,7 +405,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Implement the "when ahead trade pieces, when behind trade pawns" rule. */
|
||||
private final int tradeBonus(Position pos) {
|
||||
private int tradeBonus(Position pos) {
|
||||
final int wM = pos.wMtrl;
|
||||
final int bM = pos.bMtrl;
|
||||
final int wPawn = pos.wMtrlPawns;
|
||||
|
@ -436,7 +436,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Score castling ability. */
|
||||
private final int castleBonus(Position pos) {
|
||||
private int castleBonus(Position pos) {
|
||||
if (pos.getCastleMask() == 0) return 0;
|
||||
|
||||
final int k1 = kt1b[7*8+6] - kt1b[7*8+4];
|
||||
|
@ -464,7 +464,7 @@ public class Evaluate {
|
|||
return wBonus - bBonus;
|
||||
}
|
||||
|
||||
private final int pawnBonus(Position pos) {
|
||||
private int pawnBonus(Position pos) {
|
||||
long key = pos.pawnZobristHash();
|
||||
PawnHashData phd = pawnHash[(int)key & (pawnHash.length - 1)];
|
||||
if (phd.key != key)
|
||||
|
@ -562,7 +562,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute pawn hash data for pos. */
|
||||
private final void computePawnHashData(Position pos, PawnHashData ph) {
|
||||
private void computePawnHashData(Position pos, PawnHashData ph) {
|
||||
int score = 0;
|
||||
|
||||
// Evaluate double pawns and pawn islands
|
||||
|
@ -658,7 +658,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute rook bonus. Rook on open/half-open file. */
|
||||
private final int rookBonus(Position pos) {
|
||||
private int rookBonus(Position pos) {
|
||||
int score = 0;
|
||||
final long wPawns = pos.pieceTypeBB[Piece.WPAWN];
|
||||
final long bPawns = pos.pieceTypeBB[Piece.BPAWN];
|
||||
|
@ -703,7 +703,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute bishop evaluation. */
|
||||
private final int bishopEval(Position pos, int oldScore) {
|
||||
private int bishopEval(Position pos, int oldScore) {
|
||||
int score = 0;
|
||||
final long occupied = pos.whiteBB | pos.blackBB;
|
||||
long wBishops = pos.pieceTypeBB[Piece.WBISHOP];
|
||||
|
@ -828,7 +828,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Compute king safety for both kings. */
|
||||
private final int kingSafety(Position pos) {
|
||||
private int kingSafety(Position pos) {
|
||||
final int minM = rV + bV;
|
||||
final int m = (pos.wMtrl - pos.wMtrlPawns + pos.bMtrl - pos.bMtrlPawns) / 2;
|
||||
if (m <= minM)
|
||||
|
@ -884,7 +884,7 @@ public class Evaluate {
|
|||
}
|
||||
}
|
||||
|
||||
private final int kingSafetyKPPart(Position pos) {
|
||||
private int kingSafetyKPPart(Position pos) {
|
||||
final long key = pos.pawnZobristHash() ^ pos.kingZobristHash();
|
||||
KingSafetyHashData ksh = kingSafetyHash[(int)key & (kingSafetyHash.length - 1)];
|
||||
if (ksh.key != key) {
|
||||
|
@ -958,7 +958,7 @@ public class Evaluate {
|
|||
}
|
||||
|
||||
/** Implements special knowledge for some endgame situations. */
|
||||
private final int endGameEval(Position pos, int oldScore) {
|
||||
private int endGameEval(Position pos, int oldScore) {
|
||||
int score = oldScore;
|
||||
if (pos.wMtrl + pos.bMtrl > 6 * rV)
|
||||
return score;
|
||||
|
|
|
@ -366,7 +366,7 @@ public final class MoveGen {
|
|||
{
|
||||
ArrayList<Move> allMoves = pseudoLegalMoves(pos);
|
||||
allMoves = MoveGen.removeIllegal(pos, allMoves);
|
||||
HashSet<String> evMoves = new HashSet<String>();
|
||||
HashSet<String> evMoves = new HashSet<>();
|
||||
for (Move m : moveList)
|
||||
evMoves.add(TextIO.moveToUCIString(m));
|
||||
for (Move m : allMoves)
|
||||
|
@ -967,8 +967,8 @@ public final class MoveGen {
|
|||
moveList.size = length;
|
||||
}
|
||||
|
||||
private final static boolean addPawnMovesByMask(MoveList moveList, Position pos, long mask,
|
||||
int delta, boolean allPromotions) {
|
||||
private static boolean addPawnMovesByMask(MoveList moveList, Position pos, long mask,
|
||||
int delta, boolean allPromotions) {
|
||||
if (mask == 0)
|
||||
return false;
|
||||
long oKingMask = pos.pieceTypeBB[pos.whiteMove ? Piece.BKING : Piece.WKING];
|
||||
|
@ -1008,8 +1008,8 @@ public final class MoveGen {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final static void addPawnDoubleMovesByMask(MoveList moveList, Position pos,
|
||||
long mask, int delta) {
|
||||
private static void addPawnDoubleMovesByMask(MoveList moveList, Position pos,
|
||||
long mask, int delta) {
|
||||
while (mask != 0) {
|
||||
int sq = BitBoard.numberOfTrailingZeros(mask);
|
||||
setMove(moveList, sq + delta, sq, Piece.EMPTY);
|
||||
|
@ -1017,7 +1017,7 @@ public final class MoveGen {
|
|||
}
|
||||
}
|
||||
|
||||
private final static boolean addMovesByMask(MoveList moveList, Position pos, int sq0, long mask) {
|
||||
private static boolean addMovesByMask(MoveList moveList, Position pos, int sq0, long mask) {
|
||||
long oKingMask = pos.pieceTypeBB[pos.whiteMove ? Piece.BKING : Piece.WKING];
|
||||
if ((mask & oKingMask) != 0) {
|
||||
int sq = BitBoard.numberOfTrailingZeros(mask & oKingMask);
|
||||
|
@ -1033,7 +1033,7 @@ public final class MoveGen {
|
|||
return false;
|
||||
}
|
||||
|
||||
private final static void setMove(MoveList moveList, int from, int to, int promoteTo) {
|
||||
private static void setMove(MoveList moveList, int from, int to, int promoteTo) {
|
||||
Move m = moveList.m[moveList.size++];
|
||||
m.from = from;
|
||||
m.to = to;
|
||||
|
@ -1047,7 +1047,7 @@ public final class MoveGen {
|
|||
|
||||
private static final int MAX_MOVES = 256;
|
||||
|
||||
private final MoveList getMoveListObj() {
|
||||
private MoveList getMoveListObj() {
|
||||
MoveList ml;
|
||||
if (moveListsInCache > 0) {
|
||||
ml = (MoveList)moveListCache[--moveListsInCache];
|
||||
|
|
|
@ -85,7 +85,7 @@ public class Parameters {
|
|||
return inst;
|
||||
}
|
||||
public final String[] getParamNames() {
|
||||
ArrayList<String> parNames = new ArrayList<String>();
|
||||
ArrayList<String> parNames = new ArrayList<>();
|
||||
for (Map.Entry<String, ParamBase> e : params.entrySet())
|
||||
if (e.getValue().visible)
|
||||
parNames.add(e.getKey());
|
||||
|
@ -97,7 +97,7 @@ public class Parameters {
|
|||
}
|
||||
|
||||
private static final Parameters inst = new Parameters();
|
||||
private Map<String, ParamBase> params = new TreeMap<String, ParamBase>();
|
||||
private Map<String, ParamBase> params = new TreeMap<>();
|
||||
|
||||
private Parameters() {
|
||||
addPar(new SpinParam("qV", false, -200, 200, 0));
|
||||
|
@ -107,7 +107,7 @@ public class Parameters {
|
|||
addPar(new SpinParam("pV", false, -200, 200, 0));
|
||||
}
|
||||
|
||||
private final void addPar(ParamBase p) {
|
||||
private void addPar(ParamBase p) {
|
||||
params.put(p.name.toLowerCase(), p);
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class Position {
|
|||
}
|
||||
|
||||
/** Move a non-pawn piece to an empty square. */
|
||||
private final void movePieceNotPawn(int from, int to) {
|
||||
private void movePieceNotPawn(int from, int to) {
|
||||
final int piece = squares[from];
|
||||
hashKey ^= psHashKeys[piece][from];
|
||||
hashKey ^= psHashKeys[piece][to];
|
||||
|
@ -562,7 +562,7 @@ public class Position {
|
|||
}
|
||||
}
|
||||
|
||||
private final void removeCastleRights(int square) {
|
||||
private void removeCastleRights(int square) {
|
||||
if (square == Position.getSquare(0, 0)) {
|
||||
setCastleMask(castleMask & ~(1 << Position.A1_CASTLE));
|
||||
} else if (square == Position.getSquare(7, 0)) {
|
||||
|
@ -620,7 +620,7 @@ public class Position {
|
|||
return hash;
|
||||
}
|
||||
|
||||
private final static long getRandomHashVal(int rndNo) {
|
||||
private static long getRandomHashVal(int rndNo) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
byte[] input = new byte[4];
|
||||
|
|
|
@ -597,7 +597,7 @@ public class TextIO {
|
|||
return str;
|
||||
}
|
||||
|
||||
private final static String pieceToChar(int p) {
|
||||
private static String pieceToChar(int p) {
|
||||
switch (p) {
|
||||
case Piece.WQUEEN: case Piece.BQUEEN: return "Q";
|
||||
case Piece.WROOK: case Piece.BROOK: return "R";
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
|||
public class FileUtil {
|
||||
/** Read a text file. Return string array with one string per line. */
|
||||
public static String[] readFile(String filename) throws IOException {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
InputStream inStream = new FileInputStream(filename);
|
||||
InputStreamReader inFile = new InputStreamReader(inStream, "UTF-8");
|
||||
BufferedReader inBuf = new BufferedReader(inFile);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class EcoBuilder {
|
|||
int ecoIdx; // Index in string array, or -1
|
||||
int opnIdx; // Index in string array, or -1
|
||||
int varIdx; // Index in string array, or -1
|
||||
ArrayList<Node> children = new ArrayList<Node>();
|
||||
ArrayList<Node> children = new ArrayList<>();
|
||||
Node parent;
|
||||
}
|
||||
private ArrayList<Node> nodes;
|
||||
|
@ -57,9 +57,9 @@ public class EcoBuilder {
|
|||
|
||||
/** Constructor. */
|
||||
private EcoBuilder() {
|
||||
nodes = new ArrayList<Node>();
|
||||
strs = new ArrayList<String>();
|
||||
strToIndex = new HashMap<String, Integer>();
|
||||
nodes = new ArrayList<>();
|
||||
strs = new ArrayList<>();
|
||||
strToIndex = new HashMap<>();
|
||||
Node rootNode = new Node();
|
||||
rootNode.index = 0;
|
||||
rootNode.move = new Move(0, 0, 0);
|
||||
|
@ -99,7 +99,7 @@ public class EcoBuilder {
|
|||
game.readPGN(pgn, options);
|
||||
|
||||
// Determine name of opening
|
||||
HashMap<String,String> headers = new HashMap<String,String>();
|
||||
HashMap<String,String> headers = new HashMap<>();
|
||||
GameTree tree = game.tree;
|
||||
tree.getHeaders(headers);
|
||||
int ecoIdx = addData(headers, "ECO");
|
||||
|
|
|
@ -134,14 +134,14 @@ public class Game {
|
|||
* Second item is move played, or null if no move was played. */
|
||||
public final Pair<Boolean, Move> processString(String str) {
|
||||
if (getGameState() != GameState.ALIVE)
|
||||
return new Pair<Boolean,Move>(false, null);
|
||||
return new Pair<>(false, null);
|
||||
if (str.startsWith("draw ")) {
|
||||
String drawCmd = str.substring(str.indexOf(" ") + 1);
|
||||
Move m = handleDrawCmd(drawCmd, true);
|
||||
return new Pair<Boolean,Move>(true, m);
|
||||
return new Pair<>(true, m);
|
||||
} else if (str.equals("resign")) {
|
||||
addToGameTree(new Move(0, 0, 0), "resign");
|
||||
return new Pair<Boolean,Move>(true, null);
|
||||
return new Pair<>(true, null);
|
||||
}
|
||||
|
||||
Move m = TextIO.UCIstringToMove(str);
|
||||
|
@ -154,10 +154,10 @@ public class Game {
|
|||
m = null;
|
||||
}
|
||||
if (m == null)
|
||||
return new Pair<Boolean,Move>(false, null);
|
||||
return new Pair<>(false, null);
|
||||
|
||||
addToGameTree(m, pendingDrawOffer ? "draw offer" : "");
|
||||
return new Pair<Boolean,Move>(true, m);
|
||||
return new Pair<>(true, m);
|
||||
}
|
||||
|
||||
/** Try claim a draw using a command string. Does not play the move involved
|
||||
|
@ -169,7 +169,7 @@ public class Game {
|
|||
}
|
||||
}
|
||||
|
||||
private final void addToGameTree(Move m, String playerAction) {
|
||||
private void addToGameTree(Move m, String playerAction) {
|
||||
if (m.equals(new Move(0, 0, 0))) { // Don't create more than one game-ending move at a node
|
||||
List<Move> varMoves = tree.variations();
|
||||
for (int i = varMoves.size() - 1; i >= 0; i--)
|
||||
|
@ -240,7 +240,7 @@ public class Game {
|
|||
return gameEnd;
|
||||
}
|
||||
|
||||
private final void updateTimeControl(boolean discardElapsed) {
|
||||
private void updateTimeControl(boolean discardElapsed) {
|
||||
Position currPos = currPos();
|
||||
int move = currPos.fullMoveCounter;
|
||||
boolean wtm = currPos.whiteMove;
|
||||
|
@ -454,7 +454,7 @@ public class Game {
|
|||
Pair<List<Node>, Integer> ml = tree.getMoveList();
|
||||
List<Node> moveList = ml.first;
|
||||
Position pos = new Position(tree.startPos);
|
||||
ArrayList<Move> mList = new ArrayList<Move>();
|
||||
ArrayList<Move> mList = new ArrayList<>();
|
||||
Position currPos = new Position(pos);
|
||||
UndoInfo ui = new UndoInfo();
|
||||
int nMoves = ml.second;
|
||||
|
@ -467,10 +467,10 @@ public class Game {
|
|||
mList.clear();
|
||||
}
|
||||
}
|
||||
return new Pair<Position, ArrayList<Move>>(pos, mList);
|
||||
return new Pair<>(pos, mList);
|
||||
}
|
||||
|
||||
private final Move handleDrawCmd(String drawCmd, boolean playDrawMove) {
|
||||
private Move handleDrawCmd(String drawCmd, boolean playDrawMove) {
|
||||
Move ret = null;
|
||||
Position pos = tree.currentPos;
|
||||
if (drawCmd.startsWith("rep") || drawCmd.startsWith("50")) {
|
||||
|
|
|
@ -90,14 +90,14 @@ public class GameTree {
|
|||
timeControl = "?";
|
||||
whiteTimeControl = "?";
|
||||
blackTimeControl = "?";
|
||||
tagPairs = new ArrayList<TagPair>();
|
||||
tagPairs = new ArrayList<>();
|
||||
rootNode = new Node();
|
||||
currentNode = rootNode;
|
||||
currentPos = new Position(startPos);
|
||||
updateListener();
|
||||
}
|
||||
|
||||
private final void updateListener() {
|
||||
private void updateListener() {
|
||||
if (gameStateListener != null)
|
||||
gameStateListener.clear();
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ public class GameTree {
|
|||
|
||||
/** Update moveStrLocal in all game nodes. */
|
||||
public final void translateMoves() {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -233,8 +233,8 @@ public class GameTree {
|
|||
goForward(currPath.get(i), false);
|
||||
}
|
||||
|
||||
private final void translateMovesHelper() {
|
||||
ArrayList<Integer> currPath = new ArrayList<Integer>();
|
||||
private void translateMovesHelper() {
|
||||
ArrayList<Integer> currPath = new ArrayList<>();
|
||||
currPath.add(0);
|
||||
while (!currPath.isEmpty()) {
|
||||
int last = currPath.size() - 1;
|
||||
|
@ -309,7 +309,7 @@ public class GameTree {
|
|||
out.processToken(null, PgnToken.EOF, null);
|
||||
}
|
||||
|
||||
private final void addTagPair(PgnToken.PgnTokenReceiver out, String tagName, String tagValue) {
|
||||
private void addTagPair(PgnToken.PgnTokenReceiver out, String tagName, String tagValue) {
|
||||
out.processToken(null, PgnToken.LEFT_BRACKET, null);
|
||||
out.processToken(null, PgnToken.SYMBOL, tagName);
|
||||
out.processToken(null, PgnToken.STRING, tagValue);
|
||||
|
@ -322,7 +322,7 @@ public class GameTree {
|
|||
List<PgnToken> savedTokens;
|
||||
|
||||
PgnScanner(String pgn) {
|
||||
savedTokens = new ArrayList<PgnToken>();
|
||||
savedTokens = new ArrayList<>();
|
||||
// Skip "escape" lines, ie lines starting with a '%' character
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = pgn.length();
|
||||
|
@ -473,7 +473,7 @@ public class GameTree {
|
|||
PgnToken tok = scanner.nextToken();
|
||||
|
||||
// Parse tag section
|
||||
List<TagPair> tagPairs = new ArrayList<TagPair>();
|
||||
List<TagPair> tagPairs = new ArrayList<>();
|
||||
while (tok.type == PgnToken.LEFT_BRACKET) {
|
||||
TagPair tp = new TagPair();
|
||||
tok = scanner.nextTokenDropComments();
|
||||
|
@ -709,7 +709,7 @@ public class GameTree {
|
|||
public final ArrayList<Move> variations() {
|
||||
if (currentNode.verifyChildren(currentPos))
|
||||
updateListener();
|
||||
ArrayList<Move> ret = new ArrayList<Move>();
|
||||
ArrayList<Move> ret = new ArrayList<>();
|
||||
for (Node child : currentNode.children)
|
||||
ret.add(child.move);
|
||||
return ret;
|
||||
|
@ -782,7 +782,7 @@ public class GameTree {
|
|||
|
||||
/** Get linear game history, using default variations at branch points. */
|
||||
public final Pair<List<Node>, Integer> getMoveList() {
|
||||
List<Node> ret = new ArrayList<Node>();
|
||||
List<Node> ret = new ArrayList<>();
|
||||
Node node = currentNode;
|
||||
while (node != rootNode) {
|
||||
ret.add(node);
|
||||
|
@ -806,7 +806,7 @@ public class GameTree {
|
|||
}
|
||||
if (changed)
|
||||
updateListener();
|
||||
return new Pair<List<Node>, Integer>(ret, numMovesPlayed);
|
||||
return new Pair<>(ret, numMovesPlayed);
|
||||
}
|
||||
|
||||
final void setRemainingTime(int remaining) {
|
||||
|
@ -927,7 +927,7 @@ public class GameTree {
|
|||
|
||||
/** Evaluate PGN result string at the end of the main line. */
|
||||
public final String getPGNResultStringMainLine() {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -1031,7 +1031,7 @@ public class GameTree {
|
|||
this.playerAction = "";
|
||||
this.remainingTime = Integer.MIN_VALUE;
|
||||
this.parent = null;
|
||||
this.children = new ArrayList<Node>();
|
||||
this.children = new ArrayList<>();
|
||||
this.defaultChild = 0;
|
||||
this.nag = 0;
|
||||
this.preComment = "";
|
||||
|
@ -1047,7 +1047,7 @@ public class GameTree {
|
|||
this.playerAction = playerAction;
|
||||
this.remainingTime = remainingTime;
|
||||
this.parent = parent;
|
||||
this.children = new ArrayList<Node>();
|
||||
this.children = new ArrayList<>();
|
||||
this.defaultChild = 0;
|
||||
this.nag = nag;
|
||||
this.preComment = preComment;
|
||||
|
@ -1059,10 +1059,10 @@ public class GameTree {
|
|||
}
|
||||
|
||||
/** nodePos must represent the same position as this Node object. */
|
||||
private final boolean verifyChildren(Position nodePos) {
|
||||
private boolean verifyChildren(Position nodePos) {
|
||||
return verifyChildren(nodePos, null);
|
||||
}
|
||||
private final boolean verifyChildren(Position nodePos, ArrayList<Move> moves) {
|
||||
private boolean verifyChildren(Position nodePos, ArrayList<Move> moves) {
|
||||
boolean anyToRemove = false;
|
||||
for (Node child : children) {
|
||||
if (child.move == null) {
|
||||
|
@ -1080,7 +1080,7 @@ public class GameTree {
|
|||
}
|
||||
}
|
||||
if (anyToRemove) {
|
||||
ArrayList<Node> validChildren = new ArrayList<Node>();
|
||||
ArrayList<Node> validChildren = new ArrayList<>();
|
||||
for (Node child : children)
|
||||
if (child.move != null)
|
||||
validChildren.add(child);
|
||||
|
@ -1090,7 +1090,7 @@ public class GameTree {
|
|||
}
|
||||
|
||||
final ArrayList<Integer> getPathFromRoot() {
|
||||
ArrayList<Integer> ret = new ArrayList<Integer>(64);
|
||||
ArrayList<Integer> ret = new ArrayList<>(64);
|
||||
Node node = this;
|
||||
while (node.parent != null) {
|
||||
ret.add(node.getChildNo());
|
||||
|
@ -1193,8 +1193,8 @@ public class GameTree {
|
|||
}
|
||||
|
||||
/** Export this node in PGN (or display text) format. */
|
||||
private final boolean addPgnDataOneNode(PgnToken.PgnTokenReceiver out, MoveNumber mn,
|
||||
boolean needMoveNr, PGNOptions options) {
|
||||
private boolean addPgnDataOneNode(PgnToken.PgnTokenReceiver out, MoveNumber mn,
|
||||
boolean needMoveNr, PGNOptions options) {
|
||||
if ((preComment.length() > 0) && options.exp.comments) {
|
||||
out.processToken(this, PgnToken.COMMENT, preComment);
|
||||
needMoveNr = true;
|
||||
|
@ -1244,8 +1244,8 @@ public class GameTree {
|
|||
return needMoveNr;
|
||||
}
|
||||
|
||||
private final void addExtendedInfo(PgnToken.PgnTokenReceiver out,
|
||||
String extCmd, String extData) {
|
||||
private void addExtendedInfo(PgnToken.PgnTokenReceiver out,
|
||||
String extCmd, String extData) {
|
||||
out.processToken(this, PgnToken.COMMENT, "[%" + extCmd + " " + extData + "]");
|
||||
}
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ public class GameTree {
|
|||
return ret.toString();
|
||||
}
|
||||
|
||||
private final Node addChild(Node child) {
|
||||
private Node addChild(Node child) {
|
||||
child.parent = this;
|
||||
children.add(child);
|
||||
return child;
|
||||
|
@ -1408,7 +1408,7 @@ public class GameTree {
|
|||
param = comment.substring(start + match.length(), end);
|
||||
}
|
||||
}
|
||||
return new Pair<String, String>(remaining, param);
|
||||
return new Pair<>(remaining, param);
|
||||
}
|
||||
|
||||
/** Convert hh:mm:ss to milliseconds */
|
||||
|
@ -1502,7 +1502,7 @@ public class GameTree {
|
|||
else if (tag.equals("White")) white = val;
|
||||
else if (tag.equals("Black")) black = val;
|
||||
else if (tag.equals("Result")) {
|
||||
List<Integer> currPath = new ArrayList<Integer>();
|
||||
List<Integer> currPath = new ArrayList<>();
|
||||
while (currentNode != rootNode) {
|
||||
Node child = currentNode;
|
||||
goBack();
|
||||
|
@ -1591,7 +1591,7 @@ public class GameTree {
|
|||
private ArrayList<TimeControlField> stringToTCFields(String tcStr) {
|
||||
String[] fields = tcStr.split(":");
|
||||
int nf = fields.length;
|
||||
ArrayList<TimeControlField> ret = new ArrayList<TimeControlField>(nf);
|
||||
ArrayList<TimeControlField> ret = new ArrayList<>(nf);
|
||||
for (int i = 0; i < nf; i++) {
|
||||
String f = fields[i].trim();
|
||||
if (f.equals("?") || f.equals("-") || f.contains("*")) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MoveGen {
|
|||
* Pseudo-legal means that the moves don't necessarily defend from check threats.
|
||||
*/
|
||||
public final ArrayList<Move> pseudoLegalMoves(Position pos) {
|
||||
ArrayList<Move> moveList = new ArrayList<Move>(60);
|
||||
ArrayList<Move> moveList = new ArrayList<>(60);
|
||||
final boolean wtm = pos.whiteMove;
|
||||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
|
@ -224,7 +224,7 @@ public class MoveGen {
|
|||
* This function removes the moves that don't defend from check threats.
|
||||
*/
|
||||
public static final ArrayList<Move> removeIllegal(Position pos, ArrayList<Move> moveList) {
|
||||
ArrayList<Move> ret = new ArrayList<Move>();
|
||||
ArrayList<Move> ret = new ArrayList<>();
|
||||
UndoInfo ui = new UndoInfo();
|
||||
int mlSize = moveList.size();
|
||||
for (int mi = 0; mi < mlSize; mi++) {
|
||||
|
@ -244,7 +244,7 @@ public class MoveGen {
|
|||
* @param maxSteps Max steps until reaching a border. Set to 1 for non-sliding pieces.
|
||||
* @ return True if the enemy king could be captured, false otherwise.
|
||||
*/
|
||||
private final boolean addDirection(ArrayList<Move> moveList, Position pos, int sq0, int maxSteps, int delta) {
|
||||
private boolean addDirection(ArrayList<Move> moveList, Position pos, int sq0, int maxSteps, int delta) {
|
||||
int sq = sq0;
|
||||
boolean wtm = pos.whiteMove;
|
||||
final int oKing = (wtm ? Piece.BKING : Piece.WKING);
|
||||
|
@ -273,7 +273,7 @@ public class MoveGen {
|
|||
/**
|
||||
* Generate all possible pawn moves from (x0,y0) to (x1,y1), taking pawn promotions into account.
|
||||
*/
|
||||
private final void addPawnMoves(ArrayList<Move> moveList, int sq0, int sq1) {
|
||||
private void addPawnMoves(ArrayList<Move> moveList, int sq0, int sq1) {
|
||||
if (sq1 >= 56) { // White promotion
|
||||
moveList.add(getMoveObj(sq0, sq1, Piece.WQUEEN));
|
||||
moveList.add(getMoveObj(sq0, sq1, Piece.WKNIGHT));
|
||||
|
|
|
@ -359,7 +359,7 @@ public class Position {
|
|||
}
|
||||
}
|
||||
|
||||
private final void removeCastleRights(int square) {
|
||||
private void removeCastleRights(int square) {
|
||||
if (square == Position.getSquare(0, 0)) {
|
||||
setCastleMask(castleMask & ~(1 << Position.A1_CASTLE));
|
||||
} else if (square == Position.getSquare(7, 0)) {
|
||||
|
@ -411,7 +411,7 @@ public class Position {
|
|||
return hash;
|
||||
}
|
||||
|
||||
private final static long getRandomHashVal(int rndNo) {
|
||||
private static long getRandomHashVal(int rndNo) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
byte[] input = new byte[4];
|
||||
|
|
|
@ -565,7 +565,7 @@ public class TextIO {
|
|||
if (moves == null)
|
||||
moves = MoveGen.instance.legalMoves(pos);
|
||||
|
||||
ArrayList<Move> matches = new ArrayList<Move>(2);
|
||||
ArrayList<Move> matches = new ArrayList<>(2);
|
||||
for (int i = 0; i < moves.size(); i++) {
|
||||
Move m = moves.get(i);
|
||||
int p = pos.getPiece(m.from);
|
||||
|
@ -754,7 +754,7 @@ public class TextIO {
|
|||
return ret.toString();
|
||||
}
|
||||
|
||||
private final static String pieceToChar(int p) {
|
||||
private static String pieceToChar(int p) {
|
||||
switch (p) {
|
||||
case Piece.WQUEEN: case Piece.BQUEEN: return "Q";
|
||||
case Piece.WROOK: case Piece.BROOK: return "R";
|
||||
|
@ -776,7 +776,7 @@ public class TextIO {
|
|||
return "";
|
||||
}
|
||||
|
||||
private final static int charToPiece(boolean white, char c) {
|
||||
private static int charToPiece(boolean white, char c) {
|
||||
switch (c) {
|
||||
case 'Q': case 'q': return white ? Piece.WQUEEN : Piece.BQUEEN;
|
||||
case 'R': case 'r': return white ? Piece.WROOK : Piece.BROOK;
|
||||
|
|
|
@ -171,14 +171,14 @@ public class TimeControl {
|
|||
currMove++;
|
||||
while (true) {
|
||||
if (tc.get(tcIdx).movesPerSession <= 0)
|
||||
return new Pair<Integer,Integer>(tcIdx, 0);
|
||||
return new Pair<>(tcIdx, 0);
|
||||
nextTC += tc.get(tcIdx).movesPerSession;
|
||||
if (nextTC > currMove)
|
||||
break;
|
||||
if (tcIdx < lastTcIdx)
|
||||
tcIdx++;
|
||||
}
|
||||
return new Pair<Integer,Integer>(tcIdx, nextTC - currMove);
|
||||
return new Pair<>(tcIdx, nextTC - currMove);
|
||||
}
|
||||
|
||||
/** De-serialize from input stream. */
|
||||
|
|
|
@ -40,17 +40,17 @@ public final class TimeControlData {
|
|||
|
||||
/** Constructor. Set a default time control. */
|
||||
public TimeControlData() {
|
||||
tcW = new ArrayList<TimeControlField>();
|
||||
tcW = new ArrayList<>();
|
||||
tcW.add(new TimeControlField(5*60*1000, 60, 0));
|
||||
tcB = new ArrayList<TimeControlField>();
|
||||
tcB = new ArrayList<>();
|
||||
tcB.add(new TimeControlField(5*60*1000, 60, 0));
|
||||
}
|
||||
|
||||
/** Set a single time control for both white and black. */
|
||||
public final void setTimeControl(int time, int moves, int inc) {
|
||||
tcW = new ArrayList<TimeControlField>();
|
||||
tcW = new ArrayList<>();
|
||||
tcW.add(new TimeControlField(time, moves, inc));
|
||||
tcB = new ArrayList<TimeControlField>();
|
||||
tcB = new ArrayList<>();
|
||||
tcB.add(new TimeControlField(time, moves, inc));
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public final class TimeControlData {
|
|||
/** De-serialize from input stream. */
|
||||
public void readFromStream(DataInputStream dis, int version) throws IOException {
|
||||
for (int c = 0; c < 2; c++) {
|
||||
ArrayList<TimeControlField> tc = new ArrayList<TimeControlField>();
|
||||
ArrayList<TimeControlField> tc = new ArrayList<>();
|
||||
if (c == 0)
|
||||
tcW = tc;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user