Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues on komi and handicap in SGF reader #272

Merged
merged 3 commits into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ public void flatten() {
Stone[] stones = history.getStones();
boolean blackToPlay = history.isBlacksTurn();
Zobrist zobrist = history.getZobrist().clone();
BoardHistoryList oldHistory = history;
history = new BoardHistoryList(new BoardData(stones, null, Stone.EMPTY, blackToPlay, zobrist,
0, new int[BOARD_SIZE * BOARD_SIZE], 0, 0, 0.0, 0));
history.setGameInfo(oldHistory.getGameInfo());
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/featurecat/lizzie/rules/BoardHistoryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public GameInfo getGameInfo() {
return gameInfo;
}

public void setGameInfo(GameInfo gameInfo) {
this.gameInfo = gameInfo;
}

/**
* Clear history.
*/
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/featurecat/lizzie/rules/SGFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ private static boolean parse(String value) {
} else if (tag.equals("PW")) {
whitePlayer = tagContent;
} else if (tag.equals("KM")) {
Lizzie.board.getHistory().getGameInfo().setKomi(Double.parseDouble(tagContent));
try {
if (tagContent.trim().isEmpty()) {
tagContent = "0.0";
}
Lizzie.board.getHistory().getGameInfo().setKomi(Double.parseDouble(tagContent));
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
break;
case ';':
Expand Down