mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-18 03:32:18 +01:00
DroidFish: Added setting to control when ECO codes are displayed.
This commit is contained in:
@@ -179,6 +179,7 @@ public class DroidFish extends Activity
|
||||
private int numPV;
|
||||
private boolean mWhiteBasedScores;
|
||||
private boolean mShowBookHints;
|
||||
private int mEcoHints;
|
||||
private int maxNumArrows;
|
||||
private GameMode gameMode;
|
||||
private boolean mPonderMode;
|
||||
@@ -229,6 +230,10 @@ public class DroidFish extends Activity
|
||||
}
|
||||
private AutoMode autoMode = AutoMode.OFF;
|
||||
|
||||
private final int ECO_HINTS_OFF = 0;
|
||||
private final int ECO_HINTS_AUTO = 1;
|
||||
private final int ECO_HINTS_ALWAYS = 2;
|
||||
|
||||
/** State of requested permissions. */
|
||||
private static enum PermissionState {
|
||||
UNKNOWN,
|
||||
@@ -1161,6 +1166,7 @@ public class DroidFish extends Activity
|
||||
mWhiteBasedScores = settings.getBoolean("whiteBasedScores", false);
|
||||
maxNumArrows = getIntSetting("thinkingArrows", 4);
|
||||
mShowBookHints = settings.getBoolean("bookHints", false);
|
||||
mEcoHints = getIntSetting("ecoHints", ECO_HINTS_AUTO);
|
||||
|
||||
String engine = settings.getString("engine", "stockfish");
|
||||
int strength = settings.getInt("strength", 1000);
|
||||
@@ -1948,6 +1954,7 @@ public class DroidFish extends Activity
|
||||
private String thinkingStr2 = "";
|
||||
private String bookInfoStr = "";
|
||||
private String ecoInfoStr = "";
|
||||
private boolean ecoInTree = false;
|
||||
private String variantStr = "";
|
||||
private ArrayList<ArrayList<Move>> pvMoves = new ArrayList<ArrayList<Move>>();
|
||||
private ArrayList<Move> bookMoves = null;
|
||||
@@ -1959,6 +1966,7 @@ public class DroidFish extends Activity
|
||||
thinkingStr2 = ti.statStr;
|
||||
bookInfoStr = ti.bookInfo;
|
||||
ecoInfoStr = ti.eco;
|
||||
ecoInTree = ti.ecoInTree;
|
||||
pvMoves = ti.pvMoves;
|
||||
bookMoves = ti.bookMoves;
|
||||
updateThinkingInfo();
|
||||
@@ -1987,13 +1995,14 @@ public class DroidFish extends Activity
|
||||
}
|
||||
thinking.setText(s, TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
if (mShowBookHints && !ecoInfoStr.isEmpty()) {
|
||||
if ((mEcoHints == ECO_HINTS_ALWAYS || (mEcoHints == ECO_HINTS_AUTO && ecoInTree)) &&
|
||||
!ecoInfoStr.isEmpty()) {
|
||||
String s = thinkingEmpty ? "" : "<br>";
|
||||
s += ecoInfoStr;
|
||||
thinking.append(Html.fromHtml(s));
|
||||
thinkingEmpty = false;
|
||||
}
|
||||
if (mShowBookHints && !bookInfoStr.isEmpty()) {
|
||||
if (mShowBookHints && !bookInfoStr.isEmpty() && ctrl.humansTurn()) {
|
||||
String s = thinkingEmpty ? "" : "<br>";
|
||||
s += Util.boldStart + getString(R.string.book) + Util.boldStop + bookInfoStr;
|
||||
thinking.append(Html.fromHtml(s));
|
||||
|
||||
@@ -60,6 +60,7 @@ public interface GUIInterface {
|
||||
public ArrayList<ArrayList<Move>> pvMoves;
|
||||
public ArrayList<Move> bookMoves;
|
||||
public String eco;
|
||||
public boolean ecoInTree;
|
||||
}
|
||||
|
||||
/** Update the computer thinking information. */
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.WeakHashMap;
|
||||
import org.petero.droidfish.gamelogic.ChessParseError;
|
||||
import org.petero.droidfish.gamelogic.GameTree;
|
||||
import org.petero.droidfish.gamelogic.Move;
|
||||
import org.petero.droidfish.gamelogic.Pair;
|
||||
import org.petero.droidfish.gamelogic.Position;
|
||||
import org.petero.droidfish.gamelogic.TextIO;
|
||||
import org.petero.droidfish.gamelogic.UndoInfo;
|
||||
@@ -49,7 +50,7 @@ public class EcoDb {
|
||||
}
|
||||
|
||||
/** Get ECO classification for a given tree node. */
|
||||
public String getEco(GameTree gt, GameTree.Node node) {
|
||||
public Pair<String,Boolean> getEco(GameTree gt, GameTree.Node node) {
|
||||
ArrayList<GameTree.Node> gtNodePath = new ArrayList<GameTree.Node>();
|
||||
int nodeIdx = -1;
|
||||
boolean inEcoTree = true;
|
||||
@@ -94,9 +95,9 @@ public class EcoDb {
|
||||
if (nodeIdx != -1) {
|
||||
Node n = readNode(nodeIdx);
|
||||
if (n.nameIdx >= 0)
|
||||
return ecoNames[n.nameIdx];
|
||||
return new Pair<String, Boolean>(ecoNames[n.nameIdx], inEcoTree);
|
||||
}
|
||||
return "";
|
||||
return new Pair<String, Boolean>("", false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -684,6 +684,7 @@ public class DroidChessController {
|
||||
private String bookInfo = "";
|
||||
private ArrayList<Move> bookMoves = null;
|
||||
private String eco = ""; // ECO classification
|
||||
private boolean ecoInTree = false; // True if current position is inside the EcoDB tree
|
||||
|
||||
private Move ponderMove = null;
|
||||
private ArrayList<PvInfo> pvInfoV = new ArrayList<PvInfo>();
|
||||
@@ -697,6 +698,7 @@ public class DroidChessController {
|
||||
bookInfo = "";
|
||||
bookMoves = null;
|
||||
eco = "";
|
||||
ecoInTree = false;
|
||||
setSearchInfo(id);
|
||||
}
|
||||
|
||||
@@ -787,6 +789,7 @@ public class DroidChessController {
|
||||
ti.statStr = statStr;
|
||||
ti.bookInfo = bookInfo;
|
||||
ti.eco = eco;
|
||||
ti.ecoInTree = ecoInTree;
|
||||
ti.pvMoves = pvMoves;
|
||||
ti.bookMoves = bookMoves;
|
||||
latestThinkingInfo = ti;
|
||||
@@ -860,10 +863,11 @@ public class DroidChessController {
|
||||
|
||||
@Override
|
||||
public void notifyBookInfo(int id, String bookInfo, ArrayList<Move> moveList,
|
||||
String eco) {
|
||||
String eco, boolean ecoInTree) {
|
||||
this.bookInfo = bookInfo;
|
||||
bookMoves = moveList;
|
||||
this.eco = eco;
|
||||
this.ecoInTree = ecoInTree;
|
||||
setSearchInfo(id);
|
||||
}
|
||||
|
||||
@@ -925,10 +929,13 @@ public class DroidChessController {
|
||||
}
|
||||
|
||||
private final void updateBookHints() {
|
||||
if (humansTurn()) {
|
||||
if (game != null) {
|
||||
Pair<String, ArrayList<Move>> bi = computerPlayer.getBookHints(game.currPos(), localPt());
|
||||
String eco = EcoDb.getInstance(gui.getContext()).getEco(game.tree, game.tree.currentNode);
|
||||
listener.notifyBookInfo(searchId, bi.first, bi.second, eco);
|
||||
Pair<String, Boolean> ecoData =
|
||||
EcoDb.getInstance(gui.getContext()).getEco(game.tree, game.tree.currentNode);
|
||||
String eco = ecoData.first;
|
||||
boolean ecoInTree = ecoData.second;
|
||||
listener.notifyBookInfo(searchId, bi.first, bi.second, eco, ecoInTree);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -968,7 +975,11 @@ public class DroidChessController {
|
||||
computerPlayer.queueAnalyzeRequest(sr);
|
||||
} else if (computersTurn || ponder) {
|
||||
listener.clearSearchInfo(searchId);
|
||||
listener.notifyBookInfo(searchId, "", null, "");
|
||||
Pair<String, Boolean> ecoData =
|
||||
EcoDb.getInstance(gui.getContext()).getEco(game.tree, game.tree.currentNode);
|
||||
String eco = ecoData.first;
|
||||
boolean ecoInTree = ecoData.second;
|
||||
listener.notifyBookInfo(searchId, "", null, eco, ecoInTree);
|
||||
final Pair<Position, ArrayList<Move>> ph = game.getUCIHistory();
|
||||
Position currPos = new Position(game.currPos());
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
@@ -71,7 +71,8 @@ public interface SearchListener {
|
||||
public void notifyStats(int id, long nodes, int nps, long tbHits, int hash, int time);
|
||||
|
||||
/** Report opening book information. */
|
||||
public void notifyBookInfo(int id, String bookInfo, ArrayList<Move> moveList, String eco);
|
||||
public void notifyBookInfo(int id, String bookInfo, ArrayList<Move> moveList,
|
||||
String eco, boolean ecoInTree);
|
||||
|
||||
/** Report move (or command, such as "resign") played by the engine. */
|
||||
public void notifySearchResult(int id, String cmd, Move ponder);
|
||||
|
||||
Reference in New Issue
Block a user