From dbb07143ad0523de17b99396fd19ac68a28bde43 Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Sat, 4 Jul 2020 23:05:07 +0900 Subject: [PATCH 1/2] Fix #727 (winrate graph for LCB) --- src/main/java/featurecat/lizzie/gui/WinrateGraph.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java index 62dd0de49..204ad7171 100644 --- a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java +++ b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java @@ -163,9 +163,7 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) { g.setStroke(previousStroke); } if (playouts > 0) { - if (wr < 0) { - wr = 100 - lastWr; - } else if (!node.getData().blackToPlay) { + if (!node.getData().blackToPlay) { wr = 100 - wr; } if (Lizzie.frame.isPlayingAgainstLeelaz From aceff214c10eb599a994be170186d9e065def9c1 Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Sat, 4 Jul 2020 23:05:07 +0900 Subject: [PATCH 2/2] Fix bad plots for winrates outside [0, 100] --- src/main/java/featurecat/lizzie/gui/LizzieFrame.java | 4 ++-- src/main/java/featurecat/lizzie/gui/WinrateGraph.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java index 840c34329..2dbf6a022 100644 --- a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java +++ b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java @@ -1020,8 +1020,8 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int if (validWinrate || validLastWinrate) { int maxBarwidth = (int) (width); - int barWidthB = (int) (blackWR * maxBarwidth / 100); - int barWidthW = (int) (whiteWR * maxBarwidth / 100); + int barWidthB = (int) (Math.max(0, Math.min(blackWR, 100)) * maxBarwidth / 100); + int barWidthW = (int) (Math.max(0, Math.min(whiteWR, 100)) * maxBarwidth / 100); int barPosY = posY + height / 3; int barPosxB = (int) (posX); int barPosxW = barPosxB + barWidthB; diff --git a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java index 204ad7171..4acc6ba99 100644 --- a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java +++ b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java @@ -339,7 +339,7 @@ private double convertWinrate(double winrate) { double r = 0.5 + handicap / (2 * maxHandicap); return Math.max(0, Math.min(r, 1)) * 100; } else { - return winrate; + return Math.max(0, Math.min(winrate, 100)); } }