From: H.G. Muller Date: Sat, 7 Aug 2010 14:26:35 +0000 (+0200) Subject: Add some book-control options X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=1e854f2b4c4aa7ed89e5bf7211487c795812899f;hp=0a237bf38324d1ec35191e06ce52a2415344a805;p=xboard.git Add some book-control options Options /bookDepth and /bookVariation have been added to control the use of the GUI book. In WinBoard the Optons -> Common Engine dialog now contains fields to set them. --- diff --git a/args.h b/args.h index 04f2c23..11b630d 100644 --- a/args.h +++ b/args.h @@ -540,6 +540,8 @@ ArgDescriptor argDescriptors[] = { { "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" }, diff --git a/book.c b/book.c index b574073..2c1a06a 100644 --- a/book.c +++ b/book.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "common.h" #include "backend.h" @@ -466,7 +467,7 @@ char *ProbeBook(int moveNr, char *book) 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){ @@ -497,11 +498,21 @@ char *ProbeBook(int moveNr, char *book) 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 maxWeight) maxWeight = entries[i].weight; + for(i=0; i 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> 15; // create random < total_weight + j = (random() & 0xFFF) * total_weight >> 12; // create random < total_weight total_weight = 0; for(i=0; i