Fix some Android Studio warnings.

This commit is contained in:
Peter Osterlund
2019-03-30 15:44:35 +01:00
parent 8a0a495830
commit 78b4ac2762
77 changed files with 324 additions and 664 deletions

View File

@@ -18,12 +18,8 @@
package chess;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;

View File

@@ -40,16 +40,16 @@ public class ComputerPlayer implements Player {
engineName = name;
}
int minTimeMillis;
private int minTimeMillis;
int maxTimeMillis;
int maxDepth;
int maxNodes;
private int maxNodes;
public boolean verbose;
TranspositionTable tt;
Book book;
boolean bookEnabled;
boolean randomMode;
Search currentSearch;
private TranspositionTable tt;
private Book book;
private boolean bookEnabled;
private boolean randomMode;
private Search currentSearch;
public ComputerPlayer() {
minTimeMillis = 10000;
@@ -67,7 +67,7 @@ public class ComputerPlayer implements Player {
tt = new TranspositionTable(logSize);
}
Search.Listener listener;
private Search.Listener listener;
public void setListener(Search.Listener listener) {
this.listener = listener;
}
@@ -107,7 +107,7 @@ public class ComputerPlayer implements Player {
currentSearch = sc;
sc.setListener(listener);
Move bestM;
if ((moves.size == 1) && (canClaimDraw(pos, posHashList, posHashListSize, moves.m[0]) == "")) {
if ((moves.size == 1) && canClaimDraw(pos, posHashList, posHashListSize, moves.m[0]).isEmpty()) {
bestM = moves.m[0];
bestM.score = 0;
} else if (randomMode) {
@@ -123,7 +123,7 @@ public class ComputerPlayer implements Player {
// Claim draw if appropriate
if (bestM.score <= 0) {
String drawClaim = canClaimDraw(pos, posHashList, posHashListSize, bestM);
if (drawClaim != "")
if (!drawClaim.isEmpty())
strMove = drawClaim;
}
return strMove;

View File

@@ -340,7 +340,7 @@ public class Evaluate {
// Knights
{
final int t1 = qV + 2 * rV + 1 * bV + 1 * nV + 6 * pV;
final int t1 = qV + 2 * rV + bV + nV + 6 * pV;
final int t2 = nV + 8 * pV;
int n1 = pos.psScore1[Piece.WKNIGHT];
int n2 = pos.psScore2[Piece.WKNIGHT];

View File

@@ -26,12 +26,12 @@ import java.util.Locale;
public class Game {
protected List<Move> moveList = null;
protected List<UndoInfo> uiInfoList = null;
List<Boolean> drawOfferList = null;
private List<Boolean> drawOfferList = null;
protected int currentMove;
boolean pendingDrawOffer;
GameState drawState;
String drawStateMoveStr; // Move required to claim DRAW_REP or DRAW_50
GameState resignState;
private String drawStateMoveStr; // Move required to claim DRAW_REP or DRAW_50
private GameState resignState;
public Position pos = null;
protected Player whitePlayer;
protected Player blackPlayer;
@@ -373,10 +373,7 @@ public class Game {
UndoInfo ui = new UndoInfo();
pos.makeMove(move, ui);
}
if ((whiteMove.length() > 0) || (blackMove.length() > 0)) {
if (whiteMove.length() == 0) {
whiteMove = "...";
}
if (whiteMove.length() > 0) {
if (compressed) {
ret.append(String.format(Locale.US, "%d. %s %s ",
pos.fullMoveCounter, whiteMove, blackMove));

View File

@@ -773,12 +773,12 @@ public final class MoveGen {
switch (d1) {
case 8: case -8: case 1: case -1: // Rook direction
if ((p == Piece.WQUEEN) || (p == Piece.WROOK))
if ((d1 != 0) && (MoveGen.nextPiece(pos, m.to, d1) == oKing))
if (MoveGen.nextPiece(pos, m.to, d1) == oKing)
return true;
break;
case 9: case 7: case -9: case -7: // Bishop direction
if ((p == Piece.WQUEEN) || (p == Piece.WBISHOP)) {
if ((d1 != 0) && (MoveGen.nextPiece(pos, m.to, d1) == oKing))
if (MoveGen.nextPiece(pos, m.to, d1) == oKing)
return true;
} else if (p == Piece.WPAWN) {
if (((d1 > 0) == wtm) && (pos.getPiece(m.to + d1) == oKing))

View File

@@ -5,7 +5,7 @@ import java.util.Map;
import java.util.TreeMap;
public class Parameters {
public static enum Type {
public enum Type {
CHECK,
SPIN,
COMBO,
@@ -115,8 +115,7 @@ public class Parameters {
return ((CheckParam)params.get(name.toLowerCase())).value;
}
final int getIntPar(String name) {
int ret = ((SpinParam)params.get(name.toLowerCase())).value;
return ret;
return ((SpinParam)params.get(name.toLowerCase())).value;
}
final String getStringPar(String name) {
return ((StringParam)params.get(name.toLowerCase())).value;
@@ -141,7 +140,7 @@ public class Parameters {
int val = Integer.parseInt(value);
if ((val >= sp.minValue) && (val <= sp.maxValue))
sp.value = val;
} catch (NumberFormatException ex) {
} catch (NumberFormatException ignore) {
}
break;
}

View File

@@ -307,7 +307,7 @@ public class Position {
* Set a square to a piece value.
* Special version that only updates enough of the state for the SEE function to be happy.
*/
public final void setSEEPiece(int square, int piece) {
private void setSEEPiece(int square, int piece) {
int removedPiece = squares[square];
// Update board

View File

@@ -396,13 +396,12 @@ public class TextIO {
* @return A move object, or null if move has invalid syntax
*/
public static Move uciStringToMove(String move) {
Move m = null;
if ((move.length() < 4) || (move.length() > 5))
return m;
return null;
int fromSq = TextIO.getSquare(move.substring(0, 2));
int toSq = TextIO.getSquare(move.substring(2, 4));
if ((fromSq < 0) || (toSq < 0)) {
return m;
return null;
}
char prom = ' ';
boolean white = true;
@@ -413,7 +412,7 @@ public class TextIO {
} else if (Position.getY(toSq) == 0) {
white = false;
} else {
return m;
return null;
}
}
int promoteTo;
@@ -434,20 +433,15 @@ public class TextIO {
promoteTo = white ? Piece.WKNIGHT : Piece.BKNIGHT;
break;
default:
return m;
return null;
}
m = new Move(fromSq, toSq, promoteTo);
return m;
return new Move(fromSq, toSq, promoteTo);
}
private static boolean isCapture(Position pos, Move move) {
if (pos.getPiece(move.to) == Piece.EMPTY) {
int p = pos.getPiece(move.from);
if ((p == (pos.whiteMove ? Piece.WPAWN : Piece.BPAWN)) && (move.to == pos.getEpSquare())) {
return true;
} else {
return false;
}
return (p == (pos.whiteMove ? Piece.WPAWN : Piece.BPAWN)) && (move.to == pos.getEpSquare());
} else {
return true;
}
@@ -460,9 +454,8 @@ public class TextIO {
*/
public static Move stringToMove(Position pos, String strMove) {
strMove = strMove.replaceAll("=", "");
Move move = null;
if (strMove.length() == 0)
return move;
return null;
MoveGen.MoveList moves = MoveGen.instance.pseudoLegalMoves(pos);
MoveGen.removeIllegal(pos, moves);
{
@@ -501,7 +494,8 @@ public class TextIO {
}
}
}
Move move = null;
for (int i = 0; i < 2; i++) {
// Search for unique substring match
for (int mi = 0; mi < moves.size; mi++) {
@@ -526,7 +520,7 @@ public class TextIO {
if (move != null)
return move;
}
return move;
return null;
}
/**

View File

@@ -107,9 +107,9 @@ public class TranspositionTable {
depthSlot |= (s << 15);
}
}
TTEntry[] table;
TTEntry emptySlot;
byte generation;
private TTEntry[] table;
private TTEntry emptySlot;
private byte generation;
/** Constructor. Creates an empty transposition table with numEntries slots. */
public TranspositionTable(int log2Size) {

View File

@@ -37,7 +37,7 @@ import chess.TranspositionTable.TTEntry;
public final class TreeLogger {
private byte[] entryBuffer = new byte[16];
private ByteBuffer bb = ByteBuffer.wrap(entryBuffer);
// Used in write mode
private FileOutputStream os = null;
private BufferedOutputStream bos = null;
@@ -96,7 +96,7 @@ public final class TreeLogger {
} catch (IOException e) {
throw new RuntimeException();
} finally {
if (raf != null) try { raf.close(); } catch (IOException e) {}
if (raf != null) try { raf.close(); } catch (IOException ignore) {}
}
}
@@ -104,7 +104,7 @@ public final class TreeLogger {
try {
if (bos != null) bos.close();
if (fc != null) fc.close();
} catch (IOException e) {
} catch (IOException ignore) {
}
}
@@ -143,7 +143,7 @@ public final class TreeLogger {
/**
* Log information when entering a search node.
* @param parentId Index of parent node.
* @param parentIndex Index of parent node.
* @param m Move made to go from parent node to this node
* @param alpha Search parameter
* @param beta Search parameter
@@ -199,7 +199,7 @@ public final class TreeLogger {
private void computeForwardPointers() {
if ((mapBuf.get(127) & (1<<7)) != 0)
return;
System.out.printf("Computing forward pointers...\n");
System.out.print("Computing forward pointers...\n");
StartEntry se = new StartEntry();
EndEntry ee = new EndEntry();
for (int i = 0; i < numEntries; i++) {
@@ -296,7 +296,7 @@ public final class TreeLogger {
ArrayList<Move> moves = getMoveSequence(currIndex);
for (Move m : moves)
System.out.printf(" %s", TextIO.moveToUCIString(m));
System.out.printf("\n");
System.out.print("\n");
printNodeInfo(rootPos, currIndex);
Position pos = getPosition(rootPos, currIndex);
System.out.print(TextIO.asciiBoard(pos));
@@ -309,7 +309,7 @@ public final class TreeLogger {
}
}
doPrint = true;
System.out.printf("Command:");
System.out.print("Command:");
String cmdStr = in.readLine();
if (cmdStr == null)
return;
@@ -332,10 +332,10 @@ public final class TreeLogger {
found.add(c);
}
if (found.size() == 0) {
System.out.printf("No such move\n");
System.out.print("No such move\n");
doPrint = false;
} else if (found.size() > 1) {
System.out.printf("Ambiguous move\n");
System.out.print("Ambiguous move\n");
for (Integer c : found)
printNodeInfo(rootPos, c);
doPrint = false;
@@ -370,7 +370,7 @@ public final class TreeLogger {
ArrayList<Move> moves = getMoveSequence(currIndex);
for (Move m : moves)
System.out.printf(" %s", TextIO.moveToUCIString(m));
System.out.printf("\n");
System.out.print("\n");
doPrint = false;
} else if (cmdStr.startsWith("h")) {
long hashKey = getPosition(rootPos, currIndex).historyHash();
@@ -384,7 +384,7 @@ public final class TreeLogger {
int i = Integer.parseInt(cmdStr);
if ((i >= -1) && (i < numEntries))
currIndex = i;
} catch (NumberFormatException e) {
} catch (NumberFormatException ignore) {
}
}
prevStr = cmdStr;
@@ -437,7 +437,7 @@ public final class TreeLogger {
s = s.substring(2);
try {
key = Long.parseLong(s, 16);
} catch (NumberFormatException e) {
} catch (NumberFormatException ignore) {
}
}
return key;
@@ -450,13 +450,13 @@ public final class TreeLogger {
if (idx > 0) {
return Integer.parseInt(s.substring(idx+1));
}
} catch (NumberFormatException e) {
} catch (NumberFormatException ignore) {
}
return defVal;
}
/** Get a list of integer parameters from an input string. */
final ArrayList<Integer> getArgs(String s, int defVal) {
private ArrayList<Integer> getArgs(String s, int defVal) {
ArrayList<Integer> ret = new ArrayList<>();
String[] split = s.split(" ");
try {
@@ -612,7 +612,7 @@ public final class TreeLogger {
System.out.printf(" s:%s%6d e:%6d sub:%d", type, ee.score, ee.evalScore,
subTreeNodes);
}
System.out.printf("\n");
System.out.print("\n");
}
}
}

View File

@@ -41,16 +41,16 @@ import java.util.Scanner;
/** The glue between the chess engine and the GUI. */
public class ChessController {
Player humanPlayer;
ComputerPlayer computerPlayer;
private Player humanPlayer;
private ComputerPlayer computerPlayer;
Game game;
GUIInterface gui;
boolean humanIsWhite;
Thread computerThread;
int threadStack; // Thread stack size, or zero to use OS default
private GUIInterface gui;
private boolean humanIsWhite;
private Thread computerThread;
private int threadStack; // Thread stack size, or zero to use OS default
// Search statistics
String thinkingPV;
private String thinkingPV;
class SearchListener implements Search.Listener {
int currDepth = 0;
@@ -133,7 +133,7 @@ public class ChessController {
setSearchInfo();
}
}
SearchListener listener;
private SearchListener listener;
public ChessController(GUIInterface gui) {
this.gui = gui;
@@ -172,10 +172,8 @@ public class ChessController {
Position pos = TextIO.readFEN(fen);
game.processString("new");
game.pos = pos;
String[] strArr = posHistStr.get(1).split(" ");
final int arrLen = strArr.length;
for (int i = 0; i < arrLen; i++) {
game.processString(strArr[i]);
for (String s : posHistStr.get(1).split(" ")) {
game.processString(s);
}
int numUndo = Integer.parseInt(posHistStr.get(2));
for (int i = 0; i < numUndo; i++) {
@@ -223,11 +221,9 @@ public class ChessController {
pgn.append("[SetUp \"1\"]\n");
}
pgn.append("\n");
String[] strArr = moves.split(" ");
int currLineLength = 0;
final int arrLen = strArr.length;
for (int i = 0; i < arrLen; i++) {
String move = strArr[i].trim();
for (String s : moves.split(" ")) {
String move = s.trim();
int moveLen = move.length();
if (moveLen > 0) {
if (currLineLength + 1 + moveLen >= 80) {
@@ -408,7 +404,7 @@ public class ChessController {
}
}
Move promoteMove;
private Move promoteMove;
public final void reportPromotePiece(int choice) {
final boolean white = game.pos.whiteMove;
int promoteTo;
@@ -482,7 +478,7 @@ public class ChessController {
gui.setMoveListString(str);
}
public final void setThinkingPV() {
private void setThinkingPV() {
String str = "";
if (gui.showThinking()) {
str = thinkingPV;

View File

@@ -29,16 +29,15 @@ public class BitBoardTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/** Test of kingAttacks, of class BitBoard. */
@Test
public void testKingAttacks() throws ChessParseError {
public void testKingAttacks() {
System.out.println("kingAttacks");
assertEquals(5, Long.bitCount(BitBoard.kingAttacks[TextIO.getSquare("g1")]));
assertEquals(3, Long.bitCount(BitBoard.kingAttacks[TextIO.getSquare("h1")]));
@@ -49,9 +48,8 @@ public class BitBoardTest {
assertEquals(8, Long.bitCount(BitBoard.kingAttacks[TextIO.getSquare("b2")]));
}
/** Test of knightAttacks, of class BitBoard. */
@Test
public void testKnightAttacks() throws ChessParseError {
public void testKnightAttacks() {
System.out.println("knightAttacks");
assertEquals(3, Long.bitCount(BitBoard.knightAttacks[TextIO.getSquare("g1")]));
assertEquals(2, Long.bitCount(BitBoard.knightAttacks[TextIO.getSquare("a1")]));
@@ -65,9 +63,8 @@ public class BitBoardTest {
BitBoard.knightAttacks[TextIO.getSquare("g1")]);
}
/** Test of squaresBetween[][], of class BitBoard. */
@Test
public void testSquaresBetween() throws ChessParseError {
public void testSquaresBetween() {
System.out.println("squaresBetween");
// Tests that the set of nonzero elements is correct
for (int sq1 = 0; sq1 < 64; sq1++) {

View File

@@ -29,16 +29,13 @@ public class BookTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of getBookMove method, of class Book.
*/
@Test
public void testGetBookMove() throws ChessParseError {
System.out.println("getBookMove");
@@ -48,9 +45,6 @@ public class BookTest {
checkValid(pos, move);
}
/**
* Test of getAllBookMoves method, of class Book.
*/
@Test
public void testGetAllBookMoves() throws ChessParseError {
System.out.println("getAllBookMoves");
@@ -67,7 +61,7 @@ public class BookTest {
/** Check that move is a legal move in position pos. */
private void checkValid(Position pos, Move move) {
assertTrue(move != null);
assertNotNull(move);
MoveGen.MoveList moveList = new MoveGen().pseudoLegalMoves(pos);
MoveGen.removeIllegal(pos, moveList);
boolean contains = false;

View File

@@ -30,16 +30,13 @@ public class ComputerPlayerTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of getCommand method, of class ComputerPlayer.
*/
@Test
public void testGetCommand() throws ChessParseError {
System.out.println("getCommand");
@@ -71,11 +68,8 @@ public class ComputerPlayerTest {
assertEquals("Kxg8", result);
}
/**
* Test of draw by repetition, of class ComputerPlayer.
*/
@Test
public void testDrawRep() throws ChessParseError {
public void testDrawRep() {
System.out.println("drawRep");
Game game = new Game(new HumanPlayer(), new HumanPlayer());
ComputerPlayer cp = new ComputerPlayer();

View File

@@ -36,9 +36,6 @@ public class EvaluateTest {
public static void tearDownClass() throws Exception {
}
/**
* Test of evalPos method, of class Evaluate.
*/
@Test
public void testEvalPos() throws ChessParseError {
System.out.println("evalPos");
@@ -102,9 +99,6 @@ public class EvaluateTest {
assertTrue(sc2 > sc1);
}
/**
* Test of pieceSquareEval method, of class Evaluate.
*/
@Test
public void testPieceSquareEval() throws ChessParseError {
System.out.println("pieceSquareEval");
@@ -143,9 +137,6 @@ public class EvaluateTest {
assertTrue(score > 100); // Two rooks on 7:th rank is very good
}
/**
* Test of tradeBonus method, of class Evaluate.
*/
@Test
public void testTradeBonus() throws ChessParseError {
System.out.println("tradeBonus");
@@ -172,9 +163,6 @@ public class EvaluateTest {
assertTrue(score2 > score1); // White ahead, trading pieces is good
}
/**
* Test of material method, of class Evaluate.
*/
@Test
public void testMaterial() throws ChessParseError {
System.out.println("material");
@@ -204,9 +192,6 @@ public class EvaluateTest {
assertEquals(-pV+qV, Evaluate.material(pos));
}
/**
* Test of kingSafety method, of class Evaluate.
*/
@Test
public void testKingSafety() throws ChessParseError {
System.out.println("kingSafety");
@@ -233,9 +218,6 @@ public class EvaluateTest {
assertTrue(s2 < s1);
}
/**
* Test of endGameEval method, of class Evaluate.
*/
@Test
public void testEndGameEval() throws ChessParseError {
System.out.println("endGameEval");
@@ -312,9 +294,6 @@ public class EvaluateTest {
assertTrue(score > 0);
}
/**
* Test of endGameEval method, of class Evaluate.
*/
@Test
public void testPassedPawns() throws ChessParseError {
System.out.println("passedPawns");
@@ -341,9 +320,6 @@ public class EvaluateTest {
// assertTrue(score2 > score); // Advancing passed pawn is good
}
/**
* Test of endGameEval method, of class Evaluate.
*/
@Test
public void testBishAndRookPawns() throws ChessParseError {
System.out.println("bishAndRookPawns");
@@ -394,9 +370,6 @@ public class EvaluateTest {
assertTrue(evalWhite(pos) > 0); // Black has trapped bishop
}
/**
* Test of endGameEval method, of class Evaluate.
*/
@Test
public void testKQKP() throws ChessParseError {
System.out.println("KQKP");

View File

@@ -29,16 +29,13 @@ public class GameTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of haveDrawOffer method, of class Game.
*/
@Test
public void testHaveDrawOffer() {
System.out.println("haveDrawOffer");
@@ -129,9 +126,6 @@ public class GameTest {
assertEquals(false, game.haveDrawOffer());
}
/**
* Test of draw by 50 move rule, of class Game.
*/
@Test
public void testDraw50() {
System.out.println("draw50");
@@ -188,9 +182,6 @@ public class GameTest {
assertEquals(Game.GameState.ALIVE, game.drawState);
}
/**
* Test of draw by repetition, of class Game.
*/
@Test
public void testDrawRep() {
System.out.println("drawRep");
@@ -262,9 +253,6 @@ public class GameTest {
assertEquals(Game.GameState.DRAW_REP, game.getGameState());
}
/**
* Test of resign command, of class Game.
*/
@Test
public void testResign() {
System.out.println("resign");
@@ -289,9 +277,6 @@ public class GameTest {
assertEquals(Game.GameState.BLACK_MATE, game.getGameState()); // Can't resign after game over
}
/**
* Test of processString method, of class Game.
*/
@Test
public void testProcessString() throws ChessParseError {
System.out.println("processString");
@@ -344,9 +329,6 @@ public class GameTest {
assertEquals(false, res);
}
/**
* Test of getGameState method, of class Game.
*/
@Test
public void testGetGameState() {
System.out.println("getGameState");
@@ -362,9 +344,6 @@ public class GameTest {
assertEquals(Game.GameState.BLACK_STALEMATE, game.getGameState());
}
/**
* Test of insufficientMaterial method, of class Game.
*/
@Test
public void testInsufficientMaterial() {
System.out.println("insufficientMaterial");
@@ -407,9 +386,6 @@ public class GameTest {
assertEquals(Game.GameState.ALIVE, game.getGameState());
}
/**
* Test of perfT method, of class Game.
*/
@Test
public void testPerfT() {
System.out.println("perfT");

View File

@@ -31,11 +31,11 @@ public class HistoryTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
@Before
@@ -46,9 +46,6 @@ public class HistoryTest {
public void tearDown() {
}
/**
* Test of getHistScore method, of class History.
*/
@Test
public void testGetHistScore() throws ChessParseError {
System.out.println("getHistScore");

View File

@@ -29,16 +29,13 @@ public class KillerTableTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of addKiller method, of class KillerTable.
*/
@Test
public void testAddKiller() {
System.out.println("addKiller");
@@ -50,9 +47,6 @@ public class KillerTableTest {
kt.addKiller(3, m);
}
/**
* Test of getKillerScore method, of class KillerTable.
*/
@Test
public void testGetKillerScore() {
System.out.println("getKillerScore");

View File

@@ -31,16 +31,13 @@ public class MoveGenTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of pseudoLegalMoves method, of class MoveGen.
*/
@Test
public void testPseudoLegalMoves() throws ChessParseError {
System.out.println("pseudoLegalMoves");
@@ -86,9 +83,6 @@ public class MoveGenTest {
assertTrue(strMoves.contains("e1c1"));
}
/**
* Test of pseudoLegalMoves method, of class MoveGen. Pawn moves.
*/
@Test
public void testPawnMoves() throws ChessParseError {
System.out.println("pawnMoves");
@@ -128,9 +122,6 @@ public class MoveGenTest {
assertTrue(strMoves.contains("a2a1b"));
}
/**
* Test of inCheck method, of class MoveGen.
*/
@Test
public void testInCheck() {
System.out.println("inCheck");
@@ -163,9 +154,6 @@ public class MoveGenTest {
assertEquals(false, MoveGen.inCheck(pos));
}
/**
* Test of givesCheck method, of class MoveGen.
*/
@Test
public void testGivesCheck() throws ChessParseError {
System.out.println("givesCheck");
@@ -321,9 +309,6 @@ public class MoveGenTest {
assertTrue(MoveGen.givesCheck(pos, TextIO.stringToMove(pos, "exf3")));
}
/**
* Test of removeIllegal method, of class MoveGen.
*/
@Test
public void testRemoveIllegal() throws ChessParseError {
System.out.println("removeIllegal");
@@ -347,9 +332,6 @@ public class MoveGenTest {
assertEquals(1, strMoves.size());
}
/**
* Test that if king capture is possible, only a king capture move is returned in the move list.
*/
@Test
public void testKingCapture() throws ChessParseError {
System.out.println("kingCapture");

View File

@@ -31,11 +31,11 @@ public class MoveTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
@Before
@@ -46,9 +46,6 @@ public class MoveTest {
public void tearDown() {
}
/**
* Test of move constructor, of class Move.
*/
@Test
public void testMoveConstructor() {
System.out.println("MoveTest");
@@ -61,9 +58,6 @@ public class MoveTest {
assertEquals(move.promoteTo, p);
}
/**
* Test of equals, of class Move.
*/
@Test
public void testEquals() {
System.out.println("equals");

View File

@@ -29,16 +29,13 @@ public class PieceTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of isWhite method, of class Piece.
*/
@Test
public void testIsWhite() {
System.out.println("isWhite");

View File

@@ -33,11 +33,11 @@ public class PositionTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
@Before
@@ -48,9 +48,6 @@ public class PositionTest {
public void tearDown() {
}
/**
* Test of getPiece method, of class Position.
*/
@Test
public void testGetPiece() throws ChessParseError {
System.out.println("getPiece");
@@ -71,9 +68,6 @@ public class PositionTest {
}
}
/**
* Test of getIndex method, of class Position.
*/
@Test
public void testGetIndex() {
System.out.println("getIndex");
@@ -88,9 +82,6 @@ public class PositionTest {
}
}
/**
* Test of setPiece method, of class Position.
*/
@Test
public void testSetPiece() {
System.out.println("setPiece");
@@ -100,9 +91,6 @@ public class PositionTest {
assertEquals(Piece.WKING, instance.getPiece(Position.getSquare(3, 4)));
}
/**
* Test of makeMove method, of class Position.
*/
@Test
public void testMakeMove() throws ChessParseError {
System.out.println("makeMove");
@@ -212,9 +200,6 @@ public class PositionTest {
assertEquals(castleMask, pos.getCastleMask());
}
/**
* Test of makeMove method, of class Position.
*/
@Test
public void testPromotion() throws ChessParseError {
System.out.println("promotion");
@@ -251,10 +236,7 @@ public class PositionTest {
pos.unMakeMove(move, ui);
assertEquals(origPos, pos);
}
/**
* Test move counters, of class Position.
*/
@Test
public void testMoveCounters() throws ChessParseError {
System.out.println("moveCounters");
@@ -316,9 +298,6 @@ public class PositionTest {
assertEquals(69, pos.fullMoveCounter);
}
/**
* Test of drawRuleEquals, of class Position.
*/
@Test
public void testDrawRuleEquals() throws ChessParseError {
System.out.println("drawRuleEquals");
@@ -361,9 +340,6 @@ public class PositionTest {
assertEquals(false, pos.drawRuleEquals(origPos)); // Not equal, en passant rights lost
}
/**
* Test of hashCode method, of class Position.
*/
@Test
public void testHashCode() throws ChessParseError {
System.out.println("hashCode");
@@ -417,9 +393,6 @@ public class PositionTest {
}
}
/**
* Test of getKingSq method, of class Position.
*/
@Test
public void testGetKingSq() throws ChessParseError {
System.out.println("getKingSq");

View File

@@ -34,16 +34,13 @@ public class SearchTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of negaScout method, of class Search.
*/
@Test
public void testNegaScout() throws ChessParseError, StopSearch {
System.out.println("negaScout");
@@ -89,9 +86,6 @@ public class SearchTest {
assertTrue(!TextIO.moveToString(pos, bestM, false).equals("Qxb3"));
}
/**
* Test of draw by 50 move rule, of class Search.
*/
@Test
public void testDraw50() throws ChessParseError, StopSearch {
System.out.println("draw50");
@@ -151,9 +145,6 @@ public class SearchTest {
assertEquals(mateInThree, score); // Need an extra pawn move to avoid 50-move rule
}
/**
* Test of draw by repetition rule, of class Search.
*/
@Test
public void testDrawRep() throws ChessParseError, StopSearch {
System.out.println("drawRep");
@@ -190,9 +181,6 @@ public class SearchTest {
assertEquals(0, score); // Draw, black can not escape from perpetual checks
}
/**
* Test of hash table, of class Search.
*/
@Test
public void testHashing() throws ChessParseError {
System.out.println("hashing");
@@ -202,9 +190,6 @@ public class SearchTest {
assertEquals(TextIO.stringToMove(pos, "Kb1"), new Move(bestM));
}
/**
* Late move pruning must not be used in mate search.
*/
@Test
public void testLMP() throws ChessParseError {
Position pos = TextIO.readFEN("2r2rk1/6p1/p3pq1p/1p1b1p2/3P1n2/PP3N2/3N1PPP/1Q2RR1K b"); // WAC 174
@@ -270,9 +255,6 @@ public class SearchTest {
return see;
}
/**
* Test of SEE method, of class Search.
*/
@Test
public void testSEE() throws ChessParseError {
System.out.println("SEE");
@@ -423,9 +405,6 @@ public class SearchTest {
assertEquals(h1, h2);
}
/**
* Test of scoreMoveList method, of class Search.
*/
@Test
public void testScoreMoveList() throws ChessParseError {
System.out.println("SEEorder");

View File

@@ -31,11 +31,11 @@ public class TextIOTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
@Before
@@ -46,9 +46,6 @@ public class TextIOTest {
public void tearDown() {
}
/**
* Test of readFEN method, of class TextIO.
*/
@Test
public void testReadFEN() throws ChessParseError {
System.out.println("readFEN");
@@ -123,9 +120,6 @@ public class TextIOTest {
return wasError;
}
/**
* Test of moveToString method, of class TextIO.
*/
@Test
public void testMoveToString() throws ChessParseError {
System.out.println("moveToString");
@@ -162,9 +156,6 @@ public class TextIOTest {
assertEquals("c7-c8Q+", result);
}
/**
* Test of moveToString method, of class TextIO, mate/stalemate tests.
*/
@Test
public void testMoveToStringMate() throws ChessParseError {
System.out.println("moveToStringMate");
@@ -188,9 +179,6 @@ public class TextIOTest {
assertEquals("b7-b8B", result); // stalemate
}
/**
* Test of moveToString method, of class TextIO, short form.
*/
@Test
public void testMoveToStringShortForm() throws ChessParseError {
System.out.println("moveToStringShortForm");
@@ -240,9 +228,6 @@ public class TextIOTest {
assertEquals("Rfd8", result); // File disambiguation needed
}
/**
* Test of stringToMove method, of class TextIO.
*/
@Test
public void testStringToMove() throws ChessParseError {
System.out.println("stringToMove");
@@ -324,9 +309,6 @@ public class TextIOTest {
assertEquals(m2, m);
}
/**
* Test of getSquare method, of class TextIO.
*/
@Test
public void testGetSquare() throws ChessParseError {
System.out.println("getSquare");
@@ -338,9 +320,6 @@ public class TextIOTest {
assertEquals(Position.getSquare(7, 7), TextIO.getSquare("h8"));
}
/**
* Test of squareToString method, of class TextIO.
*/
@Test
public void testSquareToString() {
System.out.println("squareToString");
@@ -349,9 +328,6 @@ public class TextIOTest {
assertEquals("e4", TextIO.squareToString(Position.getSquare(4, 3)));
}
/**
* Test of asciiBoard method, of class TextIO.
*/
@Test
public void testAsciiBoard() throws ChessParseError {
System.out.println("asciiBoard");
@@ -363,9 +339,6 @@ public class TextIOTest {
assertEquals(3, aBrd.length() - aBrd.replaceAll(" P", " ").length()); // 3 white pawns
}
/**
* Test of uciStringToMove method, of class TextIO.
*/
@Test
public void testUciStringToMove() throws ChessParseError {
System.out.println("stringToMove");

View File

@@ -30,16 +30,13 @@ public class TranspositionTableTest {
}
@BeforeClass
public static void setUpClass() throws Exception {
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() throws Exception {
public static void tearDownClass() {
}
/**
* Test of TTEntry nested class, of class TranspositionTable.
*/
@Test
public void testTTEntry() throws ChessParseError {
System.out.println("TTEntry");
@@ -115,9 +112,6 @@ public class TranspositionTableTest {
assertEquals(score - 2, ent3.getScore(ply - 2));
}
/**
* Test of insert method, of class TranspositionTable.
*/
@Test
public void testInsert() throws ChessParseError {
System.out.println("insert");

View File

@@ -35,7 +35,7 @@ public class ChessControllerTest {
ctrl.setPGN("[FEN \"k/8/8/8/8/8/KP/8 w\"]\n");
assertEquals(TextIO.getSquare("a2"), ctrl.game.pos.getKingSq(true));
assertEquals(TextIO.getSquare("a8"), ctrl.game.pos.getKingSq(false));
ctrl.setPGN("1.e4 e5 2. Nf3!!! $6 (Nc3 (a3)) Nc6?? Bb5!!? a6?! * Ba4");
assertEquals(Piece.BPAWN, ctrl.game.pos.getPiece(TextIO.getSquare("a6")));
assertEquals(Piece.WBISHOP, ctrl.game.pos.getPiece(TextIO.getSquare("b5")));