Skip to content

Commit

Permalink
Fixed SGF read branch
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch committed Oct 25, 2018
1 parent 6a67d64 commit 4a84362
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void place(int x, int y, Stone color, boolean newBranch) {

// check to see if this coordinate is being replayed in history
BoardData next = history.getNext();
if (next != null && next.lastMove != null && next.lastMove[0] == x && next.lastMove[1] == y) {
if (next != null && next.lastMove != null && next.lastMove[0] == x && next.lastMove[1] == y && !newBranch) {
// this is the next coordinate in history. Just increment history so that we don't erase the
// redo's
history.next();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/featurecat/lizzie/rules/BoardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class BoardData {
public int whiteCaptures;

// Comment in the Sgf move
public String comment;
public String comment = "";

// Node properties
private final Map<String, String> properties = new HashMap<String, String>();
Expand Down Expand Up @@ -61,6 +61,9 @@ public BoardData(
*/
public void addProperty(String key, String value) {
SGFParser.addProperty(properties, key, value);
if ("N".equals(key) && comment.isEmpty()) {
comment = value;
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/featurecat/lizzie/rules/SGFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static boolean parse(String value) {
subTreeDepth += 1;
// Initialize the step count
subTreeStepMap.put(subTreeDepth, 0);
addPassForAwAb = true;
} else {
if (i > 0) {
// Allow the comment tag includes '('
Expand Down Expand Up @@ -197,6 +198,8 @@ private static boolean parse(String value) {
// add to node properties
Lizzie.board.addNodeProperty(tag, tagContent);
if (addPassForAwAb) {
// Save the step count
subTreeStepMap.put(subTreeDepth, subTreeStepMap.get(subTreeDepth) + 1);
Lizzie.board.pass(color);
addPassForAwAb = false;
}
Expand Down Expand Up @@ -233,6 +236,8 @@ private static boolean parse(String value) {
} else if ("AE".equals(tag)) {
// remove a stone
if (addPassForAwAb) {
// Save the step count
subTreeStepMap.put(subTreeDepth, subTreeStepMap.get(subTreeDepth) + 1);
Lizzie.board.pass(tag.equals("AB") ? Stone.BLACK : Stone.WHITE);
addPassForAwAb = false;
}
Expand Down

0 comments on commit 4a84362

Please sign in to comment.