mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-10 16:12:41 +01:00
Fix some Android Studio warnings.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user