mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-02-07 04:39:13 +01:00
DroidFish: Disabled the internal stockfish engine on Android 1.5, because it doesn't work there.
This commit is contained in:
parent
6c85f9e0c1
commit
441b6bc59a
|
@ -21,11 +21,11 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Class: org_petero_droidfish_engine_NativeUtil
|
||||
* Class: org_petero_droidfish_engine_EngineUtil
|
||||
* Method: getNPhysicalProcessors
|
||||
* Signature: ()I
|
||||
*/
|
||||
extern "C" JNIEXPORT jint JNICALL Java_org_petero_droidfish_engine_NativeUtil_getNPhysicalProcessors
|
||||
extern "C" JNIEXPORT jint JNICALL Java_org_petero_droidfish_engine_EngineUtil_getNPhysicalProcessors
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.petero.droidfish.activities.EditPGNSave;
|
|||
import org.petero.droidfish.activities.LoadScid;
|
||||
import org.petero.droidfish.activities.Preferences;
|
||||
import org.petero.droidfish.book.BookOptions;
|
||||
import org.petero.droidfish.engine.EngineUtil;
|
||||
import org.petero.droidfish.gamelogic.DroidChessController;
|
||||
import org.petero.droidfish.gamelogic.ChessParseError;
|
||||
import org.petero.droidfish.gamelogic.Move;
|
||||
|
@ -1251,19 +1252,25 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
case SELECT_ENGINE_DIALOG: {
|
||||
String[] fileNames = findFilesInDirectory(engineDir, null);
|
||||
final int numFiles = fileNames.length;
|
||||
final String[] items = new String[numFiles + 2];
|
||||
final String[] ids = new String[numFiles + 2];
|
||||
ids[0] = "stockfish"; items[0] = getString(R.string.stockfish_engine);
|
||||
ids[1] = "cuckoochess"; items[1] = getString(R.string.cuckoochess_engine);
|
||||
boolean haveSf = EngineUtil.internalStockFishName() != null;
|
||||
final int nEngines = numFiles + (haveSf ? 2 : 1);
|
||||
final String[] items = new String[nEngines];
|
||||
final String[] ids = new String[nEngines];
|
||||
int idx = 0;
|
||||
if (haveSf) {
|
||||
ids[idx] = "stockfish"; items[idx] = getString(R.string.stockfish_engine); idx++;
|
||||
}
|
||||
ids[idx] = "cuckoochess"; items[idx] = getString(R.string.cuckoochess_engine); idx++;
|
||||
String sep = File.separator;
|
||||
String base = Environment.getExternalStorageDirectory() + sep + engineDir + sep;
|
||||
for (int i = 0; i < numFiles; i++) {
|
||||
ids[i+2] = base + fileNames[i];
|
||||
items[i+2] = fileNames[i];
|
||||
ids[idx] = base + fileNames[i];
|
||||
items[idx] = fileNames[i];
|
||||
idx++;
|
||||
}
|
||||
String currEngine = ctrl.getEngine();
|
||||
int defaultItem = 0;
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
for (int i = 0; i < nEngines; i++) {
|
||||
if (ids[i].equals(currEngine)) {
|
||||
defaultItem = i;
|
||||
break;
|
||||
|
@ -1273,7 +1280,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
builder.setTitle(R.string.select_chess_engine);
|
||||
builder.setSingleChoiceItems(items, defaultItem, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
if ((item < 0) || (item >= ids.length))
|
||||
if ((item < 0) || (item >= nEngines))
|
||||
return;
|
||||
Editor editor = settings.edit();
|
||||
String engine = ids[item];
|
||||
|
|
|
@ -928,7 +928,7 @@ public class DroidComputerPlayer {
|
|||
nCPUsFromProc = nCPUs;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
int nCPUsFromOS = NativeUtil.getNPhysicalProcessors();
|
||||
int nCPUsFromOS = EngineUtil.getNPhysicalProcessors();
|
||||
return Math.max(nCPUsFromProc, nCPUsFromOS);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,26 @@
|
|||
|
||||
package org.petero.droidfish.engine;
|
||||
|
||||
public class NativeUtil {
|
||||
import android.os.Build;
|
||||
|
||||
public class EngineUtil {
|
||||
static {
|
||||
System.loadLibrary("nativeutil");
|
||||
}
|
||||
|
||||
/** Return number of physical processors, i.e. hyper-threading ignored. */
|
||||
final static native int getNPhysicalProcessors();
|
||||
|
||||
private static final class CpuAbi {
|
||||
static final String get() { return Build.CPU_ABI; }
|
||||
}
|
||||
|
||||
/** Return file name of the internal stockfish executable,
|
||||
* or null if the internal stockfish engine is not supported. */
|
||||
public static String internalStockFishName() {
|
||||
final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
|
||||
if (sdkVersion < 4)
|
||||
return null;
|
||||
return "stockfish-" + CpuAbi.get();
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ import java.security.MessageDigest;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
/** Stockfish engine running as process, started from assets resource. */
|
||||
public class InternalStockFish extends ExternalEngine {
|
||||
|
@ -51,10 +50,6 @@ public class InternalStockFish extends ExternalEngine {
|
|||
setOption("Skill Level", strength/50);
|
||||
}
|
||||
|
||||
private static final class CpuAbi {
|
||||
final String get() { return Build.CPU_ABI; }
|
||||
}
|
||||
|
||||
private final long readCheckSum(File f) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
@ -109,9 +104,7 @@ public class InternalStockFish extends ExternalEngine {
|
|||
|
||||
@Override
|
||||
protected void copyFile(File from, File to) throws IOException {
|
||||
final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
|
||||
final String abi = (sdkVersion < 4) ? "armeabi" : new CpuAbi().get();
|
||||
final String sfExe = "stockfish-" + abi;
|
||||
final String sfExe = EngineUtil.internalStockFishName();
|
||||
|
||||
// The checksum test is to avoid writing to /data unless necessary,
|
||||
// on the assumption that it will reduce memory wear.
|
||||
|
|
|
@ -29,6 +29,8 @@ public abstract class UCIEngineBase implements UCIEngine {
|
|||
private boolean processAlive;
|
||||
|
||||
public static UCIEngine getEngine(Context context, String engine, Report report) {
|
||||
if ("stockfish".equals(engine) && (EngineUtil.internalStockFishName() == null))
|
||||
engine = "cuckoochess";
|
||||
if ("cuckoochess".equals(engine))
|
||||
return new CuckooChessEngine(report);
|
||||
else if ("stockfish".equals(engine))
|
||||
|
|
Loading…
Reference in New Issue
Block a user