Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next: Support Switch Multiple Engine Heights #368

Merged
merged 2 commits into from
Oct 6, 2018

Conversation

zsalch
Copy link
Contributor

@zsalch zsalch commented Sep 18, 2018

Closes: #356

Support to switching multiple engine heights. (Currently only support Leela Zero Engine)

How to config:

  1. In the config.txt file, add a itme (engine-command-list) to add some new command lines:

    "engine-command": "./leelaz --gtp --lagbuffer 0 --weights %network-file --threads 2",
    "engine-command-list": [
      "./leelaz --gtp --lagbuffer 0 --weights leelaz_172_b1c --threads 2",
      "./leelaz --gtp --lagbuffer 0 --weights human_best --threads 2",
      "./leelaz --gtp --lagbuffer 0 --weights elf_1_62b --threads 2",
      "./leelaz --gtp --lagbuffer 0 --weights leelaz_157_d35 --threads 2"
    ],

  1. Use the shortcut key Ctrl+number to switch the weight and display the weight name in the left down, the engine command line will be displayed in the Title:

    Ctrl+0: Default switch to "engine-command"
    Ctrl+(1-9): Switch to "engine-command-list"

  1. If the current node is in Branch, it also supports keeping the current node when switching weights.

Demo:
image
image

return "";
}
int width = fm.stringWidth(line);
if (width > fitWidth) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space before >

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -80,4 +81,36 @@ public static void saveAsFile(URL url, File file) {
e.printStackTrace();
}
}

/**
* Fit the too long text by width
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fit doesn't sound like the correct word here. Maybe crop, cut or truncate?

/** Truncate text that is too long for the given width */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

src/main/java/featurecat/lizzie/analysis/Leelaz.java Outdated Show resolved Hide resolved
// substitute in the weights file
engineCommand = engineCommand.replaceAll("%network-file", config.getString("network-file"));

// Init current engine no and start engine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Init current engine number

I would also call the variable differently, currentEngineN or currentEngineNumber.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


public void startEngine(String engineCommand) throws IOException {
// Check engine command
if (engineCommand == null || "".equals(engineCommand.trim())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engineCommand.trim().isEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

}
}
// Go to move number by back routing when in branch
public boolean goToMoveNumberByBack(int moveNumber) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a separate method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the return value is never used, meaning the method can be refactored as follows:

int delta = moveNumber - history.getMoveNumber();
for (int i = 0; i < Math.abs(delta); i++) {
    BoardHistoryNode curNode = history.getCurrentHistoryNode();
    if (curNode.numberOfChildren() > 1 && delta > 0) {
        nextMove(curNode.getFromBackChildren());
    } else {
        if (!(delta > 0 ? nextMove() : previousMove())) {
            return;
        }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function goToMoveNumberByBack process the move by saved the children branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return value removed.

}
}
// Save the move number
public BoardHistoryNode saveMoveNumber() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned value is never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -433,6 +435,79 @@ public boolean nextMove() {
}
}

/**
* Goes to the next coordinate, thread safe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation doesn't explain the meaning of the returned boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

saveNode = curNode;
return curNode;
}
// Save the back routing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I would avoid comments that paraphrase method name: they don't add any information to what the code already says.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

node.previous().setFromBackChildren(node.previous().getNexts().indexOf(node));
saveBackRouting(node.previous());
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@zsalch
Copy link
Contributor Author

zsalch commented Oct 1, 2018

@OlivierBlanvillain
Thanks a lot for your detailed review, I will check and reply one by one.

@@ -80,4 +81,37 @@ public static void saveAsFile(URL url, File file) {
e.printStackTrace();
}
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@OlivierBlanvillain
Copy link
Contributor

Needs a rebased, LGTM otherwise!

@OlivierBlanvillain
Copy link
Contributor

I took care of the conflicts, let's get this in 🎉

@OlivierBlanvillain OlivierBlanvillain merged commit 10875ca into featurecat:next Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants