Refined IO functionality, fixed FEN string serialization and deserialization #7

Merged
CyB3RC0nN0R merged 7 commits from feature/io into master 2019-10-25 17:01:56 +02:00
3 changed files with 14 additions and 14 deletions
Showing only changes of commit 73f5e17405 - Show all commits

View File

@ -561,7 +561,7 @@ public class Board {
log.setHalfmoveClock(Integer.parseInt(parts[4]));
// Fullmove counter
log.setFullmoveCounter(Integer.parseInt(parts[5]));
log.setFullmoveNumber(Integer.parseInt(parts[5]));
}
/**

View File

@ -16,7 +16,7 @@ public class Log implements Iterable<MoveNode> {
private Position enPassant;
private Color activeColor;
private int fullmoveCounter, halfmoveClock;
private int fullmoveNumber, halfmoveClock;
public Log() {
reset();
@ -34,7 +34,7 @@ public class Log implements Iterable<MoveNode> {
public Log(Log other, boolean copyVariations) {
enPassant = other.enPassant;
activeColor = other.activeColor;
fullmoveCounter = other.fullmoveCounter;
fullmoveNumber = other.fullmoveNumber;
halfmoveClock = other.halfmoveClock;
// The new root is the current node of the copied instance
@ -76,11 +76,11 @@ public class Log implements Iterable<MoveNode> {
*/
public void add(Move move, Piece capturedPiece, boolean pawnMove) {
enPassant = pawnMove && move.yDist == 2 ? new Position(move.pos.x, move.pos.y + move.ySign) : null;
if (activeColor == Color.BLACK) ++fullmoveCounter;
if (activeColor == Color.BLACK) ++fullmoveNumber;
if (pawnMove || capturedPiece != null) halfmoveClock = 0;
else++halfmoveClock;
activeColor = activeColor.opposite();
final MoveNode leaf = new MoveNode(move, capturedPiece, enPassant, activeColor, fullmoveCounter, halfmoveClock);
final MoveNode leaf = new MoveNode(move, capturedPiece, enPassant, activeColor, fullmoveNumber, halfmoveClock);
if (isEmpty()) {
root = leaf;
@ -118,7 +118,7 @@ public class Log implements Iterable<MoveNode> {
current = null;
enPassant = null;
activeColor = Color.WHITE;
fullmoveCounter = 1;
fullmoveNumber = 1;
halfmoveClock = 0;
}
@ -156,7 +156,7 @@ public class Log implements Iterable<MoveNode> {
private void update() {
activeColor = current.activeColor;
enPassant = current.enPassant;
fullmoveCounter = current.fullmoveCounter;
fullmoveNumber = current.fullmoveCounter;
halfmoveClock = current.halfmoveClock;
}
@ -178,9 +178,9 @@ public class Log implements Iterable<MoveNode> {
public void setActiveColor(Color activeColor) { this.activeColor = activeColor; }
public int getFullmoveCounter() { return fullmoveCounter; }
public int getFullmoveNumber() { return fullmoveNumber; }
public void setFullmoveCounter(int fullmoveCounter) { this.fullmoveCounter = fullmoveCounter; }
public void setFullmoveNumber(int fullmoveCounter) { this.fullmoveNumber = fullmoveCounter; }
public int getHalfmoveClock() { return halfmoveClock; }

View File

@ -30,7 +30,7 @@ class LogTest {
assertNull(log.getRoot());
assertEquals(log.getActiveColor(), Color.WHITE);
assertNull(log.getEnPassant());
assertEquals(log.getFullmoveCounter(), 1);
assertEquals(log.getFullmoveNumber(), 1);
assertEquals(log.getHalfmoveClock(), 0);
}
@ -132,7 +132,7 @@ class LogTest {
}
/**
* Test method for {@link dev.kske.chess.board.Log#getFullmoveCounter()}.
* Test method for {@link dev.kske.chess.board.Log#getFullmoveNumber()}.
*/
@Test
void testGetFullmoveCounter() {
@ -140,7 +140,7 @@ class LogTest {
}
/**
* Test method for {@link dev.kske.chess.board.Log#setFullmoveCounter(int)}.
* Test method for {@link dev.kske.chess.board.Log#setFullmoveNumber(int)}.
*/
@Test
void testSetFullmoveCounter() {