From 696c6411ec7b848af5b537c8c70d70bb36152553 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sun, 13 Jul 2014 09:42:03 +0000 Subject: [PATCH] DroidFish: Automatically restart engine when tablebase engine probing is changed. --- DroidFish/res/values/strings.xml | 2 +- .../org/petero/droidfish/EngineOptions.java | 22 +++++++++++++++---- .../droidfish/engine/ExternalEngine.java | 16 ++++++-------- .../droidfish/engine/NetworkEngine.java | 16 ++++++-------- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index a95f955..03a9b6f 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -400,7 +400,7 @@ you are not actively using the program.\ Probe at Root Filter out non-optimal moves before starting search Engine Probing - Enable tablebase probing in engine, when supported. Takes effect next time engine is started + Enable tablebase probing in engine, when supported GTB Directory Directory where Gaviota tablebases are installed. Leave blank to use default directory GTB Network Directory diff --git a/DroidFish/src/org/petero/droidfish/EngineOptions.java b/DroidFish/src/org/petero/droidfish/EngineOptions.java index 73a0588..aa8eeb1 100644 --- a/DroidFish/src/org/petero/droidfish/EngineOptions.java +++ b/DroidFish/src/org/petero/droidfish/EngineOptions.java @@ -25,10 +25,10 @@ public final class EngineOptions { public boolean hintsEdit; // Hints in "edit board" mode public boolean rootProbe; // Only search optimal moves at root public boolean engineProbe; // Let engine use EGTB - public String gtbPath; // GTB directory path - public String gtbPathNet; // GTB directory path for network engines - public String rtbPath; // Syzygy directory path - public String rtbPathNet; // Syzygy directory path for network engines + String gtbPath; // GTB directory path + String gtbPathNet; // GTB directory path for network engines + String rtbPath; // Syzygy directory path + String rtbPathNet; // Syzygy directory path for network engines public String networkID; // host+port network settings public EngineOptions() { @@ -57,6 +57,20 @@ public final class EngineOptions { networkID = other.networkID; } + /** Get the GTB path for an engine. */ + public String getEngineGtbPath(boolean networkEngine) { + if (!engineProbe) + return ""; + return networkEngine ? gtbPathNet : gtbPath; + } + + /** Get the RTB path for an engine. */ + public String getEngineRtbPath(boolean networkEngine) { + if (!engineProbe) + return ""; + return networkEngine ? rtbPathNet : rtbPath; + } + @Override public boolean equals(Object o) { if ((o == null) || (o.getClass() != this.getClass())) diff --git a/DroidFish/src/org/petero/droidfish/engine/ExternalEngine.java b/DroidFish/src/org/petero/droidfish/engine/ExternalEngine.java index 7df55ee..a1e693a 100644 --- a/DroidFish/src/org/petero/droidfish/engine/ExternalEngine.java +++ b/DroidFish/src/org/petero/droidfish/engine/ExternalEngine.java @@ -174,13 +174,11 @@ public class ExternalEngine extends UCIEngineBase { super.initOptions(engineOptions); hashMB = getHashMB(engineOptions.hashMB); setOption("Hash", hashMB); - if (engineOptions.engineProbe) { - gaviotaTbPath = engineOptions.gtbPath; - setOption("GaviotaTbPath", engineOptions.gtbPath); - setOption("GaviotaTbCache", 8); - syzygyPath = engineOptions.rtbPath; - setOption("SyzygyPath", engineOptions.rtbPath); - } + gaviotaTbPath = engineOptions.getEngineGtbPath(false); + setOption("GaviotaTbPath", gaviotaTbPath); + setOption("GaviotaTbCache", 8); + syzygyPath = engineOptions.getEngineRtbPath(false); + setOption("SyzygyPath", syzygyPath); optionsInitialized = true; } @@ -203,9 +201,9 @@ public class ExternalEngine extends UCIEngineBase { return true; if (hashMB != getHashMB(engineOptions.hashMB)) return false; - if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath)) + if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.getEngineGtbPath(false))) return false; - if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.rtbPath)) + if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.getEngineRtbPath(false))) return false; return true; } diff --git a/DroidFish/src/org/petero/droidfish/engine/NetworkEngine.java b/DroidFish/src/org/petero/droidfish/engine/NetworkEngine.java index d9dbb14..1919d2f 100644 --- a/DroidFish/src/org/petero/droidfish/engine/NetworkEngine.java +++ b/DroidFish/src/org/petero/droidfish/engine/NetworkEngine.java @@ -205,13 +205,11 @@ public class NetworkEngine extends UCIEngineBase { super.initOptions(engineOptions); hashMB = engineOptions.hashMB; setOption("Hash", engineOptions.hashMB); - if (engineOptions.engineProbe) { - gaviotaTbPath = engineOptions.gtbPathNet; - setOption("GaviotaTbPath", engineOptions.gtbPathNet); - setOption("GaviotaTbCache", 8); - syzygyPath = engineOptions.rtbPathNet; - setOption("SyzygyPath", engineOptions.rtbPathNet); - } + gaviotaTbPath = engineOptions.getEngineGtbPath(true); + setOption("GaviotaTbPath", gaviotaTbPath); + setOption("GaviotaTbCache", 8); + syzygyPath = engineOptions.getEngineRtbPath(true); + setOption("SyzygyPath", syzygyPath); optionsInitialized = true; } @@ -226,9 +224,9 @@ public class NetworkEngine extends UCIEngineBase { return false; if (hashMB != engineOptions.hashMB) return false; - if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPathNet)) + if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.getEngineGtbPath(true))) return false; - if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.rtbPathNet)) + if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.getEngineRtbPath(true))) return false; return true; }