diff --git a/src/main/java/featurecat/lizzie/rules/Board.java b/src/main/java/featurecat/lizzie/rules/Board.java index 8d528fa36..b210eaac0 100644 --- a/src/main/java/featurecat/lizzie/rules/Board.java +++ b/src/main/java/featurecat/lizzie/rules/Board.java @@ -823,15 +823,10 @@ public void restoreMoveNumber() { /** Restore move number by node */ public void restoreMoveNumber(BoardHistoryNode node) { - Stone[] stones = history.getStones(); - for (int i = 0; i < stones.length; i++) { - Stone stone = stones[i]; - if (stone.isBlack() || stone.isWhite()) { - int y = i % Board.boardWidth; - int x = (i - y) / Board.boardHeight; - Lizzie.leelaz.playMove(stone, convertCoordinatesToName(x, y)); - } - } + Lizzie.leelaz.clear(); + boolean blackToPlay = node.getData().blackToPlay; + restoreInitialStones(blackToPlay); + restoreInitialStones(!blackToPlay); int moveNumber = node.getData().moveNumber; if (moveNumber > 0) { if (node.isMainTrunk()) { @@ -843,6 +838,18 @@ public void restoreMoveNumber(BoardHistoryNode node) { } } + private void restoreInitialStones(boolean isBlack) { + Stone[] stones = history.getStones(); + for (int i = 0; i < stones.length; i++) { + Stone stone = stones[i]; + if (isBlack ? stone.isBlack() : stone.isWhite()) { + int y = i % Board.boardWidth; + int x = (i - y) / Board.boardHeight; + Lizzie.leelaz.playMove(stone, convertCoordinatesToName(x, y)); + } + } + } + /** Go to move number by back routing from children when in branch */ public void goToMoveNumberByBackChildren(int moveNumber) { int delta = moveNumber - history.getMoveNumber();