Skip to content

Commit

Permalink
Fix featurecat#820 (playouts "1.5k" is wrongly read as 15000 in SGF)
Browse files Browse the repository at this point in the history
  • Loading branch information
hope366 committed Nov 28, 2020
1 parent ca8691b commit 17ce537
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/featurecat/lizzie/rules/SGFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ private static BoardHistoryList parseValue(
line1[1] =
line1[1].replaceAll(",", "."); // fix a decimal representation localization issue
Lizzie.board.getData().winrate = 100 - Double.parseDouble(line1[1]);
String playoutsStr = line1[2];
int kilo = 1000;
int playoutsUnit =
playoutsStr.endsWith("m") ? kilo * kilo : playoutsStr.endsWith("k") ? kilo : 1;
int numPlayouts =
Integer.parseInt(
line1[2]
.replaceAll("k", "000")
.replaceAll("m", "000000")
.replaceAll("[^0-9]", ""));
(int) (Double.parseDouble(playoutsStr.replaceAll("[^0-9.]", "")) * playoutsUnit);
Lizzie.board.getData().setPlayouts(numPlayouts);
if (numPlayouts > 0 && !line2.isEmpty()) {
Lizzie.board.getData().bestMoves = Lizzie.leelaz.parseInfo(line2);
Expand Down

0 comments on commit 17ce537

Please sign in to comment.