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

Remove network downloading feature #387

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Just follow the instructions in the provided readme in the
[release](https://github.com/featurecat/lizzie/releases/tag/0.5).

The first run may take a while because Leela Zero needs to set up the
OpenCL tunings and download the latest network if it is not present. Just hang tight, and wait for it to finish, then you
OpenCL tunings. Just hang tight, and wait for it to finish, then you
will see Leela Zero's analysis displayed on the board. Feel free to supply
your own tunings, as this will speed up the process. Do this by copying
any `leelaz_opencl_tuning` file you have into the directory.
Expand All @@ -24,14 +24,15 @@ any `leelaz_opencl_tuning` file you have into the directory.

First, you will need to have a version of Leela Zero that
continually outputs pondering information. You can get this from one
of the Lizzie releases or build it yourself; just compile from the **next** branch of Leela Zero (see http://github.com/gcp/leela-zero/tree/next for more details).
of the Lizzie releases or build it yourself; just compile from the **next**
branch of Leela Zero (see http://github.com/gcp/leela-zero/tree/next for more
details).

git clone -b next http://github.com/gcp/leela-zero.git
$ git clone --recursive --branch next http://github.com/gcp/leela-zero.git

### Building Lizzie

The simplest way to build Lizzie is to use
[Maven](https://maven.apache.org/).
The simplest way to build Lizzie is to use [Maven](https://maven.apache.org/).

To build the code and package it:

Expand Down
1 change: 0 additions & 1 deletion src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ private JSONObject createDefaultConfig() {
leelaz.put("max-game-thinking-time-seconds", 2);
leelaz.put("print-comms", false);
leelaz.put("analyze-update-interval-centisec", 10);
leelaz.put("automatically-download-latest-network", false);

config.put("leelaz", leelaz);

Expand Down
110 changes: 0 additions & 110 deletions src/main/java/featurecat/lizzie/Util.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package featurecat.lizzie.analysis;

import featurecat.lizzie.Lizzie;
import featurecat.lizzie.Util;
import featurecat.lizzie.rules.Stone;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executors;
Expand All @@ -29,7 +27,6 @@ public class Leelaz {
ResourceBundle.getBundle("l10n.DisplayStrings");

private static final long MINUTE = 60 * 1000; // number of milliseconds in a minute
private static final String baseURL = "http://zero.sjeng.org";

private long maxAnalyzeTimeMillis; // , maxThinkingTimeMillis;
private int cmdNumber;
Expand Down Expand Up @@ -94,10 +91,6 @@ public Leelaz() throws IOException, JSONException {
printCommunication = config.getBoolean("print-comms");
maxAnalyzeTimeMillis = MINUTE * config.getInt("max-analyze-time-minutes");

if (config.getBoolean("automatically-download-latest-network")) {
updateToLatestNetwork();
}

// command string for starting the engine
engineCommand = config.getString("engine-command");
// substitute in the weights file
Expand Down Expand Up @@ -207,43 +200,6 @@ public void normalQuit() {
}
}

private void updateToLatestNetwork() {
try {
if (needToDownloadLatestNetwork()) {
int dialogResult =
JOptionPane.showConfirmDialog(
null,
resourceBundle.getString("LizzieFrame.display.download-latest-network-prompt"));
if (dialogResult == JOptionPane.YES_OPTION) {
Util.saveAsFile(
new URL(baseURL + "/networks/" + getBestNetworkHash() + ".gz"),
new File(Lizzie.config.leelazConfig.getString("network-file")));
}
}
} catch (IOException e) {
e.printStackTrace();
// now we're probably still ok. Maybe we're offline -- then it's not a big problem.
}
}

private String getBestNetworkHash() throws IOException {
return Util.downloadAsString(new URL(baseURL + "/best-network-hash")).split("\n")[0];
}

private boolean needToDownloadLatestNetwork() throws IOException {
File networkFile = new File(Lizzie.config.leelazConfig.getString("network-file"));
if (!networkFile.exists()) {
return true;
} else {
String currentNetworkHash = Util.getSha256Sum(networkFile);
if (currentNetworkHash == null) return true;

String bestNetworkHash = getBestNetworkHash();

return !currentNetworkHash.equals(bestNetworkHash);
}
}

/** Initializes the input and output streams */
private void initializeStreams() {
inputStream = new BufferedInputStream(process.getInputStream());
Expand Down
Loading