From aaf072500213db1bed274a2dd8ebe711f21ab898 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 9 Jun 2011 10:00:13 +0200 Subject: [PATCH] version 1.4.37b --- ChangeLog | 2 + README | 21 +++++++++++++------ book.c | 58 +++++++++++++++++++++++++++++++++++++++++++------------- book.h | 2 + config.h | 6 ++-- configure | 20 +++++++++--------- configure.ac | 2 +- io.c | 2 +- main.c | 2 +- option.c | 16 ++++++++------ polyglot.man | 16 ++++++++++---- polyglot.pod | 14 ++++++++++-- polyglot.spec | 2 +- xboard2uci.c | 10 +++++++- 14 files changed, 118 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bae4d0..3902c16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +=========1.4.37b================ +- Two new options: BookDepth and BookTreshold. BookDepth limits the number of moves the book is used and BookTreshold sets the minimum weight a book move should have. =========1.4.36b================ - Bugfix: option = 0/1 was translated incorrectly. - Default node count is 1. diff --git a/README b/README index b523a6d..ed905e6 100644 --- a/README +++ b/README @@ -375,9 +375,16 @@ CONFIG FILE FORMAT Select moves according to their weights in the book. If false the move with the highest weight is selected. - BookLearn (default: false) - Record learning information in the opening book. Naturally this - requires the opening book to be writable. + BookRandom (default: true) + Select moves according to their weights in the book. If false the + move with the highest weight is selected. + + BookDepth (default: 256) + Stop using the book after this number of moves. + + BookTreshold (default: 5) + Do not play moves with a weight (probability) lower than this (in + per mil). UseNice (default: false) Run the engine at nice level 5, or "NiceValue" if it set. On some @@ -401,9 +408,9 @@ CONFIG FILE FORMAT only when necessary. Their purpose is to try to hide problems with various software (not just engines). - IMPORTANT: Any of these work arounds might be removed in future - versions of PolyGlot. You are strongly recommended to contact the - author of faulty software and truly fix the problem. + IMPORTANT: Any of these work arounds might be removed in future ver- + sions of PolyGlot. You are strongly recommended to contact the author + of faulty software and truly fix the problem. PolyGlot supports the following work arounds: @@ -526,4 +533,4 @@ SEE ALSO - 2009-08-11 POLYGLOT(6) + 2009-08-13 POLYGLOT(6) diff --git a/book.c b/book.c index 5821451..950e2f9 100644 --- a/book.c +++ b/book.c @@ -121,24 +121,30 @@ int book_move(const board_t * board, bool random) { entry_t entry[1]; int move; int score; + list_t list[1]; + int i; if(BookFile==NULL) return MoveNone; ASSERT(board!=NULL); ASSERT(random==TRUE||random==FALSE); + // init + + list_clear(list); + + book_moves(list,board); best_move = MoveNone; best_score = 0; - for (pos = find_pos(board->key); pos < BookSize; pos++) { + for(i=0; ikey != board->key) break; - - move = entry->move; - score = entry->count; + move = list->move[i]; + score = list->value[i]; - if (move != MoveNone && move_is_legal(move,board)) { + if (move != MoveNone && + move_is_legal(move,board) && + score/10>option_get_int(Option,"BookTreshold")) { // pick this move? @@ -163,9 +169,9 @@ int book_move(const board_t * board, bool random) { return best_move; } -// book_disp() +// book_moves() -void book_disp(const board_t * board) { +void book_moves(list_t * list, const board_t * board) { int first_pos; int sum; @@ -176,8 +182,13 @@ void book_disp(const board_t * board) { char move_string[256]; ASSERT(board!=NULL); + ASSERT(list!=NULL); + + if(BookFile==NULL) return; - if(BookFile==NULL) return; + // init + + list_clear(list); first_pos = find_pos(board->key); @@ -201,15 +212,34 @@ void book_disp(const board_t * board) { if (entry->key != board->key) break; move = entry->move; - score = entry->count; + score = (entry->count*10000)/sum; // 32 bit safe! if (score > 0 && move != MoveNone && move_is_legal(move,board)) { - move_to_san(move,board,move_string,256); - printf(" %s (%.0f%%)\n",move_string,((double)score)/((double)sum)*100.0); + list_add_ex(list,move,score); } } - printf("\n"); +} + + +// book_disp() + +void book_disp(const board_t * board) { + + char move_string[256]; + list_t list[1]; + int i; + + ASSERT(board!=NULL); + + if(BookFile==NULL) return; + + book_moves(list,board); + + for(i=0; imove[i],board,move_string,256); + printf(" %6s %5.2f%%\n",move_string,list->value[i]/100.0); + } } // book_learn_move() diff --git a/book.h b/book.h index 0883fc3..9f3440a 100644 --- a/book.h +++ b/book.h @@ -8,6 +8,7 @@ #include "board.h" #include "util.h" +#include "list.h" // functions @@ -19,6 +20,7 @@ extern void book_close (); extern bool is_in_book (const board_t * board); extern int book_move (const board_t * board, bool random); +extern void book_moves (list_t * list, const board_t * board); extern void book_disp (const board_t * board); extern void book_learn_move (const board_t * board, int move, int result); diff --git a/config.h b/config.h index 5076fe9..dc4b29b 100644 --- a/config.h +++ b/config.h @@ -115,13 +115,13 @@ #define PACKAGE_NAME "polyglot" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "polyglot 1.4.36b" +#define PACKAGE_STRING "polyglot 1.4.37b" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "polyglot" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.4.36b" +#define PACKAGE_VERSION "1.4.37b" /* Define to 1 if the C compiler supports function prototypes. */ #define PROTOTYPES 1 @@ -150,7 +150,7 @@ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define VERSION "1.4.36b" +#define VERSION "1.4.37b" /* Define like PROTOTYPES; this can be used by system headers. */ #define __PROTOTYPES 1 diff --git a/configure b/configure index df485e1..d403a8d 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for polyglot 1.4.36b. +# Generated by GNU Autoconf 2.61 for polyglot 1.4.37b. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='polyglot' PACKAGE_TARNAME='polyglot' -PACKAGE_VERSION='1.4.36b' -PACKAGE_STRING='polyglot 1.4.36b' +PACKAGE_VERSION='1.4.37b' +PACKAGE_STRING='polyglot 1.4.37b' PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be' ac_unique_file="mainloop.c" @@ -1207,7 +1207,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures polyglot 1.4.36b to adapt to many kinds of systems. +\`configure' configures polyglot 1.4.37b to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1273,7 +1273,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of polyglot 1.4.36b:";; + short | recursive ) echo "Configuration of polyglot 1.4.37b:";; esac cat <<\_ACEOF @@ -1357,7 +1357,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -polyglot configure 1.4.36b +polyglot configure 1.4.37b generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1371,7 +1371,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by polyglot $as_me 1.4.36b, which was +It was created by polyglot $as_me 1.4.37b, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2061,7 +2061,7 @@ fi # Define the identity of the package. PACKAGE='polyglot' - VERSION='1.4.36b' + VERSION='1.4.37b' cat >>confdefs.h <<_ACEOF @@ -6848,7 +6848,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by polyglot $as_me 1.4.36b, which was +This file was extended by polyglot $as_me 1.4.37b, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6901,7 +6901,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -polyglot config.status 1.4.36b +polyglot config.status 1.4.37b configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index fa15e53..862bac4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([polyglot], [1.4.36b], [michel.vandenbergh@uhasselt.be]) +AC_INIT([polyglot], [1.4.37b], [michel.vandenbergh@uhasselt.be]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([mainloop.c]) AC_CONFIG_HEADER([config.h]) diff --git a/io.c b/io.c index 92d1518..478f731 100644 --- a/io.c +++ b/io.c @@ -71,7 +71,7 @@ void io_close(io_t * io) { ASSERT(io->out_fd>=0); - my_log("Adapter>%s: EOF\n",io->name); + my_log("Adapter->%s: EOF\n",io->name); if (close(io->out_fd) == -1) { my_fatal("io_close(): close(): %s\n",strerror(errno)); diff --git a/main.c b/main.c index e49f51d..efd6539 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,7 @@ // constants -static const char * const Version = "1.4.36b"; +static const char * const Version = "1.4.37b"; static const char * const HelpMessage = "\ SYNTAX\n\ * polyglot [configfile]\n\ diff --git a/option.c b/option.c index cb2b5a8..1bccec3 100644 --- a/option.c +++ b/option.c @@ -29,7 +29,7 @@ option_t DefaultOptions[] = { { "EngineDir", "string","0","0", "." , NULL,0,NNB, PG}, { "EngineCommand", "string","0","0", "" , NULL,0,NNB, PG}, - { "Log", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, + { "Log", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, { "LogFile", "string","0","0", "polyglot.log", NULL,0,NNB, PG|XBOARD|UCI}, { "UCI", "check","0","0", "false" , NULL,0,NNB, PG}, @@ -43,20 +43,22 @@ option_t DefaultOptions[] = { { "ResignMoves", "spin","0","10000", "3" , NULL,0,NNB, PG|XBOARD}, { "ResignScore", "spin","0","10000", "600" , NULL,0,NNB, PG|XBOARD}, - { "MateScore", "spin","0","1000000", "10000" , NULL,0,NNB, PG|XBOARD}, + { "MateScore", "spin","0","100000", "10000" , NULL,0,NNB, PG|XBOARD}, { "Book", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, { "BookFile", "string","0","0", "book.bin" , NULL,0,NNB, PG|XBOARD|UCI}, { "BookRandom", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD|UCI}, + { "BookDepth", "spin","0","256", "256" , NULL,0,NNB, PG|XBOARD}, + { "BookTreshold", "spin","0","1000", "5" , NULL,0,NNB, PG|XBOARD|UCI}, { "BookLearn", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { "KibitzMove", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { "KibitzPV", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { "KibitzCommand", "string","0","0", "tellall" , NULL,0,NNB, PG|XBOARD}, - { "KibitzDelay", "spin","0","10000", "5" , NULL,0,NNB, PG|XBOARD}, - { "KibitzInterval", "spin","0","10000", "0" , NULL,0,NNB, PG|XBOARD}, + { "KibitzDelay", "spin","0","1000", "5" , NULL,0,NNB, PG|XBOARD}, + { "KibitzInterval", "spin","0","1000", "0" , NULL,0,NNB, PG|XBOARD}, { "ShowPonder", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { "ScoreWhite", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, @@ -66,11 +68,11 @@ option_t DefaultOptions[] = { { "UCIVersion", "spin","1","2", "2" , NULL,0,NNB, PG|XBOARD}, { "CanPonder", "check","1","2", "false" , NULL,0,NNB, PG|XBOARD}, { "SyncStop", "check","1","2", "false" , NULL,0,NNB, PG|XBOARD}, - { "Affinity", "spin","-1","32", "-1" , NULL,0,NNB, PG}, - { "RepeatPV", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, + { "Affinity", "spin","-1","32", "-1" , NULL,0,NNB, PG}, + { "RepeatPV", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, { "PromoteWorkAround","check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, - { "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, + { "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, { "WbWorkArounds2", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { NULL, NULL,"0","0", NULL , NULL,0,NNB, 0}, diff --git a/polyglot.man b/polyglot.man index 58d1753..f08b13e 100644 --- a/polyglot.man +++ b/polyglot.man @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "POLYGLOT 6" -.TH POLYGLOT 6 "2009-08-11" "" "" +.TH POLYGLOT 6 "2009-08-13" "" "" .SH "NAME" PolyGlot \- Winboard protocol to UCI protocol adapter \- book engine for Polyglot books @@ -492,10 +492,16 @@ does not matter. .IX Item "BookRandom (default: true)" Select moves according to their weights in the book. If false the move with the highest weight is selected. -.IP "\fBBookLearn\fR (default: false)" 4 -.IX Item "BookLearn (default: false)" -Record learning information in the opening book. Naturally this requires -the opening book to be writable. +.IP "\fBBookRandom\fR (default: true)" 4 +.IX Item "BookRandom (default: true)" +Select moves according to their weights in the book. If false the move +with the highest weight is selected. +.IP "\fBBookDepth\fR (default: 256)" 4 +.IX Item "BookDepth (default: 256)" +Stop using the book after this number of moves. +.IP "\fBBookTreshold\fR (default: 5)" 4 +.IX Item "BookTreshold (default: 5)" +Do not play moves with a weight (probability) lower than this (in per mil). .IP "\fBUseNice\fR (default: false)" 4 .IX Item "UseNice (default: false)" Run the engine at nice level 5, or \*(L"NiceValue\*(R" if it set. On some diff --git a/polyglot.pod b/polyglot.pod index 45287d2..3ad6913 100644 --- a/polyglot.pod +++ b/polyglot.pod @@ -442,10 +442,18 @@ does not matter. Select moves according to their weights in the book. If false the move with the highest weight is selected. -=item B (default: false) +=item B (default: true) + +Select moves according to their weights in the book. If false the move +with the highest weight is selected. + +=item B (default: 256) + +Stop using the book after this number of moves. + +=item B (default: 5) -Record learning information in the opening book. Naturally this requires -the opening book to be writable. +Do not play moves with a weight (probability) lower than this (in per mil). =item B (default: false) diff --git a/polyglot.spec b/polyglot.spec index 2c9413d..c157bc7 100644 --- a/polyglot.spec +++ b/polyglot.spec @@ -1,6 +1,6 @@ Summary: A Winboard protocol to UCI protocol adapter Name: polyglot -Version: 1.4.36b +Version: 1.4.37b Release: 1 License: GPL Group: Amusement/Games diff --git a/xboard2uci.c b/xboard2uci.c index d026096..1a4103c 100644 --- a/xboard2uci.c +++ b/xboard2uci.c @@ -1197,11 +1197,17 @@ static void search_update() { if (State->state == THINK || State->state == PONDER || State->state == ANALYSE) { + // [VdB] moved up as we need the move number + + game_get_board(Game,Uci->board); + // opening book - if (State->state == THINK && option_get_bool(Option,"Book")) { + if (State->state == THINK && + option_get_bool(Option,"Book") && + Uci->board->move_nbboard); move = book_move(Uci->board,option_get_bool(Option,"BookRandom")); -- 1.7.0.4