DroidFish: Made it possible to hide engine statistics.

This commit is contained in:
Peter Osterlund 2011-12-24 08:00:07 +00:00
parent 6b9d274008
commit bdb55f5677
4 changed files with 36 additions and 12 deletions
DroidFish

View File

@ -365,6 +365,8 @@ you are not actively using the program.\
<string name="add_analysis">Add Analysis</string>
<string name="fewer_variations">Fewer Variations</string>
<string name="more_variations">More Variations</string>
<string name="hide_statistics">Hide statistics</string>
<string name="show_statistics">Show statistics</string>
<string name="heavy_cpu_usage">Heavy CPU usage</string>
<string name="background_processing">Background processing</string>
<string name="lot_cpu_power">DroidFish is using a lot of CPU power</string>

View File

@ -132,6 +132,7 @@ public class DroidFish extends Activity implements GUIInterface {
private ChessBoard cb;
private static DroidChessController ctrl = null;
private boolean mShowThinking;
private boolean mShowStats;
private boolean mWhiteBasedScores;
private boolean mShowBookHints;
private int maxNumArrows;
@ -532,6 +533,7 @@ public class DroidFish extends Activity implements GUIInterface {
cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false);
mShowThinking = settings.getBoolean("showThinking", false);
mShowStats = settings.getBoolean("showStats", true);
mWhiteBasedScores = settings.getBoolean("whiteBasedScores", false);
maxNumArrows = getIntSetting("thinkingArrows", 2);
mShowBookHints = settings.getBoolean("bookHints", false);
@ -912,7 +914,8 @@ public class DroidFish extends Activity implements GUIInterface {
updateThinkingInfo();
}
private String thinkingStr = "";
private String thinkingStr1 = "";
private String thinkingStr2 = "";
private String bookInfoStr = "";
private String variantStr = "";
private ArrayList<ArrayList<Move>> pvMoves = new ArrayList<ArrayList<Move>>();
@ -920,9 +923,10 @@ public class DroidFish extends Activity implements GUIInterface {
private List<Move> variantMoves = null;
@Override
public void setThinkingInfo(String pvStr, String bookInfo,
public void setThinkingInfo(String pvStr, String statStr, String bookInfo,
ArrayList<ArrayList<Move>> pvMoves, List<Move> bookMoves) {
thinkingStr = pvStr;
thinkingStr1 = pvStr;
thinkingStr2 = statStr;
bookInfoStr = bookInfo;
this.pvMoves = pvMoves;
this.bookMoves = bookMoves;
@ -941,7 +945,9 @@ public class DroidFish extends Activity implements GUIInterface {
{
String s = "";
if (mShowThinking || gameMode.analysisMode()) {
s = thinkingStr;
s = thinkingStr1;
if (mShowStats)
s += "\n" + thinkingStr2;
}
thinking.setText(s, TextView.BufferType.SPANNABLE);
if (s.length() > 0) thinkingEmpty = false;
@ -1508,6 +1514,8 @@ public class DroidFish extends Activity implements GUIInterface {
final int ADD_ANALYSIS = 0;
final int MULTIPV_DEC = 1;
final int MULTIPV_INC = 2;
final int HIDE_STATISTICS = 3;
final int SHOW_STATISTICS = 4;
List<CharSequence> lst = new ArrayList<CharSequence>();
List<Integer> actions = new ArrayList<Integer>();
lst.add(getString(R.string.add_analysis)); actions.add(ADD_ANALYSIS);
@ -1520,6 +1528,11 @@ public class DroidFish extends Activity implements GUIInterface {
if (numPV < maxPV) {
lst.add(getString(R.string.more_variations)); actions.add(MULTIPV_INC);
}
if (mShowStats) {
lst.add(getString(R.string.hide_statistics)); actions.add(HIDE_STATISTICS);
} else {
lst.add(getString(R.string.show_statistics)); actions.add(SHOW_STATISTICS);
}
}
final List<Integer> finalActions = actions;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@ -1529,7 +1542,7 @@ public class DroidFish extends Activity implements GUIInterface {
switch (finalActions.get(item)) {
case ADD_ANALYSIS: {
ArrayList<ArrayList<Move>> pvMovesTmp = pvMoves;
String[] pvStrs = thinkingStr.split("\n");
String[] pvStrs = thinkingStr1.split("\n");
for (int i = 0; i < pvMovesTmp.size(); i++) {
ArrayList<Move> pv = pvMovesTmp.get(i);
StringBuilder preComment = new StringBuilder();
@ -1554,6 +1567,15 @@ public class DroidFish extends Activity implements GUIInterface {
case MULTIPV_INC:
ctrl.setMultiPVMode(numPV + 1);
break;
case HIDE_STATISTICS:
case SHOW_STATISTICS: {
mShowStats = finalActions.get(item) == SHOW_STATISTICS;
Editor editor = settings.edit();
editor.putBoolean("showStats", mShowStats);
editor.commit();
updateThinkingInfo();
break;
}
}
}
});

View File

@ -51,7 +51,8 @@ public interface GUIInterface {
public void moveListUpdated();
/** Update the computer thinking information. */
public void setThinkingInfo(String pvStr, String bookInfo, ArrayList<ArrayList<Move>> pvMoves, List<Move> bookMoves);
public void setThinkingInfo(String pvStr, String statStr, String bookInfo,
ArrayList<ArrayList<Move>> pvMoves, List<Move> bookMoves);
/** Ask what to promote a pawn to. Should call reportPromotePiece() when done. */
public void requestPromotePiece();

View File

@ -96,12 +96,11 @@ public class DroidChessController {
}
buf.append(pvi.pvStr);
buf.append("\n");
}
if (currDepth > 0) {
buf.append(String.format("d:%d %d:%s t:%.2f n:%d nps:%d", currDepth,
currMoveNr, currMove, currTime / 1000.0, currNodes, currNps));
}
final String statStr = (currDepth > 0) ?
String.format("d:%d %d:%s t:%.2f n:%d nps:%d", currDepth, currMoveNr, currMove,
currTime / 1000.0, currNodes, currNps)
: "";
final String newPV = buf.toString();
final String newBookInfo = bookInfo;
final SearchStatus localSS = ss;
@ -112,7 +111,7 @@ public class DroidChessController {
ArrayList<ArrayList<Move>> pvMoves = new ArrayList<ArrayList<Move>>();
for (int i = 0; i < pvInfoV.size(); i++)
pvMoves.add(pvInfoV.get(i).pv);
gui.setThinkingInfo(newPV, newBookInfo, pvMoves, bookMoves);
gui.setThinkingInfo(newPV, statStr, newBookInfo, pvMoves, bookMoves);
}
});
}