OK, thanks. I tried to compile the probe library from source on Linux, using the included Makefile, but I got an error on memcpy. Some googling revealed that Volker Pittlik experienced the same problem in 2009, and that the solution was to add an #include "common.h" in cache.cpp. This worked, and provided me with an egbbso.so file. So beware that this still isn't fixed in the zip file I downloaded from your website!
Connecting to it from XBoard gives me some trouble, though. The probe code from Scorpio seems Windows-specific. After I added #defines to get rid of the error mesages for undeclared CDECL and HMODULE, it turns out that the routines LoadLibrary and GetProcAddress are unknown to the linker. Or is this because I need to give a special library flag to use .so files?
If this is really platform dependent, it would be a bad idea to put it in the back-end (where I have it now), and I'd better make separate versions of the load code in the respective front-ends.
Code: Select all
#define CDECL
#define HMODULE void *
#define EGBB_NAME "egbbso.so"
typedef int (CDECL *PPROBE_EGBB) (int player, int *piece, int *square);
typedef int (CDECL *PLOAD_EGBB) (char *path, int cache_size, int load_options);
static int egbbCode[] = { 6, 5, 4, 3, 2, 1 };
static int
BitbaseProbe ()
{
int pieces[10], squares[10], cnt=0, r, f, res;
static int loaded;
static PPROBE_EGBB probeBB;
if(!appData.testLegality) return 10;
if(BOARD_HEIGHT != 8 || BOARD_RGHT-BOARD_LEFT != 8) return 12;
if(loaded == 2 && forwardMostMove < 2) loaded = 0; // retry on new game
for(r=0; r<BOARD_HEIGHT; r++) for(f=BOARD_LEFT; f<BOARD_RGHT; f++) {
ChessSquare piece = boards[forwardMostMove][r][f];
int black = (piece >= BlackPawn);
int type = piece - black*BlackPawn;
if(piece == EmptySquare) continue;
if(type != WhiteKing && type > WhiteQueen) return 12; // unorthodox piece
if(type == WhiteKing) type = WhiteQueen + 1;
type = egbbCode[type];
squares[cnt] = r*(BOARD_RGHT - BOARD_LEFT) + f - BOARD_LEFT;
pieces[cnt] = piece + black*6;
if(++cnt > 5) return 11;
}
pieces[cnt] = squares[cnt] = 0;
// probe EGBB
if(loaded == 2) return 13; // loading failed before
if(loaded == 0) {
loaded = 2; // prepare for failure
char *p, *path = strstr(appData.egtFormats, "scorpio:"), buf[MSG_SIZ];
HMODULE lib;
PLOAD_EGBB loadBB;
if(!path) return 13; // no egbb installed
strncpy(buf, path + 8, MSG_SIZ);
if(p = strchr(buf, ',')) *p = NULLCHAR; else p = buf + strlen(buf);
snprintf(p, MSG_SIZ - strlen(buf), "%c%s", SLASH, EGBB_NAME);
lib = LoadLibrary(buf);
if(!lib) return 13;
loadBB = (PLOAD_EGBB) GetProcAddress(lib, "load_egbb_xmen");
probeBB = (PPROBE_EGBB) GetProcAddress(lib, "probe_egbb_xmen");
*p = NULLCHAR; loadBB(buf, 64*1028, 2); // 2 = SMART_LOAD
loaded = 1; // success!
}
res = probeBB(forwardMostMove & 1, pieces, squares);
return res > 0 ? 1 : res < 0 ? -1 : 0;
}