mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-08 07:11:32 +01:00
Fix some Android Studio warnings.
This commit is contained in:
@@ -31,8 +31,8 @@ import chess.Position;
|
||||
/** The main class for the chess GUI. */
|
||||
public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
|
||||
private static final long serialVersionUID = 7357610346389734323L;
|
||||
ChessBoardPainter cbp;
|
||||
ChessController ctrl;
|
||||
private ChessBoardPainter cbp;
|
||||
private ChessController ctrl;
|
||||
private final static int ttLogSize = 19; // Use 2^19 hash entries.
|
||||
private String moveListStr = "";
|
||||
private String thinkingStr = "";
|
||||
|
||||
@@ -61,7 +61,6 @@ public class ChessBoardPainter extends JLabel {
|
||||
|
||||
/**
|
||||
* Set the board to a given state.
|
||||
* @param pos
|
||||
*/
|
||||
final public void setPosition(Position pos) {
|
||||
this.pos = pos;
|
||||
@@ -70,7 +69,6 @@ public class ChessBoardPainter extends JLabel {
|
||||
|
||||
/**
|
||||
* Set/clear the board flipped status.
|
||||
* @param flipped
|
||||
*/
|
||||
final public void setFlipped(boolean flipped) {
|
||||
this.flipped = flipped;
|
||||
@@ -227,23 +225,23 @@ public class ChessBoardPainter extends JLabel {
|
||||
}
|
||||
|
||||
final Move mousePressed(int sq) {
|
||||
Move m = null;
|
||||
cancelSelection = false;
|
||||
int p = pos.getPiece(sq);
|
||||
if ((selectedSquare >= 0) && (sq == selectedSquare)) {
|
||||
int fromPiece = pos.getPiece(selectedSquare);
|
||||
if ((fromPiece == Piece.EMPTY) || (Piece.isWhite(fromPiece) != pos.whiteMove)) {
|
||||
return m; // Can't move the piece the oppenent just moved.
|
||||
return null; // Can't move the piece the opponent just moved.
|
||||
}
|
||||
}
|
||||
if ((selectedSquare < 0) &&
|
||||
((p == Piece.EMPTY) || (Piece.isWhite(p) != pos.whiteMove))) {
|
||||
return m; // You must click on one of your own pieces.
|
||||
return null; // You must click on one of your own pieces.
|
||||
}
|
||||
activeSquare = sq;
|
||||
dragging = false;
|
||||
dragX = dragY = -1;
|
||||
|
||||
Move m = null;
|
||||
if (selectedSquare >= 0) {
|
||||
if (sq == selectedSquare) {
|
||||
cancelSelection = true;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.util.Locale;
|
||||
|
||||
import uci.UCIProtocol;
|
||||
import chess.ChessParseError;
|
||||
@@ -89,14 +90,14 @@ public class TUIGame extends Game {
|
||||
try {
|
||||
int idx = cmd.indexOf(" ");
|
||||
String filename = cmd.substring(0, idx);
|
||||
String timeStr = cmd.substring(idx + 1, cmd.length());
|
||||
String timeStr = cmd.substring(idx + 1);
|
||||
int timeLimit = Integer.parseInt(timeStr);
|
||||
// System.out.printf("file:%s time:%s (%d)\n", filename, timeStr, timeLimit);
|
||||
fr = new LineNumberReader(new FileReader(filename));
|
||||
String line;
|
||||
Player pl = whitePlayer.isHumanPlayer() ? blackPlayer : whitePlayer;
|
||||
if (pl.isHumanPlayer()) {
|
||||
System.out.printf("No computer player available");
|
||||
System.out.print("No computer player available");
|
||||
return false;
|
||||
}
|
||||
ComputerPlayer cp = (ComputerPlayer)pl;
|
||||
@@ -178,9 +179,9 @@ public class TUIGame extends Game {
|
||||
if (haveDrawOffer()) {
|
||||
moveStr += " (offer draw)";
|
||||
}
|
||||
String msg = String.format("Last move: %d%s %s",
|
||||
String msg = String.format(Locale.US, "Last move: %d%s %s",
|
||||
prevPos.fullMoveCounter, prevPos.whiteMove ? "." : "...",
|
||||
moveStr);
|
||||
moveStr);
|
||||
System.out.println(msg);
|
||||
}
|
||||
// System.out.printf("Hash: %016x\n", pos.zobristHash());
|
||||
|
||||
@@ -43,37 +43,37 @@ import java.util.Random;
|
||||
|
||||
/** Control the search thread. */
|
||||
public class EngineControl {
|
||||
PrintStream os;
|
||||
private PrintStream os;
|
||||
|
||||
Thread engineThread;
|
||||
private Thread engineThread;
|
||||
private final Object threadMutex;
|
||||
Search sc;
|
||||
TranspositionTable tt;
|
||||
History ht;
|
||||
MoveGen moveGen;
|
||||
private Search sc;
|
||||
private TranspositionTable tt;
|
||||
private History ht;
|
||||
private MoveGen moveGen;
|
||||
|
||||
Position pos;
|
||||
long[] posHashList;
|
||||
int posHashListSize;
|
||||
boolean ponder; // True if currently doing pondering
|
||||
boolean onePossibleMove;
|
||||
boolean infinite;
|
||||
private Position pos;
|
||||
private long[] posHashList;
|
||||
private int posHashListSize;
|
||||
private boolean ponder; // True if currently doing pondering
|
||||
private boolean onePossibleMove;
|
||||
private boolean infinite;
|
||||
|
||||
int minTimeLimit;
|
||||
int maxTimeLimit;
|
||||
int maxDepth;
|
||||
int maxNodes;
|
||||
List<Move> searchMoves;
|
||||
private int minTimeLimit;
|
||||
private int maxTimeLimit;
|
||||
private int maxDepth;
|
||||
private int maxNodes;
|
||||
private List<Move> searchMoves;
|
||||
|
||||
// Options
|
||||
int hashSizeMB = 16;
|
||||
boolean ownBook = false;
|
||||
boolean analyseMode = false;
|
||||
boolean ponderMode = true;
|
||||
private int hashSizeMB = 16;
|
||||
private boolean ownBook = false;
|
||||
private boolean analyseMode = false;
|
||||
private boolean ponderMode = true;
|
||||
|
||||
// Reduced strength variables
|
||||
int strength = 1000;
|
||||
long randomSeed = 0;
|
||||
private int strength = 1000;
|
||||
private long randomSeed = 0;
|
||||
|
||||
/**
|
||||
* This class is responsible for sending "info" strings during search.
|
||||
@@ -202,7 +202,7 @@ public class EngineControl {
|
||||
final int margin = Math.min(1000, time * 9 / 10);
|
||||
int timeLimit = (time + inc * (moves - 1) - margin) / moves;
|
||||
minTimeLimit = (int)(timeLimit * 0.85);
|
||||
maxTimeLimit = (int)(minTimeLimit * (Math.max(2.5, Math.min(4.0, moves / 2))));
|
||||
maxTimeLimit = (int)(minTimeLimit * (Math.max(2.5, Math.min(4.0, moves * 0.5))));
|
||||
|
||||
// Leave at least 1s on the clock, but can't use negative time
|
||||
minTimeLimit = clamp(minTimeLimit, 1, time - margin);
|
||||
@@ -368,13 +368,13 @@ public class EngineControl {
|
||||
}
|
||||
|
||||
static void printOptions(PrintStream os) {
|
||||
os.printf("option name Hash type spin default 16 min 1 max 2048%n");
|
||||
os.printf("option name OwnBook type check default false%n");
|
||||
os.printf("option name Ponder type check default true%n");
|
||||
os.printf("option name UCI_AnalyseMode type check default false%n");
|
||||
os.print("option name Hash type spin default 16 min 1 max 2048%n");
|
||||
os.print("option name OwnBook type check default false%n");
|
||||
os.print("option name Ponder type check default true%n");
|
||||
os.print("option name UCI_AnalyseMode type check default false%n");
|
||||
os.printf("option name UCI_EngineAbout type string default %s by Peter Osterlund, see http://web.comhem.se/petero2home/javachess/index.html%n",
|
||||
ComputerPlayer.engineName);
|
||||
os.printf("option name Strength type spin default 1000 min 0 max 1000\n");
|
||||
os.print("option name Strength type spin default 1000 min 0 max 1000\n");
|
||||
|
||||
for (String pName : Parameters.instance().getParamNames()) {
|
||||
ParamBase p = Parameters.instance().getParam(pName);
|
||||
@@ -396,7 +396,7 @@ public class EngineControl {
|
||||
os.printf("option name %s type combo default %s ", cp.name, cp.defaultValue);
|
||||
for (String s : cp.allowedValues)
|
||||
os.printf(" var %s", s);
|
||||
os.printf("\n");
|
||||
os.print("\n");
|
||||
break;
|
||||
}
|
||||
case BUTTON:
|
||||
@@ -428,7 +428,7 @@ public class EngineControl {
|
||||
} else {
|
||||
Parameters.instance().set(optionName, optionValue);
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ import java.util.ArrayList;
|
||||
/** Handle the UCI protocol mode. */
|
||||
public class UCIProtocol {
|
||||
// Data set by the "position" command.
|
||||
Position pos;
|
||||
ArrayList<Move> moves;
|
||||
private Position pos;
|
||||
private ArrayList<Move> moves;
|
||||
|
||||
// Engine data
|
||||
EngineControl engine;
|
||||
private EngineControl engine;
|
||||
|
||||
// Set to true to break out of main loop
|
||||
boolean quit;
|
||||
private boolean quit;
|
||||
|
||||
|
||||
public static void main(boolean autoStart) {
|
||||
@@ -54,7 +54,7 @@ public class UCIProtocol {
|
||||
quit = false;
|
||||
}
|
||||
|
||||
final public void mainLoop(InputStream is, PrintStream os, boolean autoStart) {
|
||||
private void mainLoop(InputStream is, PrintStream os, boolean autoStart) {
|
||||
try {
|
||||
if (autoStart) {
|
||||
handleCommand("uci", os);
|
||||
@@ -73,7 +73,7 @@ public class UCIProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
final void handleCommand(String cmdLine, PrintStream os) {
|
||||
private void handleCommand(String cmdLine, PrintStream os) {
|
||||
String[] tokens = tokenize(cmdLine);
|
||||
try {
|
||||
String cmd = tokens[0];
|
||||
@@ -199,9 +199,9 @@ public class UCIProtocol {
|
||||
}
|
||||
quit = true;
|
||||
}
|
||||
} catch (ChessParseError ex) {
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (ChessParseError ignore) {
|
||||
} catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ public class UCIProtocolTest {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
Reference in New Issue
Block a user