Skip to content

Commit

Permalink
Show score in winrate graph even when pondering is off (ref. featurec…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Nov 8, 2020
1 parent acdb8a8 commit 277a790
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
double curWR = stats.maxWinrate; // winrate on this move
boolean validWinrate = (stats.totalPlayouts > 0); // and whether it was actually calculated
boolean validScore = validWinrate;
if (!validWinrate) {
curWR = Lizzie.board.getHistory().getData().winrate;
validWinrate = Lizzie.board.getHistory().getData().getPlayouts() > 0;
Expand Down Expand Up @@ -965,8 +964,11 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
setPanelFont(g, (int) (min(width, height) * 0.2));

String text = "";
MoveData bestMove = Utils.getBestMove();
boolean validScore = (bestMove != null);
if (Lizzie.leelaz.isKataGo && validScore) {
double score = Lizzie.leelaz.scoreMean;
double score = bestMove.scoreMean;
double stdev = bestMove.scoreStdev;
if (Lizzie.board.getHistory().isBlacksTurn()) {
if (Lizzie.config.showKataGoBoardScoreMean) {
score = score + Lizzie.board.getHistory().getGameInfo().getKomi();
Expand All @@ -988,7 +990,7 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
text
+ resourceBundle.getString("LizzieFrame.katago.scoreStdev")
+ ": "
+ String.format("%.1f", Lizzie.leelaz.scoreStdev)
+ String.format("%.1f", stdev)
+ " ";
}
// Last move
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/featurecat/lizzie/gui/WinratePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import featurecat.lizzie.Lizzie;
import featurecat.lizzie.analysis.Leelaz;
import featurecat.lizzie.analysis.MoveData;
import featurecat.lizzie.rules.BoardData;
import featurecat.lizzie.util.Utils;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
Expand Down Expand Up @@ -135,7 +137,6 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
curWR = Lizzie.board.getHistory().getData().winrate;
validWinrate = Lizzie.board.getHistory().getData().getPlayouts() > 0;
}
boolean validScore = validWinrate;
if (Lizzie.frame.isPlayingAgainstLeelaz
&& Lizzie.frame.playerIsBlack == !Lizzie.board.getHistory().getData().blackToPlay) {
validWinrate = false;
Expand Down Expand Up @@ -185,8 +186,11 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
setPanelFont(g, (int) (min(width, height) * 0.2));

String text = "";
MoveData bestMove = Utils.getBestMove();
boolean validScore = (bestMove != null);
if (Lizzie.leelaz.isKataGo && validScore) {
double score = Lizzie.leelaz.scoreMean;
double score = bestMove.scoreMean;
double stdev = bestMove.scoreStdev;
if (Lizzie.board.getHistory().isBlacksTurn()) {
if (Lizzie.config.showKataGoBoardScoreMean) {
score = score + Lizzie.board.getHistory().getGameInfo().getKomi();
Expand All @@ -208,7 +212,7 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
text
+ LizzieMain.resourceBundle.getString("LizzieFrame.katago.scoreStdev")
+ ":"
+ String.format("%.1f", Lizzie.leelaz.scoreStdev)
+ String.format("%.1f", stdev)
+ " ";
}
// Last move
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/featurecat/lizzie/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import featurecat.lizzie.Lizzie;
import featurecat.lizzie.analysis.Leelaz;
import featurecat.lizzie.analysis.MoveData;
import featurecat.lizzie.gui.BoardRenderer;
import featurecat.lizzie.rules.BoardData;
import featurecat.lizzie.rules.BoardHistoryNode;
Expand Down Expand Up @@ -180,6 +181,11 @@ public static double actualScoreMean(double scoreMean) {
return score;
}

public static MoveData getBestMove() {
List<MoveData> bestMoves = Lizzie.board.getHistory().getData().bestMoves;
return (bestMoves.size() > 0) ? bestMoves.get(0) : null;
}

public static Integer txtFieldValue(JTextField txt) {
if (txt.getText().trim().isEmpty()
|| txt.getText().trim().length() >= String.valueOf(Integer.MAX_VALUE).length()) {
Expand Down

0 comments on commit 277a790

Please sign in to comment.