Skip to content

Commit

Permalink
Fix bad plots for winrates outside [0, 100]
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Jul 4, 2020
1 parent dbb0714 commit aceff21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/gui/WinrateGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit aceff21

Please sign in to comment.