mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-01-30 17:13:50 +01:00
DroidFish: Show tablebase hits. Add support for SyzygyPath uci option.
This commit is contained in:
parent
837c49777a
commit
4fbb4b721c
|
@ -405,6 +405,8 @@ you are not actively using the program.\
|
|||
<string name="prefs_tbEngineProbe_summary">Enable tablebase probing in engine, when supported. Takes effect next time engine is started</string>
|
||||
<string name="prefs_gtbPath_title">GTB Directory</string>
|
||||
<string name="prefs_gtbPath_summary">Directory where Gaviota tablebases are installed. Leave blank to use default directory</string>
|
||||
<string name="prefs_rtbPath_title">Syzygy Directory</string>
|
||||
<string name="prefs_rtbPath_summary">Directory where Syzygy tablebases are installed. Leave blank to use default directory</string>
|
||||
<string name="buttonDesc_custom1">@string/prefs_custom_button_1</string>
|
||||
<string name="buttonDesc_custom2">@string/prefs_custom_button_2</string>
|
||||
<string name="buttonDesc_custom3">@string/prefs_custom_button_3</string>
|
||||
|
|
|
@ -687,6 +687,12 @@
|
|||
android:summary="@string/prefs_gtbPath_summary"
|
||||
android:defaultValue="">
|
||||
</EditTextPreference>
|
||||
</PreferenceScreen>
|
||||
<EditTextPreference
|
||||
android:key="rtbPath"
|
||||
android:title="@string/prefs_rtbPath_title"
|
||||
android:summary="@string/prefs_rtbPath_summary"
|
||||
android:defaultValue="">
|
||||
</EditTextPreference>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -208,6 +208,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
private final static String fenDir = "DroidFish/epd";
|
||||
private final static String engineDir = "DroidFish/uci";
|
||||
private final static String gtbDefaultDir = "DroidFish/gtb";
|
||||
private final static String rtbDefaultDir = "DroidFish/rtb";
|
||||
private BookOptions bookOptions = new BookOptions();
|
||||
private PGNOptions pgnOptions = new PGNOptions();
|
||||
private EngineOptions engineOptions = new EngineOptions();
|
||||
|
@ -476,6 +477,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
new File(extDir + sep + fenDir).mkdirs();
|
||||
new File(extDir + sep + engineDir).mkdirs();
|
||||
new File(extDir + sep + gtbDefaultDir).mkdirs();
|
||||
new File(extDir + sep + rtbDefaultDir).mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -960,6 +962,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
engineOptions.hintsEdit = settings.getBoolean("tbHintsEdit", false);
|
||||
engineOptions.rootProbe = settings.getBoolean("tbRootProbe", true);
|
||||
engineOptions.engineProbe = settings.getBoolean("tbEngineProbe", true);
|
||||
|
||||
String gtbPath = settings.getString("gtbPath", "").trim();
|
||||
if (gtbPath.length() == 0) {
|
||||
File extDir = Environment.getExternalStorageDirectory();
|
||||
|
@ -967,6 +970,14 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
gtbPath = extDir.getAbsolutePath() + sep + gtbDefaultDir;
|
||||
}
|
||||
engineOptions.gtbPath = gtbPath;
|
||||
String rtbPath = settings.getString("rtbPath", "").trim();
|
||||
if (rtbPath.length() == 0) {
|
||||
File extDir = Environment.getExternalStorageDirectory();
|
||||
String sep = File.separator;
|
||||
rtbPath = extDir.getAbsolutePath() + sep + rtbDefaultDir;
|
||||
}
|
||||
engineOptions.rtbPath = rtbPath;
|
||||
|
||||
setEngineOptions(false);
|
||||
setEgtbHints(cb.getSelectedSquare());
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ public final class EngineOptions {
|
|||
public boolean rootProbe; // Only search optimal moves at root
|
||||
public boolean engineProbe; // Let engine use EGTB
|
||||
public String gtbPath; // GTB directory path
|
||||
public String rtbPath; // Syzygy directory path
|
||||
public String networkID; // host+port network settings
|
||||
|
||||
public EngineOptions() {
|
||||
|
@ -35,6 +36,7 @@ public final class EngineOptions {
|
|||
rootProbe = false;
|
||||
engineProbe = false;
|
||||
gtbPath = "";
|
||||
rtbPath = "";
|
||||
networkID = "";
|
||||
}
|
||||
|
||||
|
@ -45,6 +47,7 @@ public final class EngineOptions {
|
|||
rootProbe = other.rootProbe;
|
||||
engineProbe = other.engineProbe;
|
||||
gtbPath = other.gtbPath;
|
||||
rtbPath = other.rtbPath;
|
||||
networkID = other.networkID;
|
||||
}
|
||||
|
||||
|
@ -60,6 +63,7 @@ public final class EngineOptions {
|
|||
(rootProbe == other.rootProbe) &&
|
||||
(engineProbe == other.engineProbe) &&
|
||||
gtbPath.equals(other.gtbPath) &&
|
||||
rtbPath.equals(other.rtbPath) &&
|
||||
networkID.equals(other.networkID));
|
||||
}
|
||||
|
||||
|
|
|
@ -859,6 +859,7 @@ public class DroidComputerPlayer {
|
|||
private boolean statLowerBound = false;
|
||||
private int statTime = 0;
|
||||
private long statNodes = 0;
|
||||
private long statTBHits = 0;
|
||||
private int statNps = 0;
|
||||
private int pvNum = 0;
|
||||
private ArrayList<String> statPV = new ArrayList<String>();
|
||||
|
@ -873,6 +874,11 @@ public class DroidComputerPlayer {
|
|||
private boolean statsModified = false;
|
||||
|
||||
private final void clearInfo() {
|
||||
statCurrDepth = statPVDepth = statScore = 0;
|
||||
statIsMate = statUpperBound = statLowerBound = false;
|
||||
statTime = 0;
|
||||
statNodes = statTBHits = 0;
|
||||
statNps = 0;
|
||||
depthModified = false;
|
||||
currMoveModified = false;
|
||||
pvModified = false;
|
||||
|
@ -913,6 +919,9 @@ public class DroidComputerPlayer {
|
|||
} else if (is.equals("nodes")) {
|
||||
statNodes = Long.parseLong(tokens[i++]);
|
||||
statsModified = true;
|
||||
} else if (is.equals("tbhits")) {
|
||||
statTBHits = Long.parseLong(tokens[i++]);
|
||||
statsModified = true;
|
||||
} else if (is.equals("nps")) {
|
||||
statNps = Integer.parseInt(tokens[i++]);
|
||||
statsModified = true;
|
||||
|
@ -945,15 +954,15 @@ public class DroidComputerPlayer {
|
|||
}
|
||||
if (havePvData) {
|
||||
while (statPvInfo.size() < pvNum)
|
||||
statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, false, false, false, new ArrayList<Move>()));
|
||||
statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, 0, false, false, false, new ArrayList<Move>()));
|
||||
while (statPvInfo.size() <= pvNum)
|
||||
statPvInfo.add(null);
|
||||
ArrayList<Move> moves = new ArrayList<Move>();
|
||||
int nMoves = statPV.size();
|
||||
for (i = 0; i < nMoves; i++)
|
||||
moves.add(TextIO.UCIstringToMove(statPV.get(i)));
|
||||
statPvInfo.set(pvNum, new PvInfo(statPVDepth, statScore, statTime, statNodes, statNps, statIsMate,
|
||||
statUpperBound, statLowerBound, moves));
|
||||
statPvInfo.set(pvNum, new PvInfo(statPVDepth, statScore, statTime, statNodes, statNps, statTBHits,
|
||||
statIsMate, statUpperBound, statLowerBound, moves));
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
// Ignore
|
||||
|
@ -997,7 +1006,7 @@ public class DroidComputerPlayer {
|
|||
pvModified = false;
|
||||
}
|
||||
if (statsModified) {
|
||||
listener.notifyStats(id, statNodes, statNps, statTime);
|
||||
listener.notifyStats(id, statNodes, statNps, statTBHits, statTime);
|
||||
statsModified = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ public class ExternalEngine extends UCIEngineBase {
|
|||
|
||||
private int hashMB = -1;
|
||||
private String gaviotaTbPath = "";
|
||||
private String syzygyPath = "";
|
||||
private boolean optionsInitialized = false;
|
||||
|
||||
/** @inheritDoc */
|
||||
|
@ -177,6 +178,8 @@ public class ExternalEngine extends UCIEngineBase {
|
|||
gaviotaTbPath = engineOptions.gtbPath;
|
||||
setOption("GaviotaTbPath", engineOptions.gtbPath);
|
||||
setOption("GaviotaTbCache", 8);
|
||||
syzygyPath = engineOptions.rtbPath;
|
||||
setOption("SyzygyPath", engineOptions.rtbPath);
|
||||
}
|
||||
optionsInitialized = true;
|
||||
}
|
||||
|
@ -202,6 +205,8 @@ public class ExternalEngine extends UCIEngineBase {
|
|||
return false;
|
||||
if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath))
|
||||
return false;
|
||||
if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.rtbPath))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,6 +196,7 @@ public class NetworkEngine extends UCIEngineBase {
|
|||
|
||||
private int hashMB = -1;
|
||||
private String gaviotaTbPath = "";
|
||||
private String syzygyPath = "";
|
||||
private boolean optionsInitialized = false;
|
||||
|
||||
/** @inheritDoc */
|
||||
|
@ -208,6 +209,8 @@ public class NetworkEngine extends UCIEngineBase {
|
|||
gaviotaTbPath = engineOptions.gtbPath;
|
||||
setOption("GaviotaTbPath", engineOptions.gtbPath);
|
||||
setOption("GaviotaTbCache", 8);
|
||||
syzygyPath = engineOptions.rtbPath;
|
||||
setOption("SyzygyPath", engineOptions.rtbPath);
|
||||
}
|
||||
optionsInitialized = true;
|
||||
}
|
||||
|
@ -225,6 +228,8 @@ public class NetworkEngine extends UCIEngineBase {
|
|||
return false;
|
||||
if (hasOption("gaviotatbpath") && !gaviotaTbPath.equals(engineOptions.gtbPath))
|
||||
return false;
|
||||
if (hasOption("syzygypath") && !syzygyPath.equals(engineOptions.rtbPath))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -633,6 +633,7 @@ public class DroidChessController {
|
|||
private String currMoveStr = "";
|
||||
private long currNodes = 0;
|
||||
private int currNps = 0;
|
||||
private long currTBHits = 0;
|
||||
private int currTime = 0;
|
||||
|
||||
private boolean whiteMove = true;
|
||||
|
@ -695,6 +696,18 @@ public class DroidChessController {
|
|||
}
|
||||
statStrTmp = String.format(Locale.US, "d:%d %d:%s t:%.2f n:%d%s nps:%d%s", currDepth, currMoveNr, currMoveStr,
|
||||
currTime / 1000.0, nodes, nodesPrefix, nps, npsPrefix);
|
||||
if (currTBHits > 0) {
|
||||
long tbHits = currTBHits;
|
||||
String tbHitsPrefix = "";
|
||||
if (tbHits > 100000000) {
|
||||
tbHits /= 1000000;
|
||||
tbHitsPrefix = "M";
|
||||
} else if (tbHits > 100000) {
|
||||
tbHits /= 1000;
|
||||
tbHitsPrefix = "k";
|
||||
}
|
||||
statStrTmp += String.format(Locale.US, " tb:%d%s", tbHits, tbHitsPrefix);
|
||||
}
|
||||
}
|
||||
final String statStr = statStrTmp;
|
||||
final String newPV = buf.toString();
|
||||
|
@ -742,6 +755,7 @@ public class DroidChessController {
|
|||
currTime = pv.time;
|
||||
currNodes = pv.nodes;
|
||||
currNps = pv.nps;
|
||||
currTBHits = pv.tbHits;
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Position tmpPos = new Position(pos);
|
||||
|
@ -768,9 +782,10 @@ public class DroidChessController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void notifyStats(int id, long nodes, int nps, int time) {
|
||||
public void notifyStats(int id, long nodes, int nps, long tbHits, int time) {
|
||||
currNodes = nodes;
|
||||
currNps = nps;
|
||||
currTBHits = tbHits;
|
||||
currTime = time;
|
||||
setSearchInfo(id);
|
||||
}
|
||||
|
|
|
@ -31,19 +31,21 @@ public interface SearchListener {
|
|||
int time;
|
||||
long nodes;
|
||||
int nps;
|
||||
long tbHits;
|
||||
boolean isMate;
|
||||
boolean upperBound;
|
||||
boolean lowerBound;
|
||||
ArrayList<Move> pv;
|
||||
String pvStr = "";
|
||||
|
||||
public PvInfo(int depth, int score, int time, long nodes, int nps,
|
||||
public PvInfo(int depth, int score, int time, long nodes, int nps, long tbHits,
|
||||
boolean isMate, boolean upperBound, boolean lowerBound, ArrayList<Move> pv) {
|
||||
this.depth = depth;
|
||||
this.score = score;
|
||||
this.time = time;
|
||||
this.nodes = nodes;
|
||||
this.nps = nps;
|
||||
this.tbHits = tbHits;
|
||||
this.isMate = isMate;
|
||||
this.upperBound = upperBound;
|
||||
this.lowerBound = lowerBound;
|
||||
|
@ -64,7 +66,7 @@ public interface SearchListener {
|
|||
public void notifyPV(int id, Position pos, ArrayList<PvInfo> pvInfo, Move ponderMove);
|
||||
|
||||
/** Report search statistics. */
|
||||
public void notifyStats(int id, long nodes, int nps, int time);
|
||||
public void notifyStats(int id, long nodes, int nps, long tbHits, int time);
|
||||
|
||||
/** Report opening book information. */
|
||||
public void notifyBookInfo(int id, String bookInfo, ArrayList<Move> moveList);
|
||||
|
|
Loading…
Reference in New Issue
Block a user