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 #732 etc. (dynamic-winrate-graph-width) #735

Merged
merged 3 commits into from
Sep 29, 2020
Merged
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
22 changes: 14 additions & 8 deletions src/main/java/featurecat/lizzie/gui/WinrateGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
if (Lizzie.config.dynamicWinrateGraphWidth && this.numMovesOfPlayed > 0) {
numMoves = this.numMovesOfPlayed;
}
if (Lizzie.config.dynamicWinrateGraphWidth
&& curMove.getData().moveNumber - 1 > this.numMovesOfPlayed) {
this.numMovesOfPlayed = curMove.getData().moveNumber - 1;
numMoves = this.numMovesOfPlayed;
}

while (node.previous().isPresent()) {
double wr = node.getData().winrate;
int playouts = node.getData().getPlayouts();
if (node == curMove) {
if (Lizzie.config.dynamicWinrateGraphWidth
&& node.getData().moveNumber - 1 > this.numMovesOfPlayed) {
this.numMovesOfPlayed = node.getData().moveNumber - 1;
numMoves = this.numMovesOfPlayed;
}
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
double bwr = stats.maxWinrate;
if (bwr >= 0 && stats.totalPlayouts > playouts) {
Expand All @@ -162,7 +162,7 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
g.drawString(moveNumString, mx, posy + height - margin);
g.setStroke(previousStroke);
}
if (playouts > 0) {
if (playouts > 0 && node.getData().moveNumber - 1 <= numMoves) {
if (wr < 0) {
wr = 100 - lastWr;
} else if (!node.getData().blackToPlay) {
Expand Down Expand Up @@ -256,13 +256,16 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
if (numMoves < 1) return;
lastOkMove = -1;
movenum = node.getData().moveNumber - 1;
if (Lizzie.config.dynamicWinrateGraphWidth && this.numMovesOfPlayed > 0) {
numMoves = this.numMovesOfPlayed;
}

if (Lizzie.leelaz.isKataGo) {
double lastScoreMean = -500;
int curMovenum = -1;
double curCurscoreMean = 0;
while (node.previous().isPresent()) {
if (!node.getData().bestMoves.isEmpty()) {
if (!node.getData().bestMoves.isEmpty() && node.getData().moveNumber - 1 <= numMoves) {

double curscoreMean = node.getData().bestMoves.get(0).scoreMean;
if (!node.getData().blackToPlay) {
Expand Down Expand Up @@ -355,9 +358,12 @@ public int moveNumber(int x, int y) {
int width = params[2];
int height = params[3];
int numMoves = params[4];
if (Lizzie.config.dynamicWinrateGraphWidth && this.numMovesOfPlayed > 0) {
numMoves = this.numMovesOfPlayed;
}
if (origPosx <= x && x < origPosx + origWidth && origPosy <= y && y < origPosy + origHeight) {
// x == posx + (movenum * width / numMoves) ==> movenum = ...
int movenum = Math.round((x - posx) * numMoves / (float) width);
int movenum = Math.round(numMoves * Math.min((x - posx) / (float) width, 1));
// movenum == moveNumber - 1 ==> moveNumber = ...
return movenum + 1;
} else {
Expand Down