Skip to content

Commit

Permalink
Quick hack to support featurecat#785 (<nickname> before the engine co…
Browse files Browse the repository at this point in the history
…mmand)
  • Loading branch information
Hiraoka committed Oct 17, 2020
1 parent ebeb446 commit bf96dcc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class Leelaz {

// for Multiple Engine
private String engineCommand;
private String engineNickname;
private List<String> commands;
private JSONObject config;
private String currentWeightFile = "";
Expand Down Expand Up @@ -128,6 +129,14 @@ public Leelaz(String engineCommand) throws JSONException {
// substitute in the weights file
engineCommand = engineCommand.replaceAll("%network-file", config.getString("network-file"));
}
Matcher nicknameMatcher = Pattern.compile("<([^<]*)>\\s*(.*)").matcher(engineCommand);
if (nicknameMatcher.matches()) {
engineNickname = nicknameMatcher.group(1);
engineCommand = nicknameMatcher.group(2);
} else {
engineNickname = null;
}

this.engineCommand = engineCommand;
if (engineCommand.toLowerCase().contains("override-version")) {
this.isKataGo = true;
Expand Down Expand Up @@ -987,6 +996,10 @@ public boolean supportScoremean() {
return isKataGo || supportScoremean;
}

public String nicknameOrcurrentWeight() {
return (engineNickname == null) ? currentWeight : engineNickname;
}

public String currentWeight() {
return currentWeight;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/featurecat/lizzie/gui/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,9 @@ protected DocumentFilter getDocumentFilter() {
txts[i].setText(a.getString(i));
});
});
Arrays.asList(txts)
.stream()
.forEach(t -> t.setToolTipText("Engine Command or <Label> Engine Command"));

chkPreloads =
new JCheckBox[] {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/gui/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ public void updateEngineMenu(List<Leelaz> engineList) {
Leelaz engineDt = engineList.get(i);
if (engineDt != null) {
if (engineDt.currentWeight() != "")
engine[i].setText(engine[i].getText() + " : " + engineDt.currentWeight());
engine[i].setText(engine[i].getText() + " : " + engineDt.nicknameOrcurrentWeight());
engine[i].setVisible(true);
int a = i;
engine[i].addActionListener(
Expand Down

0 comments on commit bf96dcc

Please sign in to comment.