Skip to content

Commit

Permalink
Merge featurecat#787 (squashed): <nickname> before the engine command
Browse files Browse the repository at this point in the history
commit 8bf2209
Author: Hiraoka <[email protected]>
Date:   Mon Oct 19 21:32:00 2020 +0900

    fixup

commit 33cb711
Author: Hiraoka <[email protected]>
Date:   Sun Oct 18 00:05:28 2020 +0900

    fixup

commit bf96dcc
Author: Hiraoka <[email protected]>
Date:   Sat Oct 17 23:55:27 2020 +0900

    Quick hack to support featurecat#785 (<nickname> before the engine command)
  • Loading branch information
Hiraoka committed Oct 24, 2020
1 parent 36183e6 commit 3ae2d96
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
22 changes: 20 additions & 2 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,7 +129,8 @@ public Leelaz(String engineCommand) throws JSONException {
// substitute in the weights file
engineCommand = engineCommand.replaceAll("%network-file", config.getString("network-file"));
}
this.engineCommand = engineCommand;
updateEngineCommandAndNickname(engineCommand);
engineCommand = this.engineCommand;
if (engineCommand.toLowerCase().contains("override-version")) {
this.isKataGo = true;
}
Expand Down Expand Up @@ -949,7 +951,8 @@ public List<String> splitCommand(String commandLine) {
}

public boolean isCommandChange(String command) {
List<String> newList = splitCommand(command);
updateEngineCommandAndNickname(command);
List<String> newList = splitCommand(engineCommand);
if (this.commands.size() != newList.size()) {
engineIndex++;
return true;
Expand All @@ -967,6 +970,17 @@ public boolean isCommandChange(String command) {
}
}

private void updateEngineCommandAndNickname(String command) {
Matcher nicknameMatcher = Pattern.compile("<(.*?)>\\s*(.*)").matcher(command);
if (nicknameMatcher.matches()) {
engineNickname = nicknameMatcher.group(1);
engineCommand = nicknameMatcher.group(2);
} else {
engineNickname = null;
engineCommand = command;
}
}

public boolean isStarted() {
return started;
}
Expand All @@ -990,6 +1004,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 @@ -757,6 +757,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
4 changes: 2 additions & 2 deletions src/main/java/featurecat/lizzie/gui/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,8 @@ public void updateEngineMenu(List<Leelaz> engineList) {
engine[i].setVisible(false);
Leelaz engineDt = engineList.get(i);
if (engineDt != null) {
if (engineDt.currentWeight() != "")
engine[i].setText(engine[i].getText() + " : " + engineDt.currentWeight());
if (engineDt.nicknameOrCurrentWeight() != "")
engine[i].setText(engine[i].getText() + " : " + engineDt.nicknameOrCurrentWeight());
engine[i].setVisible(true);
int a = i;
engine[i].addActionListener(
Expand Down

0 comments on commit 3ae2d96

Please sign in to comment.