From 1e6ba97f9a8dadd65aadc2945b899e38efad63f8 Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Tue, 9 Feb 2021 20:39:34 +0900 Subject: [PATCH 1/2] Fix #869 (movenum of the first move) --- src/main/java/featurecat/lizzie/rules/Board.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/featurecat/lizzie/rules/Board.java b/src/main/java/featurecat/lizzie/rules/Board.java index 763873573..aef49735f 100644 --- a/src/main/java/featurecat/lizzie/rules/Board.java +++ b/src/main/java/featurecat/lizzie/rules/Board.java @@ -517,9 +517,11 @@ public void place(int x, int y, Stone color, boolean newBranch, boolean changeMo Stone[] stones = history.getStones().clone(); Zobrist zobrist = history.getZobrist(); Optional lastMove = Optional.of(new int[] {x, y}); + boolean isNewSubBranch = newBranch && !history.getData().firstBranch; + boolean isMissingMoveMNNumber = history.getMoveMNNumber() < 0; int moveNumber = history.getMoveNumber() + 1; int moveMNNumber = - !newBranch || history.getData().firstBranch ? history.getMoveMNNumber() + 1 : 1; + isNewSubBranch ? 1 : isMissingMoveMNNumber ? -1 : history.getMoveMNNumber() + 1; int[] moveNumberList = newBranch && history.getNext(true).isPresent() ? new int[Board.boardWidth * Board.boardHeight] From d58e38e2bcc0af669e02e1299050623f2ad3528e Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Tue, 9 Feb 2021 20:39:34 +0900 Subject: [PATCH 2/2] Refactoring to avoid modification of SGFParser --- src/main/java/featurecat/lizzie/rules/Board.java | 3 ++- src/main/java/featurecat/lizzie/rules/BoardData.java | 1 - src/main/java/featurecat/lizzie/rules/SGFParser.java | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/featurecat/lizzie/rules/Board.java b/src/main/java/featurecat/lizzie/rules/Board.java index aef49735f..3b3622f4e 100644 --- a/src/main/java/featurecat/lizzie/rules/Board.java +++ b/src/main/java/featurecat/lizzie/rules/Board.java @@ -517,7 +517,8 @@ public void place(int x, int y, Stone color, boolean newBranch, boolean changeMo Stone[] stones = history.getStones().clone(); Zobrist zobrist = history.getZobrist(); Optional lastMove = Optional.of(new int[] {x, y}); - boolean isNewSubBranch = newBranch && !history.getData().firstBranch; + boolean isNewSubBranch = + newBranch && (history.getCurrentHistoryNode().numberOfChildren() > 0); boolean isMissingMoveMNNumber = history.getMoveMNNumber() < 0; int moveNumber = history.getMoveNumber() + 1; int moveMNNumber = diff --git a/src/main/java/featurecat/lizzie/rules/BoardData.java b/src/main/java/featurecat/lizzie/rules/BoardData.java index 906b9bdfc..ede816aa6 100644 --- a/src/main/java/featurecat/lizzie/rules/BoardData.java +++ b/src/main/java/featurecat/lizzie/rules/BoardData.java @@ -24,7 +24,6 @@ public class BoardData { public boolean verify; public double winrate; - public boolean firstBranch; private int playouts; public int engineIndex; public double komi; diff --git a/src/main/java/featurecat/lizzie/rules/SGFParser.java b/src/main/java/featurecat/lizzie/rules/SGFParser.java index 87f510ec5..3cc146e50 100644 --- a/src/main/java/featurecat/lizzie/rules/SGFParser.java +++ b/src/main/java/featurecat/lizzie/rules/SGFParser.java @@ -166,7 +166,6 @@ private static BoardHistoryList parseValue( String blackPlayer = "", whitePlayer = ""; - int previousDepth = -1; // Support unicode characters (UTF-8) for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); @@ -182,8 +181,6 @@ private static BoardHistoryList parseValue( if (!inTag) { subTreeDepth += 1; // Initialize the step count - Lizzie.board.getData().firstBranch = previousDepth < subTreeDepth; - previousDepth = subTreeDepth; subTreeStepMap.put(subTreeDepth, 0); addPassForMove = true; pendingProps = new HashMap();