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