Skip to content

Commit

Permalink
Print dynamic komi if present
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba97531 committed Jul 20, 2018
1 parent 814cfd3 commit 20611db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class Leelaz {
private boolean isLoaded = false;
private boolean isCheckingVersion;

// dynamic komi and opponent komi as reported by dynamic-komi version of leelaz
private float dynamicKomi = Float.NaN, dynamicOppKomi = Float.NaN;
/**
* Initializes the leelaz process and starts reading output
*
Expand Down Expand Up @@ -180,7 +182,25 @@ private void parseInfo(String line) {
*/
private void parseLine(String line) {
synchronized (this) {
if (line.equals("\n")) {
if (line.startsWith("komi="))
{
try {
dynamicKomi = Float.parseFloat(line.substring("komi=".length()).trim());
}
catch (NumberFormatException nfe) {
dynamicKomi = Float.NaN;
}
}
else if (line.startsWith("opp_komi="))
{
try {
dynamicOppKomi = Float.parseFloat(line.substring("opp_komi=".length()).trim());
}
catch (NumberFormatException nfe) {
dynamicOppKomi = Float.NaN;
}
}
else if (line.equals("\n")) {
// End of response
} else if (line.startsWith("info")) {
isLoaded = true;
Expand Down Expand Up @@ -425,6 +445,13 @@ public List<MoveData> getBestMoves() {
}
}

public String getDynamicKomi() {
if (Float.isNaN(dynamicKomi) || Float.isNaN(dynamicOppKomi)) {
return null;
}
return String.format("%.1f / %.1f", dynamicKomi, dynamicOppKomi);

This comment has been minimized.

Copy link
@featurecat

featurecat Jul 20, 2018

Owner

hmm I think you misunderstood me although I think the variable names are good. I wanted the output to be labeled haha. So that the user knows what 7.5 / 7.5 means. The variable labeling is good though :)

This comment has been minimized.

Copy link
@kuba97531

kuba97531 Jul 20, 2018

Author Contributor

43f5ddfdc4dcfa2702a850a66c4ce335
Would that be good?

This comment has been minimized.

Copy link
@featurecat

featurecat Jul 20, 2018

Owner

sure :) so long as resizing the window does not overlap small board with text

This comment has been minimized.

Copy link
@featurecat

featurecat Jul 20, 2018

Owner

also we should make this a Config option to display

This comment has been minimized.

Copy link
@kuba97531

kuba97531 Jul 20, 2018

Author Contributor

I will make it configurable. But I don't know how to hide it. The pondering string is already overlapping with the board.
test

This comment has been minimized.

Copy link
@kuba97531

kuba97531 Jul 20, 2018

Author Contributor

Oh, I read again without understanding. The text is shown under the small board.
test

This comment has been minimized.

Copy link
@kuba97531

kuba97531 Jul 20, 2018

Author Contributor

I will add the dynamic komi show/hide under D key.
I will change the drawControls method to only show this entry however only if I recognize that the leelaz is actually producing this value. Otherwise it will just confuse users.
Is that good?

This comment has been minimized.

Copy link
@featurecat

featurecat Jul 20, 2018

Owner

well, just make sure it's configurable via the file. some users will be annoyed if they must press D every time they start lizzie. I don't think we should bind it to a key. It should be in the Config. I think by default it can be on.

}

public boolean isPondering() {
return isPondering;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ public void paint(Graphics g0) {
int ponderingY = boardY + (int) (maxSize*0.93);
double ponderingSize = .02;

// dynamic komi
int dynamicKomiX = this.getInsets().left;
int dynamicKomiY = boardY + (int) (maxSize*0.86);
double dynamicKomiSize = .02;


// loading message
int loadingX = ponderingX;
int loadingY = ponderingY;
Expand Down Expand Up @@ -390,6 +396,10 @@ public void paint(Graphics g0) {
ponderingX, ponderingY, ponderingSize);
}

if (Lizzie.leelaz.getDynamicKomi() != null) {
drawPonderingState(g, Lizzie.leelaz.getDynamicKomi(), dynamicKomiX, dynamicKomiY, dynamicKomiSize);
}

// Todo: Make board move over when there is no space beside the board
if (Lizzie.config.showWinrate) {
drawWinrateGraphContainer(backgroundG, contx, conty, contw, conth);
Expand Down

0 comments on commit 20611db

Please sign in to comment.