DroidFish: Reinitialize tablebases when activity is started.

This commit is contained in:
Peter Osterlund 2012-01-21 08:51:01 +00:00
parent 1370b50ec7
commit 50ef527376
8 changed files with 17 additions and 21 deletions

View File

@ -105,7 +105,7 @@ public class ChessBoard extends View {
labelPaint = new Paint();
labelPaint.setAntiAlias(true);
decorationPaint = new Paint();
decorationPaint.setAntiAlias(true);

View File

@ -208,6 +208,7 @@ public class DroidFish extends Activity implements GUIInterface {
if (ctrl != null)
ctrl.shutdownEngine();
ctrl = new DroidChessController(this, gameTextListener, pgnOptions);
egtbForceReload = true;
readPrefs();
ctrl.newGame(gameMode);
{
@ -700,8 +701,12 @@ public class DroidFish extends Activity implements GUIInterface {
ctrl.setBookOptions(options);
}
private boolean egtbForceReload = false;
private final void setEgtbOptions() {
ctrl.setEgtbOptions(new EGTBOptions(egtbOptions));
Probe.getInstance().setPath(egtbOptions.gtbPath, egtbForceReload);
egtbForceReload = false;
}
private final void setEgtbHints(int sq) {

View File

@ -35,7 +35,6 @@ import org.petero.droidfish.gamelogic.TextIO;
import org.petero.droidfish.gamelogic.UndoInfo;
import org.petero.droidfish.gamelogic.SearchListener.PvInfo;
import org.petero.droidfish.gtb.Probe;
import org.petero.droidfish.gtb.Probe.ProbeResult;
import android.content.Context;
@ -49,7 +48,6 @@ public class DroidComputerPlayer {
private final SearchListener listener;
private final DroidBook book;
private EGTBOptions egtbOptions;
private final Probe gtbProbe;
/** Set when "ucinewgame" needs to be sent. */
private boolean newGame = false;
@ -245,7 +243,6 @@ public class DroidComputerPlayer {
this.listener = listener;
book = DroidBook.getInstance();
egtbOptions = new EGTBOptions();
gtbProbe = Probe.getInstance();
engineState = new EngineState();
searchRequest = null;
}
@ -272,10 +269,9 @@ public class DroidComputerPlayer {
public final void setBookOptions(BookOptions options) {
book.setOptions(options);
}
public final void setEgtbOptions(EGTBOptions options) {
egtbOptions = options;
gtbProbe.setPath(options.gtbPath);
}
/** Return all book moves, both as a formatted string and as a list of moves. */
@ -283,10 +279,6 @@ public class DroidComputerPlayer {
return book.getAllBookMoves(pos);
}
public final ProbeResult egtbProbe(Position pos) {
return gtbProbe.probeHard(pos);
}
/** Get engine reported name. */
public final synchronized String getEngineName() {
return engineName;
@ -339,9 +331,8 @@ public class DroidComputerPlayer {
/** Decide what moves to search. Filters out non-optimal moves if tablebases are used. */
private final ArrayList<Move> movesToSearch(SearchRequest sr) {
ArrayList<Move> moves = null;
if (egtbOptions.rootProbe) {
moves = gtbProbe.findOptimal(sr.currPos);
}
if (egtbOptions.rootProbe)
moves = Probe.getInstance().findOptimal(sr.currPos);
if (moves != null) {
sr.searchMoves = moves;
} else {

View File

@ -101,7 +101,7 @@ public class ExternalEngine extends UCIEngineBase {
}
});
exitThread.start();
// Start a thread to read stdin
stdInThread = new Thread(new Runnable() {
@Override

View File

@ -78,7 +78,7 @@ public abstract class UCIEngineBase implements UCIEngine {
public void clearOptions() {
allOptions.clear();
}
@Override
public void registerOption(String optName) {
allOptions.add(optName);

View File

@ -719,7 +719,7 @@ public class DroidChessController {
}
});
}
@Override
public void reportEngineError(final String errMsg) {
gui.runOnUIThread(new Runnable() {

View File

@ -29,8 +29,8 @@ class GtbProbe {
GtbProbe() {
}
final synchronized void setPath(String tbPath) {
if (!currTbPath.equals(tbPath)) {
final synchronized void setPath(String tbPath, boolean forceReload) {
if (forceReload || !currTbPath.equals(tbPath)) {
currTbPath = tbPath;
init(tbPath);
}

View File

@ -50,9 +50,9 @@ public class Probe {
whitePieces = new byte[65];
blackPieces = new byte[65];
}
public void setPath(String tbPath) {
gtb.setPath(tbPath);
public void setPath(String tbPath, boolean forceReload) {
gtb.setPath(tbPath, forceReload);
}
public static final class ProbeResult {