Skip to content

Commit

Permalink
Changing komi should cause Lizzie to regenerate analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch committed Nov 4, 2019
1 parent d2d2640 commit ad63248
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public EngineManager(Config config) throws JSONException, IOException {
*/
public void switchEngine(int index) {
if (index == this.currentEngineNo || index > this.engineList.size()) return;
Leelaz.engineIndex++;
Leelaz newEng = engineList.get(index);
if (newEng == null) return;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class Leelaz {
ArrayList<Double> estimateArray = new ArrayList<Double>();
public double scoreMean = 0;
public double scoreStdev = 0;
public static int engineIndex = 0;

/**
* Initializes the leelaz process and starts reading output
Expand Down Expand Up @@ -884,13 +885,15 @@ public List<String> splitCommand(String commandLine) {
public boolean isCommandChange(String command) {
List<String> newList = splitCommand(command);
if (this.commands.size() != newList.size()) {
engineIndex++;
return true;
} else {
for (int i = 0; i < this.commands.size(); i++) {
String param = this.commands.get(i);
String newParam = newList.get(i);
if ((!Utils.isBlank(param) || !Utils.isBlank(newParam))
&& (Utils.isBlank(param) || !param.equals(newParam))) {
engineIndex++;
return true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/featurecat/lizzie/gui/BoardRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import featurecat.lizzie.Lizzie;
import featurecat.lizzie.analysis.Branch;
import featurecat.lizzie.analysis.Leelaz;
import featurecat.lizzie.analysis.MoveData;
import featurecat.lizzie.rules.Board;
import featurecat.lizzie.rules.BoardData;
Expand Down Expand Up @@ -546,6 +547,8 @@ private void drawBranch() {
// calculate best moves and branch
bestMoves = Lizzie.leelaz.getBestMoves();
if (Lizzie.config.showBestMovesByHold
&& Leelaz.engineIndex == Lizzie.board.getData().engineIndex
&& Lizzie.board.getHistory().getGameInfo().getKomi() == Lizzie.board.getData().komi
&& MoveData.getPlayouts(bestMoves) < Lizzie.board.getData().getPlayouts()) {
bestMoves = Lizzie.board.getData().bestMoves;
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/featurecat/lizzie/rules/BoardData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package featurecat.lizzie.rules;

import featurecat.lizzie.Lizzie;
import featurecat.lizzie.analysis.Leelaz;
import featurecat.lizzie.analysis.MoveData;
import featurecat.lizzie.util.Utils;
import java.util.ArrayList;
Expand All @@ -24,6 +25,8 @@ public class BoardData {

public double winrate;
private int playouts;
public int engineIndex;
public double komi;
public double scoreMean;
public List<MoveData> bestMoves;
public int blackCaptures;
Expand Down Expand Up @@ -61,6 +64,8 @@ public BoardData(

this.winrate = winrate;
this.playouts = playouts;
this.engineIndex = Leelaz.engineIndex;
this.komi = 0.0;
this.scoreMean = scoreMean;
this.blackCaptures = blackCaptures;
this.whiteCaptures = whiteCaptures;
Expand Down Expand Up @@ -172,6 +177,8 @@ public double getWinrate() {
public void tryToClearBestMoves() {
bestMoves = new ArrayList<>();
playouts = 0;
engineIndex = Leelaz.engineIndex;
komi = Lizzie.board.getHistory().getGameInfo().getKomi();
if (Lizzie.leelaz.isKataGo) {
Lizzie.leelaz.scoreMean = 0;
Lizzie.leelaz.scoreStdev = 0;
Expand All @@ -186,6 +193,8 @@ public void tryToSetBestMoves(List<MoveData> moves) {
if (Lizzie.leelaz.isKataGo) {
scoreMean = getScoreMeanFromBestMoves(moves);
}
engineIndex = Leelaz.engineIndex;
komi = Lizzie.board.getHistory().getGameInfo().getKomi();
}
if (Lizzie.leelaz.isKataGo) {
Lizzie.leelaz.scoreMean = moves.get(0).scoreMean;
Expand Down

0 comments on commit ad63248

Please sign in to comment.