{ "polyglotDir", ArgFilename, (void *) &appData.polyglotDir, TRUE, (ArgIniType) "" },
{ "usePolyglotBook", ArgBoolean, (void *) &appData.usePolyglotBook, TRUE, (ArgIniType) FALSE },
{ "polyglotBook", ArgFilename, (void *) &appData.polyglotBook, TRUE, (ArgIniType) "" },
+ { "bookDepth", ArgInt, (void *) &appData.bookDepth, TRUE, (ArgIniType) 12 },
+ { "bookVariation", ArgInt, (void *) &appData.bookStrength, TRUE, (ArgIniType) 50 },
{ "defaultHashSize", ArgInt, (void *) &appData.defaultHashSize, TRUE, (ArgIniType) 64 },
{ "defaultCacheSizeEGTB", ArgInt, (void *) &appData.defaultCacheSizeEGTB, TRUE, (ArgIniType) 4 },
{ "defaultPathEGTB", ArgFilename, (void *) &appData.defaultPathEGTB, TRUE, (ArgIniType) "c:\\egtb" },
#include <string.h>
#include <time.h>
#include <stdlib.h>
+#include <math.h>
#include "common.h"
#include "backend.h"
static char move_s[6];
int total_weight;
- if(book == NULL) return NULL;
+ if(book == NULL || moveNr >= 2*appData.bookDepth) return NULL;
// if(gameInfo.variant != VariantNormal) return NULL; // Zobrist scheme only works for normal Chess, so far
f=fopen(book,"rb");
if(!f){
if(count == MOVE_BUF) break;
entries[count++] = entry;
}
+ if(appData.bookStrength != 50) { // transform weights
+ double power, maxWeight = 0.0;
+ if(appData.bookStrength) power = (100.-appData.bookStrength)/appData.bookStrength;
+ for(i=0; i<count; i++) if(entries[i].weight > maxWeight) maxWeight = entries[i].weight;
+ for(i=0; i<count; i++){
+ double weight = entries[i].weight / maxWeight;
+ if(weight > 0)
+ entries[i].weight = appData.bookStrength || weight == 1.0 ? 1e4*exp(power * log(weight)) + 0.5 : 0.0;
+ }
+ }
total_weight = 0;
for(i=0; i<count; i++){
total_weight += entries[i].weight;
}
- j = (random() & 0x7FFF) * total_weight >> 15; // create random < total_weight
+ j = (random() & 0xFFF) * total_weight >> 12; // create random < total_weight
total_weight = 0;
for(i=0; i<count; i++){
total_weight += entries[i].weight;
char * polyglotDir;
Boolean usePolyglotBook;
char * polyglotBook;
+ int bookDepth;
+ int bookStrength;
int defaultHashSize;
int defaultCacheSizeEGTB;
char * defaultPathEGTB;
#define IDC_OwnBook1 1471\r
#define IDC_OwnBook2 1472\r
#define IDC_Cores 1473\r
+#define IDC_BookDep 1474\r
+#define IDC_BookStr 1475\r
#define DLG_NewVariant 1500\r
#define OPT_VariantGothic 1501\r
#define OPT_VariantCrazyhouse 1502\r
PUSHBUTTON "Cancel",IDCANCEL,154,185,50,14\r
END\r
\r
-DLG_OptionsUCI DIALOG DISCARDABLE 0, 0, 228, 124\r
+DLG_OptionsUCI DIALOG DISCARDABLE 0, 0, 228, 160\r
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\r
CAPTION "Common Engine Settings"\r
FONT 8, "MS Sans Serif"\r
WS_TABSTOP,2,94,100,10\r
CONTROL "Second has Own Book",IDC_OwnBook2,"Button",BS_AUTOCHECKBOX | \r
WS_TABSTOP,2,107,100,10\r
- DEFPUSHBUTTON "OK",IDOK,118,106,50,14\r
- PUSHBUTTON "Cancel",IDCANCEL,174,106,50,14\r
+ LTEXT "Book Depth:",IDC_STATIC,106,98,52,8\r
+ EDITTEXT IDC_BookDep,162,94,40,14,ES_AUTOHSCROLL\r
+ LTEXT "Book Variation:",IDC_STATIC,106,116,52,8\r
+ EDITTEXT IDC_BookStr,162,112,40,14,ES_AUTOHSCROLL\r
+ DEFPUSHBUTTON "OK",IDOK,118,142,50,14\r
+ PUSHBUTTON "Cancel",IDCANCEL,174,142,50,14\r
END\r
\r
DLG_Null DIALOG DISCARDABLE 0, 0, 186, 50\r
// [HGM] book: tick boxes for own book use\r
CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI );\r
CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI );\r
+ SetDlgItemInt( hDlg, IDC_BookDep, appData.bookDepth, TRUE );\r
+ SetDlgItemInt( hDlg, IDC_BookStr, appData.bookStrength, TRUE );\r
\r
SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );\r
\r
// [HGM] book: read tick boxes for own book use\r
appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 );\r
appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 );\r
+ appData.bookDepth = GetDlgItemInt(hDlg, IDC_BookDep, NULL, FALSE );\r
+ appData.bookStrength = GetDlgItemInt(hDlg, IDC_BookStr, NULL, FALSE );\r
\r
if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);\r
EndDialog(hDlg, TRUE);\r