|
|
|
@ -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,14 +34,14 @@ 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
|
|
|
|
|
if (!other.isEmpty()) {
|
|
|
|
|
root = new MoveNode(other.current, copyVariations);
|
|
|
|
|
root = new MoveNode(other.current, copyVariations);
|
|
|
|
|
root.setParent(null);
|
|
|
|
|
current = root;
|
|
|
|
|
current = root;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -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; }
|
|
|
|
|
|
|
|
|
|