From c6505b9bddf0ed2f461a473d4be40c98608d9866 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 9 Jun 2011 10:08:21 +0200 Subject: [PATCH] version 1.4.50b --- ChangeLog | 5 + README | 185 +++++++++--------- config.guess | 32 +-- config.h | 6 +- config.sub | 44 +---- configure | 20 +- configure.ac | 2 +- debian/changelog | 54 +++++ debian/files | 2 +- main.c | 567 +++++++++++++++++++++++++++--------------------------- option.c | 73 ++++--- option.h | 1 + polyglot.man | 179 ++++++++---------- polyglot.pod | 63 ++---- polyglot.spec | 2 +- uci.c | 9 +- util.c | 4 + util.h | 7 +- 18 files changed, 624 insertions(+), 631 deletions(-) diff --git a/ChangeLog b/ChangeLog index 203101c..6495598 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +=========1.4.50b================ +- Change in architecture. Persistence is disabled. The user is required to push the "Save" button explicitly to save the settings. What is retained is that in case PG is invoked with -noini (or as a special exception for WB 4.4.0 when the config files are polyglot_1st.ini or polyglot_2nd.ini) then PG uses a default config file whose name is derived from the engine name. +- New option: OnlyWbOptions (default: true). Restrict the options that PG sends to those that are potentially useful for WinBoard. +=========1.4.47b================ +- Try to detect if the engine is not an UCI engine. =========1.4.46b================ - The default persistence directory on Windows is now _PG. The names of the engine specific ini files are mangled so as not to contain spaces. - PG now tries to guess if a string option is really a file or a path (like in the Arena GUI). diff --git a/README b/README index 499acf1..4358d8e 100644 --- a/README +++ b/README @@ -5,8 +5,8 @@ POLYGLOT(6) POLYGLOT(6) NAME PolyGlot - Winboard protocol to UCI protocol adapter - book engine for Polyglot books - - a collection of utilities for creating and analyzing - opening books + - a collection of utilities for creating and analyzing open- + ing books - a utility for analyzing epd files - a perft counter @@ -16,8 +16,8 @@ SYNOPSIS =]* [-uci =]* polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] - [-min-game games] [-min-score score] [-only-white] [-only-black] - [-uniform] + [-min-game games] [-min-score score] [-only-white] [-only-black] [-uni- + form] polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile] @@ -32,16 +32,17 @@ SYNOPSIS polyglot perft [-fen fen] [-max-depth depth] DESCRIPTION - PolyGlot as adapter and book engine + PolyGlot as adapter and book engine + PolyGlot is a "UCI adapter". It connects a GUI interface (such as XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. By specifying an opening book (in PolyGlot book format) chess engines can transparently use such books. - PolyGlot understands the two main GUI protocols: UCI and xboard. - Normally the protocol will be auto detected but this can be overridden - in the configuration file. + PolyGlot understands the two main GUI protocols: UCI and xboard. Nor- + mally the protocol will be auto detected but this can be overridden in + the configuration file. In xboard mode PolyGlot fully translates between the xboard and UCI protocols. In addition it tries to solve known problems with other @@ -52,9 +53,9 @@ DESCRIPTION engine and vice versa, except that it will play book moves on behalf of the engine when the occasion arises. - The engine options are exported as UCI options in UCI mode and as - "feature option=" commands in xboard mode. The latter form an extension - of the xboard protocol as defined by H.G. Muller. + The engine options are exported as UCI options in UCI mode and as "fea- + ture option=" commands in xboard mode. The latter form an extension of + the xboard protocol as defined by H.G. Muller. Options which normally appear in the [PolyGlot] section of the config file (see below) are exported as options with their name prefixed by @@ -63,10 +64,11 @@ DESCRIPTION NOTE: Not all options are exported, only those that make sense in the given mode. - Book making utilities + Book making utilities + PolyGlot supports the "PolyGlot opening book format". This is the - defacto standard non-proprietary opening book format. It is fully - documented here + defacto standard non-proprietary opening book format. It is fully docu- + mented here http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html @@ -79,13 +81,13 @@ DESCRIPTION .abk format are undocumented and proprietary. They can only be used by their own GUIs. - PolyGlot can compile a pgn file into a binary PolyGlot book and - furthermore it can merge two such binary books into a third one. + PolyGlot can compile a pgn file into a binary PolyGlot book and fur- + thermore it can merge two such binary books into a third one. PolyGlot can also extract some useful information from PolyGlot books. The utility "dump-book" dumps the "lines" in a book for a given color. - By definition a line is a sequence of moves (from the starting - position) in which the given color makes only book moves and the other + By definition a line is a sequence of moves (from the starting posi- + tion) in which the given color makes only book moves and the other color makes arbitrary moves (i.e. not necessarily book moves). Since a PolyGlot book is built up from positions and not lines there @@ -109,15 +111,17 @@ DESCRIPTION Due to the possibility of transpositions this is not a fool proof method. - Epd test mode + Epd test mode + In epd test mode, PolyGlot will search positions in an epd file and - record the number of times the right best move was found. The - arguments specify when to stop the search in any given position. + record the number of times the right best move was found. The argu- + ments specify when to stop the search in any given position. + + Perft counts - Perft counts A perft count is the number of legal move sequence in a given position - up to a given depth. PolyGlot can perform such perft counts. It is - however much slower than other more dedicated programs. + up to a given depth. PolyGlot can perform such perft counts. It is how- + ever much slower than other more dedicated programs. OPTIONS When PolyGlot is invoked as an adapter of in epd-test mode it gets its @@ -138,26 +142,25 @@ OPTIONS The argument is a string of the form =. This option will set the engine option to . - -ec This sets the EngineCommand. + -ec This is an alias for -pg "EngineCommand=" - -ed This sets the EngineDir. + -ed This is an alias for -pg "EngineDir=" - -en This sets the EngineName. + -en This is an alias for -pg "EngineName=" - -hash - This is an alias for -uci "Hash=". - - -log - This is an alias for -pg "Log=true". + -log (default: false) + This is an alias for -pg "Log=" -lf (default: "polyglot.log") This is an alias for -pg "LogFile=". - -bk This is an alias for -pg "Book=true" -pg "BookFile=". + -wb (default: "true") + This is an alias for -pg "OnlyWbOptions=". When invoked as - polyglot make-book + polyglot make-book + PolyGlot supports the following options -pgn (default: "book.pgn") @@ -190,7 +193,8 @@ OPTIONS When invoked as - polyglot merge-book + polyglot merge-book + PolyGlot supports the following options -in1 @@ -208,7 +212,8 @@ OPTIONS When invoked as - polyglot dump-book + polyglot dump-book + PolyGlot supports the following options -bin (default: book.bin) @@ -222,19 +227,21 @@ OPTIONS When invoked as - polyglot info-book + polyglot info-book + PolyGlot supports the following options -bin (default: book.bin) Input file in PolyGlot book format. -exact - Attempt to count the provably unreachable positions among the - isolated ones. Note that this takes a very long time. + Attempt to count the provably unreachable positions among the iso- + lated ones. Note that this takes a very long time. When invoked as - polyglot epd-test + polyglot epd-test + (possibly with a config file as first argument) PolyGlot supports besides the generic options described above the following additional options. @@ -260,7 +267,8 @@ OPTIONS When invoked as - polyglot perft + polyglot perft + PolyGlot supports the following options -fen (default: starting position) @@ -283,12 +291,13 @@ CONFIG FILE FORMAT The characters "#" and ";" serve as comment characters. - By default initial and final white space is stripped from option - values. If you want to avoid this, or if you want use one of the - comment characters # or ; in option values (such as for NalimovPath), - enclose the value in quotes. + By default initial and final white space is stripped from option val- + ues. If you want to avoid this, or if you want use one of the comment + characters # or ; in option values (such as for NalimovPath), enclose + the value in quotes. + + [PolyGlot] section - [PolyGlot] section This section is used by PolyGlot only. The engine is unaware of these options. The list of available options is detailed below. @@ -308,6 +317,14 @@ CONFIG FILE FORMAT command-line arguments. Path searching is used and the current directory will be "EngineDir". + SettingsDir (default: $HOME/.polyglot on Linux; ".\_PG" on Windows) + The directory where ini files are stored for engines that are + started with -noini. Such ini files may be created by pushing the + "Save" button in the Engine settings dialog in WB/XB 4.4.0 and + higher. As a special exception (for WB/XB 4.4.0 compatibility) this + directory is also used in case PolyGlot is started with config + files named "polyglot_1st.ini" or "polyglot_2nd.ini". + Log (default: false) Whether PolyGlot should log all transactions with the interface and the engine. This should be necessary only to locate problems. @@ -333,8 +350,8 @@ CONFIG FILE FORMAT move are ignored. ResignScore (default: 600) - This is the score in centipawns that will trigger resign - "counting". + This is the score in centipawns that will trigger resign "count- + ing". ShowPonder (default: true) Show search information during engine pondering. Turning this off @@ -351,8 +368,8 @@ CONFIG FILE FORMAT move). KibitzCommand (default: "tellall") - xboard command to use for kibitzing, normally "tellall" for - kibitzing or "tellothers" for whispering. + xboard command to use for kibitzing, normally "tellall" for kibitz- + ing or "tellothers" for whispering. KibitzDelay (default: 5) How many seconds to wait before starting kibitzing. This has an @@ -381,8 +398,8 @@ CONFIG FILE FORMAT BookFile (default: book.bin) The name of the (binary) book file. Note that PolyGlot will look for it in the directory it was launched from, not in the engine - directory. Of course, full path can be used in which case the - current directory does not matter. + directory. Of course, full path can be used in which case the cur- + rent directory does not matter. BookRandom (default: true) Select moves according to their weights in the book. If false the @@ -415,29 +432,19 @@ CONFIG FILE FORMAT This a bit vector in which each bit represents the processors that a process is allowed to run on. This option works only on Windows. - Persist (default: true) - If true then PolyGlot will implement persistence by loading options - from an additional INI file whose name is by default derived from - the engine name. At exit PolyGlot will also save its options to - this INI file. - - PersistFile (default: .ini) - The name of the file from which to take the additional options. It - is probably best to stick with the default. You can safely edit - this file, or delete it to restore the default options. + OnlyWbOptions (default: true) + If true then PolyGlot restricts the options it sends to those that + are potentially useful for WinBoard. - PersistDir (default: $HOME/.polyglot on Linux; ".\Polyglot Settings" on - Windows) - The directory where the PersistFile is stored. + Work arounds - Work arounds Work arounds are identical to options except that they should be used 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: @@ -448,16 +455,16 @@ CONFIG FILE FORMAT CanPonder (default: false) PolyGlot now conforms to the documented UCI behaviour: the engine will be allowed to ponder only if it (the engine) declares the - "Ponder" UCI option. However some engines which can actually - ponder do not declare the option. This work around lets PolyGlot - know that they can ponder. + "Ponder" UCI option. However some engines which can actually pon- + der do not declare the option. This work around lets PolyGlot know + that they can ponder. SyncStop (default: false) - When a ponder miss occurs, Polyglot interrupts the engine and - IMMEDIATELY launches a new search. While there should be no - problem with this, some engines seem confused and corrupt their - search board. "SyncStop" forces PolyGlot to wait for the (now - useless) ponder search to finish before launching the new search. + When a ponder miss occurs, Polyglot interrupts the engine and IMME- + DIATELY launches a new search. While there should be no problem + with this, some engines seem confused and corrupt their search + board. "SyncStop" forces PolyGlot to wait for the (now useless) + ponder search to finish before launching the new search. PromoteWorkAround (default: false) Some engines do not specify a promotion piece, e.g. they send @@ -473,29 +480,15 @@ CONFIG FILE FORMAT to the way kibitzing is implemented, KibitzMove is disabled in that case. - WbWorkArounds (default: true) - The intention of these options is to provide work arounds for - xboard/winboard bugs should they arise. This one decapitalizes the - word Draw in options that contain this word. Some versions of - xboard/winboard contain a bug which causes such options to be - interpreted as draw claims by the engine. - - Engines that send options with "Draw" in their name are Rybka and - HIARCS. - - WbWorkArounds2 (default: false) - Old version of Winboard clear the engine output window at depth 1. - With this work around PG will send info lines at depth >=2. This - may or may not improve the display. + [Engine] section - [Engine] section This section contains engine UCI options. PolyGlot does not understand them, but sends the information to the engine at startup (converted to UCI form). You can add any UCI option that makes sense to the engine (not just the common options about hash-table size and tablebases). - NOTE: use INI syntax, not UCI. For example "OwnBook = true" is - correct. It will be replaced by PolyGlot with "setoption name OwnBook + NOTE: use INI syntax, not UCI. For example "OwnBook = true" is cor- + rect. It will be replaced by PolyGlot with "setoption name OwnBook value true" at engine startup. Standard UCI options are @@ -559,7 +552,7 @@ AUTHORS Various enhancements: Fonzy Bleumers - UCI port, option persistence and new WB protocol: Michel Van den Bergh + UCI port and implementation of new WB protocol: Michel Van den Bergh SEE ALSO @@ -567,4 +560,4 @@ SEE ALSO - 2009-09-05 POLYGLOT(6) + 2009-09-11 POLYGLOT(6) diff --git a/config.guess b/config.guess index f32079a..278f9e9 100755 --- a/config.guess +++ b/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2008-01-23' +timestamp='2007-07-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -56,8 +56,8 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -532,7 +532,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -799,9 +799,6 @@ EOF EM64T | authenticamd) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks @@ -836,14 +833,7 @@ EOF echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-gnu - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - fi + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -964,8 +954,8 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so @@ -1484,9 +1474,9 @@ This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub If the version you run ($0) is already up to date, please send the following data and any information you think might be diff --git a/config.h b/config.h index bd86e86..d80095b 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.46b" +#define PACKAGE_STRING "polyglot 1.4.50b" /* 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.46b" +#define PACKAGE_VERSION "1.4.50b" /* 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.46b" +#define VERSION "1.4.50b" /* Define like PROTOTYPES; this can be used by system headers. */ #define __PROTOTYPES 1 diff --git a/config.sub b/config.sub index 6759825..1761d8b 100755 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2008-01-16' +timestamp='2007-06-28' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -72,8 +72,8 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -369,14 +369,10 @@ case $basic_machine in | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa*-* \ + | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) @@ -447,14 +443,6 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; c90) basic_machine=c90-cray os=-unicos @@ -680,14 +668,6 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; m88k-omron*) basic_machine=m88k-omron ;; @@ -833,14 +813,6 @@ case $basic_machine in basic_machine=i860-intel os=-osf ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; pbd) basic_machine=sparc-tti ;; @@ -1049,10 +1021,6 @@ case $basic_machine in basic_machine=tic6x-unknown os=-coff ;; - tile*) - basic_machine=tile-unknown - os=-linux-gnu - ;; tx39) basic_machine=mipstx39-unknown ;; diff --git a/configure b/configure index d03e34c..b5b969a 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.46b. +# Generated by GNU Autoconf 2.61 for polyglot 1.4.50b. # # 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.46b' -PACKAGE_STRING='polyglot 1.4.46b' +PACKAGE_VERSION='1.4.50b' +PACKAGE_STRING='polyglot 1.4.50b' 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.46b to adapt to many kinds of systems. +\`configure' configures polyglot 1.4.50b 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.46b:";; + short | recursive ) echo "Configuration of polyglot 1.4.50b:";; 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.46b +polyglot configure 1.4.50b 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.46b, which was +It was created by polyglot $as_me 1.4.50b, 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.46b' + VERSION='1.4.50b' 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.46b, which was +This file was extended by polyglot $as_me 1.4.50b, 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.46b +polyglot config.status 1.4.50b 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 7386c1a..2ad1c89 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.46b], [michel.vandenbergh@uhasselt.be]) +AC_INIT([polyglot], [1.4.50b], [michel.vandenbergh@uhasselt.be]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([mainloop.c]) AC_CONFIG_HEADER([config.h]) diff --git a/debian/changelog b/debian/changelog index 0eb0168..1d4c545 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,57 @@ +polyglot (1.4.50b) unstable; urgency=low + + * Change in architecture. Persistence is disabled. The user is required to push th "Save" button explicitly to save the settings. What is retained is that in case PG is invoked with -noini (or as a special exception for WB 4.4.0 when the config files are polyglot_1st.ini or polyglot_2nd.ini) then PG uses a default config file whose name is derived from the engine name. + + * New option: OnlyWbOptions (default: true). Restrict the options that PG sends to those that are potentially useful for WinBoard. + + -- Michel Van den Bergh Fri, 9 Sep 2009 21:00:00 +0100 + +polyglot (1.4.46b) unstable; urgency=low + + * The default persistence directory on Windows is now _PG. The names of the engine specific ini files are mangled so as not to contain spaces. + + * PG now tries to guess if a string option is really a file or a path (like in the Arena GUI). + + -- Michel Van den Bergh Fri, 4 Sep 2009 21:00:00 +0100 + +polyglot (1.4.45b) unstable; urgency=low + + * The engine specific config files (.ini) are now stored in a separate directory. $HOME/.polyglot on Linux and "./Polyglot Settings" on Windows. + + * The engine specific config files are now complete config files. So they can be used in a stand alone fashion. + + * Implemented a minor hack to make xboard show error messages during startup. + + -- Michel Van den Bergh Fri, 4 Sep 2009 21:00:00 +0100 + +polyglot (1.4.44b) unstable; urgency=low + + * "Implementation" of new buttons and controls. + + * The "Persist" option is now persistent. That is if you turn of "Persist" then as a special case PG will remember this. + + * There is now a "reset" button which restores the default options. The code is commented out since WB does not support it yet. + + -- Michel Van den Bergh Thu, 3 Sep 2009 21:00:00 +0100 + +polyglot (1.4.42b) unstable; urgency=low + + * SaveSettingsOnExit/SaveFile renamed as Persist/PersistFile. + + * Many bug fixes in the persistence feature. + + * The PG_.ini file now contains only options that have been changed. So the resulting ini files are much smaller. This makes this version of PG usable on WB 4.3.15 as now the engine specific ini file will be empty (the user has no way to change options). + + -- Michel Van den Bergh Mon, 1 Sep 2009 21:00:00 +0100 + +polyglot (1.4.41b) unstable; urgency=low + + * Some segfaults fixed in case of corrupt config files. + + * Persistence of options. If the option SaveSettingsOnExit is true (the default) PolyGlot now saves its options in a file whose name is given by the option SaveFile which by default is equal to the engine name, prefixed by PG_ suffixed by ".ini". + + -- Michel Van den Bergh Sun, 31 Aug 2009 21:00:00 +0100 + polyglot (1.4.39b) unstable; urgency=low * Refactoring of config file parsing diff --git a/debian/files b/debian/files index 0bc7c99..d93b7da 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -polyglot_1.4.39b_i386.deb games extra +polyglot_1.4.50b_i386.deb games extra diff --git a/main.c b/main.c index aaadc82..830dfa2 100644 --- a/main.c +++ b/main.c @@ -39,7 +39,7 @@ // constants -static const char * const Version = "1.4.46b"; +static const char * const Version = "1.4.50b"; static const char * const HelpMessage = "\ SYNTAX\n\ * polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg =]* [-uci =]*\n\ @@ -55,29 +55,12 @@ static const int SearchDepth = 63; static const double SearchTime = 3600.0; static const int StringSize = 4096; -static const char * const IniIntro= - "; This ini file is used internally by PolyGlot\n" - "; to remember the settings for the UCI engine\n" - "; whose name is \"%s\".\n" - "\n" - "; The values for these settings would be typicallly\n" - "; obtained from the engine settings dialog\n" - "; in WinBoard/xboard 4.4.0 and higher.\n" - "\n" - "; If the value of the option \"Persist\" is false\n" - "; then the content of this file is ignored.\n" - "\n" - "; It is allowed to manually edit this file\n" - "; and you may safely delete it as well.\n" - "\n"; - // variables static bool Init; // prototypes -static void init_book (); static void stop_search (); // functions @@ -91,34 +74,108 @@ static void arg_shift_left(char **argv, int index){ } } +// parse_args() + +static void parse_args(ini_t *ini, char **argv){ + int arg_index; + char *arg; + arg_index=0; + while((arg=argv[arg_index])){ + if(my_string_equal(arg,"-ec") && argv[arg_index+1]){ + ini_insert_ex(ini,"PolyGlot","EngineCommand",argv[arg_index+1]); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + }if(my_string_equal(arg,"-ed") && argv[arg_index+1]){ + ini_insert_ex(ini,"PolyGlot","EngineDir",argv[arg_index+1]); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + if(my_string_equal(arg,"-en") && argv[arg_index+1]){ + ini_insert_ex(ini,"PolyGlot","EngineName",argv[arg_index+1]); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + if(my_string_equal(arg,"-log") && + argv[arg_index+1] && + IS_BOOL(argv[arg_index+1])){ + ini_insert_ex(ini, + "PolyGlot", + "Log", + TO_BOOL(argv[arg_index+1])?"true":"false"); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + if(my_string_equal(arg,"-lf") && argv[arg_index+1]){ + ini_insert_ex(ini,"PolyGlot","LogFile",argv[arg_index+1]); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + if(my_string_equal(arg,"-wb") && + argv[arg_index+1]&& + IS_BOOL(argv[arg_index+1])){ + ini_insert_ex(ini,"PolyGlot", + "OnlyWbOptions", + TO_BOOL(argv[arg_index+1])?"true":"false"); + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + if((my_string_equal(arg,"-pg")||my_string_equal(arg,"-uci")) && + argv[arg_index+1]){ + int ret; + char section[StringSize]; + char name[StringSize]; + char value[StringSize]; + ret=ini_line_parse(argv[arg_index+1],section,name,value); + if(ret==NAME_VALUE){ + if(my_string_equal(arg,"-pg")){ + ini_insert_ex(ini,"PolyGlot",name,value); + }else{ + ini_insert_ex(ini,"Engine",name,value); + } + } + arg_shift_left(argv,arg_index); + arg_shift_left(argv,arg_index); + continue; + } + arg_index++; + } +} + // make_ini() static void make_ini(ini_t *ini){ option_t *opt; - char tmp[StringSize]; - ini_insert_ex(ini,"polyglot", - "EngineName", - option_get_string(Option,"EngineName")); ini_insert_ex(ini,"polyglot", "EngineCommand", - option_get_string(Option,"EngineCommand")); + option_get(Option,"EngineCommand")); ini_insert_ex(ini,"polyglot", "EngineDir", - option_get_string(Option,"EngineDir")); + option_get(Option,"EngineDir")); option_start_iter(Option); while((opt=option_next(Option))){ - if(!my_string_equal(opt->value,opt->default_)&& - !IS_BUTTON(opt->type) && - (opt->mode & XBOARD)){ - ini_insert_ex(ini,"polyglot",opt->name,opt->value); + if(my_string_case_equal(opt->name,"SettingsFile")) continue; + if(my_string_case_equal(opt->name,"EngineCommand")) continue; + if(my_string_case_equal(opt->name,"EngineDir")) continue; + if(!my_string_equal(opt->value,opt->default_)&& !IS_BUTTON(opt->type)) + { + ini_insert_ex(ini,"polyglot",opt->name,opt->value); } } option_start_iter(Uci->option); while((opt=option_next(Uci->option))){ + if(!strncmp(opt->name,"UCI_",4) && + !my_string_case_equal(opt->name,"UCI_LimitStrength") && + !my_string_case_equal(opt->name,"UCI_Elo"))continue; if(!my_string_equal(opt->value,opt->default_)&& !IS_BUTTON(opt->type)){ - ini_insert_ex(ini,"engine",opt->name,opt->value); + ini_insert_ex(ini,"engine",opt->name,opt->value); } } } @@ -128,27 +185,32 @@ static void make_ini(ini_t *ini){ static void write_ini(const char *filename, ini_t *ini){ + const char *quote; ini_entry_t *entry; char tmp[StringSize]; FILE *f; time_t t=time(NULL); f=fopen(filename,"w"); if(!f){ - // alas this does nothing.... gui_send(GUI,"tellusererror write_ini(): %s: %s.",filename,strerror(errno)); - // but at least we log the error my_log("POLYGLOT write_ini(): %s: %s.\n",filename,strerror(errno)); return; } - fprintf(f,"; %s\n",ctime(&t)); - fprintf(f,IniIntro,option_get_string(Option,"EngineName")); + fprintf(f,"; Created: %s\n",ctime(&t)); fprintf(f,"[PolyGlot]\n"); ini_start_iter(ini); while((entry=ini_next(ini))){ if(my_string_case_equal(entry->section,"polyglot")){ - snprintf(tmp,sizeof(tmp),"%s=%s\n", - entry->name, - entry->value); + if(strchr(entry->value,';')|| strchr(entry->value,'#')|| strchr(entry->value,'"')){ + quote="\""; + }else{ + quote=""; + } + snprintf(tmp,sizeof(tmp),"%s=%s%s%s\n", + entry->name, + quote, + entry->value, + quote); tmp[sizeof(tmp)-1]='\0'; fprintf(f,"%s",tmp); } @@ -156,10 +218,17 @@ static void write_ini(const char *filename, fprintf(f,"[Engine]\n"); ini_start_iter(ini); while((entry=ini_next(ini))){ - if(my_string_case_equal(entry->section,"engine")){ - snprintf(tmp,sizeof(tmp),"%s=%s\n", - entry->name, - entry->value); + if(my_string_case_equal(entry->section,"engine")){ + if(strchr(entry->value,';')|| strchr(entry->value,'#')|| strchr(entry->value,'"')){ + quote="\""; + }else{ + quote=""; + } + snprintf(tmp,sizeof(tmp),"%s=%s%s%s\n", + entry->name, + quote, + entry->value, + quote); tmp[sizeof(tmp)-1]='\0'; fprintf(f,"%s",tmp); } @@ -167,22 +236,47 @@ static void write_ini(const char *filename, fclose(f); } +// welcome_message() + +void welcome_message(char *buf){ + if(!DEBUG){ + sprintf(buf, + "PolyGlot %s by Fabien Letouzey.\n", + Version); + }else{ + sprintf(buf, + "PolyGlot %s by Fabien Letouzey (debug build).\n", + Version); + } +} + +int wb_select(){ + option_t *opt; + option_start_iter(Option); + while((opt=option_next(Option))){ + opt->mode&=~XBOARD; + if(opt->mode & XBSEL){ + opt->mode|=XBOARD; + } + } +} // main() int main(int argc, char * argv[]) { - ini_t ini[1],ini_save[1]; + ini_t ini[1], ini_command[1]; ini_entry_t *entry; char *arg; int arg_index; - bool NoIni, Persist; - char persist_path[StringSize]; + bool NoIni; + option_t *opt; + char welcome[StringSize]; + + + welcome_message(welcome); - if(!DEBUG){ - printf("PolyGlot %s by Fabien Letouzey.\n",Version); - }else{ - printf("PolyGlot %s by Fabien Letouzey (debug build).\n",Version); - } + printf("%s",welcome); + if(argc>=2 && ((my_string_case_equal(argv[1],"help")) || (my_string_case_equal(argv[1],"-help")) || (my_string_case_equal(argv[1],"--help")) || (my_string_case_equal(argv[1],"-h")) || my_string_case_equal(argv[1],"/?"))){ printf("%s\n",HelpMessage); @@ -205,9 +299,9 @@ int main(int argc, char * argv[]) { my_random_init(); ini_init(ini); - ini_init(ini_save); + ini_init(ini_command); - // book utilities + // book utilities: do not touch these if (argc >= 2 && my_string_equal(argv[1],"make-book")) { book_make(argc,argv); @@ -235,9 +329,6 @@ int main(int argc, char * argv[]) { do_perft(argc,argv); return EXIT_SUCCESS; } - - // TODO: If logging is enabled on the command line turn it on NOW - // and do not allow it to be overridden later. // What is the config file? This is very hacky right now. @@ -252,8 +343,9 @@ int main(int argc, char * argv[]) { } } arg_shift_left(argv,arg_index-1); + parse_args(ini_command,argv+1); if(NoIni){ - option_set(Option,"OptionFile",""); + option_set(Option,"SettingsFile",""); } // Ok see if first argument looks like config file @@ -261,7 +353,7 @@ int main(int argc, char * argv[]) { if(argv[1] && !my_string_equal(argv[1],"epd-test") && !(argv[1][0]=='-')){ // first argument must be config file if(!NoIni){ - option_set(Option,"OptionFile",argv[1]); + option_set(Option,"SettingsFile",argv[1]); }else{ // ignore } @@ -270,33 +362,59 @@ int main(int argc, char * argv[]) { // Config file is the default. // This has already been set above or in "option_init_pg()" } - + + // if we use a config file: load it! - if(!my_string_equal(option_get_string(Option,"OptionFile"),"")){ - if(ini_parse(ini,option_get_string(Option,"OptionFile"))){ + if(!my_string_equal(option_get_string(Option,"SettingsFile"),"")){ + if(ini_parse(ini,option_get_string(Option,"SettingsFile"))){ my_fatal("main(): Can't open file \"%s\": %s\n", - option_get_string(Option,"OptionFile"), + option_get_string(Option,"SettingsFile"), strerror(errno)); } } - // remind the reader of what options are in effect - my_log("POLYGLOG Options from ini file\n"); - ini_disp(ini); + // Extract some important options - // extract PG options + if((entry=ini_find(ini,"polyglot","EngineCommand"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini,"polyglot","EngineDir"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini,"polyglot","EngineName"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini,"polyglot","Log"))){ + polyglot_set_option(entry->name,entry->value); + } + if((entry=ini_find(ini,"polyglot","LogFile"))){ + polyglot_set_option(entry->name,entry->value); + } - ini_start_iter(ini); - while((entry=ini_next(ini))){ - if(my_string_case_equal(entry->section,"polyglot")){ - option_set(Option,entry->name,entry->value); - option_set_default(Option,entry->name,entry->value); + // Concession to WB 4.4.0 + // Treat "polyglot_1st.ini" and "polyglot_2nd.ini" specially + + if(option_get_bool(Option,"WbWorkArounds3")){ + const char *SettingsFile=option_get(Option,"SettingsFile"); + if(strstr(SettingsFile,"polyglot_1st.ini")|| + strstr(SettingsFile,"polyglot_2nd.ini")){ + option_set(Option,"SettingsFile",""); } } - // start logging if required + // Look at command line for logging option. It is important + // to start logging as soon as possible. + + if((entry=ini_find(ini_command,"PolyGlot","Log"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini_command,"PolyGlot","LogFile"))){ + option_set(Option,entry->name,entry->value); + } + + // start logging if required if (option_get_bool(Option,"Log")) { my_log_open(option_get_string(Option,"LogFile")); @@ -304,41 +422,24 @@ int main(int argc, char * argv[]) { // log welcome stuff - if(!DEBUG){ - my_log("PolyGlot %s by Fabien Letouzey\n",Version); - }else{ - my_log("PolyGlot %s by Fabien Letouzey (debug build)\n",Version); - } + my_log("%s",welcome); my_log("POLYGLOT *** START ***\n"); - my_log("POLYGLOT INI file \"%s\"\n",option_get_string(Option,"OptionFile")); + if(!my_string_equal(option_get_string(Option,"SettingsFile"),"")){ + my_log("POLYGLOT INI file \"%s\"\n",option_get_string(Option,"SettingsFile")); + } - // open book (presumably this should go else where) - - init_book(); // scavenge command line for options necessary to start the engine - - arg_index=1; - while((arg=argv[arg_index])){ - if(my_string_equal(arg,"-ec") && argv[arg_index+1]){ - option_set(Option,"EngineCommand",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - if(my_string_equal(arg,"-ed") && argv[arg_index+1]){ - option_set(Option,"EngineDir",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - if(my_string_equal(arg,"-en") && argv[arg_index+1]){ - option_set(Option,"EngineName",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - arg_index++; + + + if((entry=ini_find(ini_command,"PolyGlot","EngineCommand"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini_command,"PolyGlot","EngineDir"))){ + option_set(Option,entry->name,entry->value); + } + if((entry=ini_find(ini_command,"PolyGlot","EngineName"))){ + option_set(Option,entry->name,entry->value); } // start engine @@ -359,130 +460,76 @@ int main(int argc, char * argv[]) { uci_open(Uci,Engine); - // get engine name from engine if not supplied in config file - + option_set_default(Option,"EngineName",Uci->name); + + // get engine name from engine if not supplied in config file or on + // the command line + if (my_string_equal(option_get_string(Option,"EngineName"),"")) { option_set(Option,"EngineName",Uci->name); } - // what is the name of the persist file? - if(my_string_equal(option_get_string(Option,"PersistFile"),"")){ + // In the case we have been invoked with NoIni or StandardIni + // we still have to load a config file. + + if(my_string_equal(option_get_string(Option,"SettingsFile"),"")){ + + // construct the name of the ConfigFile from the EngineName + char tmp[StringSize]; - int i; + char option_file[StringSize]; + int i; snprintf(tmp,sizeof(tmp),"%s.ini", option_get_string(Option,"EngineName")); tmp[sizeof(tmp)-1]='\0'; - for(i=0;ivalue,"false") || - my_string_equal(entry->value,"0"))?FALSE:TRUE; - } - - // if "Persist" now happens to be false, forget about the - // persist file - - if(!Persist){ - my_log("POLYGLOT Ignoring PersistFile"); - ini_clear(ini_save); - } + // Remind the reader about the options that are now in effect. - option_set(Option,"Persist",Persist?"true":"false"); - - // parse the command line and merge remaining options + my_log("POLYGLOG OPTIONS \n"); + ini_disp(ini); - arg_index=1; - while((arg=argv[arg_index])){ - if(my_string_equal(arg,"-log")){ - ini_insert_ex(ini_save,"PolyGlot","Log","true"); - arg_shift_left(argv,arg_index); - continue; - } - if(my_string_equal(arg,"-lf") && argv[arg_index+1]){ - ini_insert_ex(ini_save,"PolyGlot","LogFile",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - if(my_string_equal(arg,"-hash") && argv[arg_index+1]){ - ini_insert_ex(ini_save,"Engine","Hash",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - if(my_string_equal(arg,"-bk") && argv[arg_index+1]){ - ini_insert_ex(ini_save,"PolyGlot","Book","true"); - ini_insert_ex(ini_save,"PolyGlot","BookFile",argv[arg_index+1]); - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; - } - if((my_string_equal(arg,"-pg")||my_string_equal(arg,"-uci")) && - argv[arg_index]){ - int ret; - char section[StringSize]; - char name[StringSize]; - char value[StringSize]; - ret=ini_line_parse(argv[arg_index++],section,name,value); - if(ret==NAME_VALUE){ - if(my_string_equal(arg,"-pg")){ - ini_insert_ex(ini_save,"PolyGlot",name,value); - }else{ - ini_insert_ex(ini_save,"Engine",name,value); - } + // extract PG options + + ini_start_iter(ini); + while((entry=ini_next(ini))){ + if(my_string_case_equal(entry->section,"polyglot")){ + opt=option_find(Option,entry->name); + if(opt && !IS_BUTTON(opt->type)){ + polyglot_set_option(entry->name,entry->value); } - arg_shift_left(argv,arg_index); - arg_shift_left(argv,arg_index); - continue; } - arg_index++; } - // remind the reader once again about options - - my_log("POLYGLOG Options from PersistFile and command line\n"); - ini_disp(ini_save); - - // Extract PG options; this time do not set the default. - // polyglot_set_option() performs the necessary actions such - // as opening the log file/opening book etcetera. - // Ignore EngineName, EngineCommand and EngineDir - // as these are really meant as comments. + // Cater to our biggest customer:-) - ini_start_iter(ini_save); - while((entry=ini_next(ini_save))){ - if(my_string_case_equal(entry->section,"polyglot")){ - if(my_string_case_equal(entry->value,"EngineName")) - continue; - if(my_string_case_equal(entry->value,"EngineCommand")) - continue; - if(my_string_case_equal(entry->value,"EngineDir")) - continue; - polyglot_set_option(entry->name,entry->value); - } + if(option_get_bool(Option,"OnlyWbOptions")){ + wb_select(); } // done initializing @@ -496,8 +543,6 @@ int main(int argc, char * argv[]) { if(my_string_case_equal(entry->section,"engine")){ // also updates value in Uci->option uci_send_option(Uci,entry->name,"%s",entry->value); - // since this comes from the ini file, also update default - option_set_default(Uci->option,entry->name,entry->value); // this is inherited, it probably does not work correctly if(my_string_case_equal(entry->name,"MultiPV") && atoi(entry->value)>1){ @@ -505,19 +550,8 @@ int main(int argc, char * argv[]) { } } } - ini_start_iter(ini_save); - while((entry=ini_next(ini_save))){ - if(my_string_case_equal(entry->section,"engine")){ - // also updates value in Uci->option - uci_send_option(Uci,entry->name,"%s",entry->value); - // this is inherited, it probably does not work correctly - if(my_string_case_equal(entry->name,"MultiPV") && - atoi(entry->value)>1){ - Uci->multipv_mode=TRUE; - } - } - } - + + // EPD test @@ -529,12 +563,16 @@ int main(int argc, char * argv[]) { } // Anything that hasn't been parsed yet is a syntax error + // It seems that XBoard sometimes passes empty strings as arguments + // to PolyGlot. We ignore these. - if(argv[1]){ - my_fatal("main(): Unknown option: %s\n",argv[1]); + argc=1; + while((arg=argv[argc++])){ + if(!my_string_equal(arg,"")){ + my_fatal("main(): Option: \"%s\" not found\n",argv[argc-1]); + } } - gui_init(GUI); mainloop(); return EXIT_SUCCESS; @@ -543,24 +581,27 @@ int main(int argc, char * argv[]) { // polyglot_set_option() void polyglot_set_option(const char *name, const char *value){ // this must be cleaned up! - option_t *opt; + ini_t ini[1]; + int ret; + ini_init(ini); my_log("POLYGLOT Setting PolyGlot option %s=\"%s\"\n",name,value); - if(my_string_case_equal(name,"Defaults")){ - option_start_iter(Uci->option); - while((opt=option_next(Uci->option))){ - if(!IS_BUTTON(opt->type)){ - // also sets opt->value - uci_send_option(Uci,opt->name,opt->default_); - } - } - option_start_iter(Option); - while((opt=option_next(Option))){ - if(!IS_BUTTON(opt->type)){ - polyglot_set_option(opt->name,opt->default_); - } - } - xboard2uci_send_options(); - } + if(my_string_case_equal(name,"Save")){ + ret=my_mkdir(option_get(Option,"SettingsDir")); + if(ret){ + my_log("POLYGLOT polyglot_set_option(): %s: %s\n", + option_get(Option,"SettingsDir"), + strerror(errno)); + } + make_ini(ini); + write_ini(option_get(Option,"SettingsFile"),ini); + return; + } +// if(my_string_equal(option_get(Option,name),value)){ +// my_log("Not setting PolyGlot option \"%s\" " +// "since it already as the correct value.\n", +// name); +// return; +// } option_set(Option,name,value); if(option_get_bool(Option,"Book")&&(my_string_case_equal(name,"BookFile")||my_string_case_equal(name,"Book"))){ my_log("POLYGLOT *** SETTING BOOK ***\n"); @@ -573,7 +614,7 @@ void polyglot_set_option(const char *name, const char *value){ // this must be c } }else if(option_get_bool(Option,"Log")&&(my_string_case_equal(name,"LogFile") ||my_string_case_equal(name,"Log"))){ my_log("POLYGLOT *** SWITCHING LOGFILE ***\n"); - my_log("POLYGLOT LOGFILE \"%s\"\n",option_get_string(Option,"LogFile")); + my_log("POLYGLOT NEW LOGFILE \"%s\"\n",option_get_string(Option,"LogFile")); my_log_close(); my_log_open(option_get_string(Option,"LogFile")); }else if(option_get_bool(Option,"UseNice") &&(my_string_case_equal(name,"NiceValue")||my_string_case_equal(name,"UseNice"))){ @@ -592,32 +633,11 @@ void polyglot_set_option(const char *name, const char *value){ // this must be c } -// init_book() - -static void init_book(){ - book_clear(); - if (option_get_bool(Option,"Book")){ - my_log("POLYGLOT *** SETTING BOOK ***\n"); - my_log("POLYGLOT BOOK \"%s\"\n",option_get_string(Option,"BookFile")); - book_open(option_get_string(Option,"BookFile")); - if(!book_is_open()){ - my_log("POLYGLOT Unable to open book \"%s\"\n", - option_get_string(Option,"BookFile")); - } - } -} - // quit() void quit() { - ini_t ini[1]; - char persist_path[StringSize]; - int ret; - - ini_init(ini); - my_log("POLYGLOT *** QUIT ***\n"); if (Init) { @@ -628,34 +648,7 @@ void quit() { engine_close(Engine); } - ret=my_mkdir(option_get(Option,"PersistDir")); - if(ret){ - my_log("POLYGLOT quit(): %s: %s\n",option_get(Option,"PersistDir"),strerror(errno)); - } - // PersistFile can be named "" in case of a crash before the - // engine is started. - if(!my_string_case_equal(option_get(Option,"PersistFile"), - "")){ - // Persistence should only work in XBOARD mode. - // In UCI mode the GUI is responsible for remembering options. - if(!option_get_bool(Option,"UCI")){ - my_path_join(persist_path, - option_get(Option,"PersistDir"), - option_get(Option,"PersistFile")); - make_ini(ini); - if(option_get_bool(Option,"Persist")){ - write_ini(persist_path,ini); - }else if(!my_string_case_equal(option_get_default(Option,"Persist"), - option_get_string(Option,"Persist"))){ - // Hack - ini_insert_ex(ini,"polyglot","Persist","false"); - write_ini(persist_path,ini); - }else{ - write_ini(persist_path,ini); - } my_log("POLYGLOT Calling exit\n"); - } - } exit(EXIT_SUCCESS); } @@ -679,5 +672,5 @@ static void stop_search() { } -// end of main.cpp +// end of main.c diff --git a/option.c b/option.c index 0052fe3..e415b5b 100644 --- a/option.c +++ b/option.c @@ -9,6 +9,11 @@ #include "option.h" #include "util.h" + +// defines + +#define NNB { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL } + // constants static const bool UseDebug = FALSE; @@ -16,44 +21,41 @@ static const int StringSize = 4096; // variables -#define NNB { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL } option_list_t Option[1]; option_t DefaultOptions[] = { - { "OptionFile", "file","0","0", "polyglot.ini", NULL,0,NNB, PG}, - // options - { "Persist", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, - { "PersistFile", "file","0","0", "" , NULL,0,NNB, PG}, - { "PersistDir", "path","0","0", "" , NULL,0,NNB, PG}, - + { "SettingsFile", "file","0","0", "polyglot.ini", NULL,0,NNB, PG|XBOARD|XBSEL}, + + { "SettingsDir", "path","0","0", "" , NULL,0,NNB, PG}, + + { "OnlyWbOptions", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, + { "EngineName", "string","0","0", "" , NULL,0,NNB, PG}, - { "EngineDir", "path","0","0", "." , NULL,0,NNB, PG}, + { "EngineDir", "path","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}, - { "LogFile", "file","0","0", "polyglot.log", NULL,0,NNB, PG|XBOARD|UCI}, + { "Log", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|XBSEL|UCI}, + { "LogFile", "file","0","0", "polyglot.log", NULL,0,NNB, PG|XBOARD|XBSEL|UCI}, { "UCI", "check","0","0", "false" , NULL,0,NNB, PG}, { "UseNice", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, { "NiceValue", "spin", "0","20", "5" , NULL,0,NNB, PG|XBOARD|UCI}, - { "Chess960", "check","0","0", "false" , NULL,0,NNB, PG}, - - { "Resign", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, - { "ResignMoves", "spin","0","10000", "3" , NULL,0,NNB, PG|XBOARD}, - { "ResignScore", "spin","0","10000", "600" , NULL,0,NNB, PG|XBOARD}, + { "Resign", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|XBSEL}, + { "ResignMoves", "spin","0","10000", "3" , NULL,0,NNB, PG|XBOARD|XBSEL}, + { "ResignScore", "spin","0","10000", "600" , NULL,0,NNB, PG|XBOARD|XBSEL}, { "MateScore", "spin","0","100000", "10000" , NULL,0,NNB, PG|XBOARD}, - { "Book", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, - { "BookFile", "file","0","0", "book.bin" , NULL,0,NNB, PG|XBOARD|UCI}, + { "Book", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|XBSEL|UCI}, + { "BookFile", "file","0","0", "book.bin" , NULL,0,NNB, PG|XBOARD|XBSEL|UCI}, - { "BookRandom", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD|UCI}, - { "BookDepth", "spin","0","256", "256" , NULL,0,NNB, PG|XBOARD}, + { "BookRandom", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD|XBSEL|UCI}, + { "BookDepth", "spin","0","256", "256" , NULL,0,NNB, PG|XBOARD|XBSEL}, { "BookTreshold", "spin","0","1000", "5" , NULL,0,NNB, PG|XBOARD|UCI}, { "BookLearn", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, @@ -64,7 +66,7 @@ option_t DefaultOptions[] = { { "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}, + { "ShowPonder", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, { "ScoreWhite", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, // work-arounds @@ -74,15 +76,26 @@ option_t DefaultOptions[] = { { "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}, - { "PromoteWorkAround","check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, + { "PromoteWorkAround","check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, + + // internal - { "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, - { "WbWorkArounds2", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, + { "Chess960", "check","0","0", "false" , NULL,0,NNB, PG}, + + // These options flag various hacks in the source to work around + // WB quirks. They will eventually all be set to false. Probably + // in 4.5.0 + + { "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG}, + { "WbWorkArounds2", "check","0","0", "false" , NULL,0,NNB, PG}, + { "WbWorkArounds3", "check","0","0", "true" , NULL,0,NNB, PG}, // Buttons -// { "Defaults", "reset","0","0", "false" , NULL,0,NNB, PG|XBOARD}, + { "Save", "save","0","0", "false" , NULL,0,NNB, PG|XBOARD|XBSEL}, + // Sentinel + { NULL, NULL,"0","0", NULL , NULL,0,NNB, 0}, }; @@ -106,7 +119,7 @@ void option_init_pg() { int i; option_t *p=DefaultOptions; char *home_dir; - char PersistDir[StringSize]; + char SettingsDir[StringSize]; option_init(Option); while(p){ @@ -125,13 +138,13 @@ void option_init_pg() { if(!home_dir){ home_dir="."; } - snprintf(PersistDir,sizeof(PersistDir),"%s/.polyglot",home_dir); - PersistDir[sizeof(PersistDir)-1]='\0'; + snprintf(SettingsDir,sizeof(SettingsDir),"%s/.polyglot",home_dir); + SettingsDir[sizeof(SettingsDir)-1]='\0'; #else - sprintf(PersistDir,".\\_PG"); + sprintf(SettingsDir,".\\_PG"); #endif - option_set(Option,"PersistDir",PersistDir); - option_set_default(Option,"PersistDir",PersistDir); + option_set(Option,"SettingsDir",SettingsDir); + option_set_default(Option,"SettingsDir",SettingsDir); } // option_init() diff --git a/option.h b/option.h index 17468ba..7a842e6 100644 --- a/option.h +++ b/option.h @@ -15,6 +15,7 @@ #define XBOARD (1<<0) #define UCI (1<<1) #define PG (1<<2) +#define XBSEL (1<<3) #define OptionNb 256 #define IS_BUTTON(str) (my_string_case_equal(str,"button") || \ diff --git a/polyglot.man b/polyglot.man index ded75ff..12f1611 100644 --- a/polyglot.man +++ b/polyglot.man @@ -1,7 +1,15 @@ -.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) +.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== +.de Sh \" Subsection heading +.br +.if t .Sp +.ne 5 +.PP +\fB\\$1\fR +.PP +.. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp @@ -40,25 +48,22 @@ . ds R" '' 'br\} .\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" .\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.ie \nF \{\ +.if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} -.el \{\ -. de IX -.. -.\} +.\" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.hy 0 +.if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -124,11 +129,7 @@ .\" ======================================================================== .\" .IX Title "POLYGLOT 6" -.TH POLYGLOT 6 "2009-09-05" "" "" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh +.TH POLYGLOT 6 "2009-09-11" "" "" .SH "NAME" PolyGlot \- Winboard protocol to UCI protocol adapter \- book engine for Polyglot books @@ -147,12 +148,12 @@ polyglot info-book [\-bin inputfile] [\-exact] .PP polyglot dump-book [\-bin inputfile] \-color color [\-out outputfile] .PP -polyglot [configfile] epd-test [engineoptions] [\-epd inputfile] [\-min\-depth depth] [\-max\-depth depth] [\-max\-time time] [\-depth\-delta delta] +polyglot [configfile] epd-test [engineoptions] [\-epd inputfile] [\-min\-depth depth] [\-max\-depth depth] [\-max\-time time] [\-depth\-delta delta] .PP polyglot perft [\-fen fen] [\-max\-depth depth] .SH "DESCRIPTION" .IX Header "DESCRIPTION" -.SS "PolyGlot as adapter and book engine" +.Sh "PolyGlot as adapter and book engine" .IX Subsection "PolyGlot as adapter and book engine" PolyGlot is a \*(L"\s-1UCI\s0 adapter\*(R". It connects a \s-1GUI\s0 interface (such as XBoard, Winboard, Arena or Chessbase) to a \s-1UCI\s0 chess engine. @@ -183,7 +184,7 @@ by \*(L"Polyglot\*(R". This makes it easy to filter them in the \s-1GUI\s0. .PP \&\s-1NOTE:\s0 Not all options are exported, only those that make sense in the given mode. -.SS "Book making utilities" +.Sh "Book making utilities" .IX Subsection "Book making utilities" PolyGlot supports the \*(L"PolyGlot opening book format\*(R". This is the defacto standard non-proprietary opening book format. It is fully documented @@ -194,17 +195,17 @@ http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html Roughly speaking a PolyGlot opening book is a collection of triples (position, move, weight). A \*(L"position\*(R" is represented by a 64\-bit Zobrist hash key. The weight is proportional to the probability the move should -be played. +be played. .PP Other opening book formats such as ChessBase's .ctg format and Arena's \&.abk format are undocumented and proprietary. They can only be used -by their own GUIs. +by their own GUIs. .PP PolyGlot can compile a pgn file into a binary PolyGlot book and furthermore it can merge two such binary books into a third one. .PP PolyGlot can also extract some useful information from PolyGlot books. The utility -\&\*(L"dump-book\*(R" dumps the \*(L"lines\*(R" in a book for a given color. By definition +\&\*(L"dump\-book\*(R" dumps the \*(L"lines\*(R" in a book for a given color. By definition a line is a sequence of moves (from the starting position) in which the given color makes only book moves and the other color makes arbitrary moves (i.e. not necessarily book moves). @@ -212,7 +213,7 @@ arbitrary moves (i.e. not necessarily book moves). Since a PolyGlot book is built up from positions and not lines there may be (and there usually are) many positions in the book that are not on a \*(L"line\*(R" as defined in the previous paragraph. It is convenient -to call such positions \*(L"isolated\*(R" positions. The utility \*(L"info-book\*(R" +to call such positions \*(L"isolated\*(R" positions. The utility \*(L"info\-book\*(R" counts such isolated positions. .PP Some of the isolated positions are provably unreachable and they @@ -228,12 +229,12 @@ it is difficult to identify the latter. If invoked with \*(L"\-exact\*(R" the utility info-book will attempt to count the isolated positions which require a player to make a non-book move when a book move is available. Due to the possibility of transpositions this is not a fool proof method. -.SS "Epd test mode" +.Sh "Epd test mode" .IX Subsection "Epd test mode" In epd test mode, PolyGlot will search positions in an epd file and record the number of times the right best move was found. The arguments specify when to stop the search in any given position. -.SS "Perft counts" +.Sh "Perft counts" .IX Subsection "Perft counts" A perft count is the number of legal move sequence in a given position up to a given depth. PolyGlot can perform such perft counts. It @@ -253,46 +254,44 @@ Do not use a config file, even if one was specified on the command line. .IP "\fB\-pg\fR" 4 .IX Item "-pg" The argument is a string of the form =. This option will -set the Polyglot option to . +set the Polyglot option to . .IP "\fB\-uci\fR" 4 .IX Item "-uci" The argument is a string of the form =. This option will -set the engine option to . +set the engine option to . .IP "\fB\-ec\fR" 4 .IX Item "-ec" -This sets the EngineCommand. +This is an alias for \-pg \*(L"EngineCommand=\*(R" .IP "\fB\-ed\fR" 4 .IX Item "-ed" -This sets the EngineDir. +This is an alias for \-pg \*(L"EngineDir=\*(R" .IP "\fB\-en\fR" 4 .IX Item "-en" -This sets the EngineName. -.IP "\fB\-hash\fR" 4 -.IX Item "-hash" -This is an alias for \-uci \*(L"Hash=\*(R". -.IP "\fB\-log\fR" 4 -.IX Item "-log" -This is an alias for \-pg \*(L"Log=true\*(R". +This is an alias for \-pg \*(L"EngineName=\*(R" +.IP "\fB\-log\fR (default: false)" 4 +.IX Item "-log (default: false)" +This is an alias for \-pg \*(L"Log=\*(R" .ie n .IP "\fB\-lf\fR (default: ""polyglot.log"")" 4 .el .IP "\fB\-lf\fR (default: ``polyglot.log'')" 4 .IX Item "-lf (default: polyglot.log)" This is an alias for \-pg \*(L"LogFile=\*(R". -.IP "\fB\-bk\fR" 4 -.IX Item "-bk" -This is an alias for \-pg \*(L"Book=true\*(R" \-pg \*(L"BookFile=\*(R". +.ie n .IP "\fB\-wb\fR (default: ""true"")" 4 +.el .IP "\fB\-wb\fR (default: ``true'')" 4 +.IX Item "-wb (default: true)" +This is an alias for \-pg \*(L"OnlyWbOptions=\*(R". .PP When invoked as -.SS "polyglot make-book" +.Sh "polyglot make-book" .IX Subsection "polyglot make-book" PolyGlot supports the following options .ie n .IP "\fB\-pgn\fR (default: ""book.pgn"")" 4 .el .IP "\fB\-pgn\fR (default: ``book.pgn'')" 4 .IX Item "-pgn (default: book.pgn)" -Input file in pgn format. +Input file in pgn format. .ie n .IP "\fB\-bin\fR (default: ""book.bin"")" 4 .el .IP "\fB\-bin\fR (default: ``book.bin'')" 4 .IX Item "-bin (default: book.bin)" -Output file in PolyGlot format. +Output file in PolyGlot format. .IP "\fB\-max\-ply\fR (default: 1024)" 4 .IX Item "-max-ply (default: 1024)" Specifies the maximum ply-depth of lines included in the book. @@ -303,7 +302,7 @@ Specifies the minimum number of games that have to contain this move for it to b .IX Item "-min-score (default: 0.0)" Specifies the minimum score (or weight) this move should have received for it to be included in the book. The score is 2*(wins)+(draws), globally scaled -to fit into 16 bits. +to fit into 16 bits. .IP "\fB\-only\-white\fR" 4 .IX Item "-only-white" Include only moves for white in the book. @@ -313,11 +312,11 @@ Include only moves for black in the book. .IP "\fB\-uniform\fR" 4 .IX Item "-uniform" Set all weights to 1. In other words, all moves will be selected with -equal probability. +equal probability. .PP When invoked as -.SS "polyglot merge-book" +.Sh "polyglot merge-book" .IX Subsection "polyglot merge-book" PolyGlot supports the following options .IP "\fB\-in1\fR" 4 @@ -336,7 +335,7 @@ moves and weights from \*(L"in1\*(R" will be retained in \*(L"out\*(R". .PP When invoked as -.SS "polyglot dump-book" +.Sh "polyglot dump-book" .IX Subsection "polyglot dump-book" PolyGlot supports the following options .IP "\fB\-bin\fR (default: book.bin)" 4 @@ -351,7 +350,7 @@ The name of the output file. .PP When invoked as -.SS "polyglot info-book" +.Sh "polyglot info-book" .IX Subsection "polyglot info-book" PolyGlot supports the following options .IP "\fB\-bin\fR (default: book.bin)" 4 @@ -360,10 +359,10 @@ Input file in PolyGlot book format. .IP "\fB\-exact\fR" 4 .IX Item "-exact" Attempt to count the provably unreachable positions among the isolated ones. -Note that this takes a very long time. +Note that this takes a very long time. .PP When invoked as -.SS "polyglot epd-test" +.Sh "polyglot epd-test" .IX Subsection "polyglot epd-test" (possibly with a config file as first argument) PolyGlot supports besides the generic options described above the following additional @@ -388,7 +387,7 @@ Minimal search depth when the search is stopped using \*(L"\-depth\-delta\*(R". Minimal search time when the search is stopped using \*(L"\-depth\-delta\*(R". .PP When invoked as -.SS "polyglot perft" +.Sh "polyglot perft" .IX Subsection "polyglot perft" PolyGlot supports the following options @@ -400,9 +399,9 @@ Fen at which to start searching. Maximum depth to search. .SH "CONFIG FILE FORMAT" .IX Header "CONFIG FILE FORMAT" -There should be a different config file for each engine. +There should be a different config file for each engine. .PP -The config file is in the traditional \s-1INI\s0 format. +The config file is in the traditional \s-1INI\s0 format. .PP .Vb 6 \& [PolyGLot] @@ -413,13 +412,13 @@ The config file is in the traditional \s-1INI\s0 format. \& ... .Ve .PP -The characters \*(L"#\*(R" and \*(L";\*(R" serve as comment characters. +The characters \*(L"#\*(R" and \*(L";\*(R" serve as comment characters. .PP By default initial and final white space is stripped from option values. If you want to avoid this, or if you want use one of the comment characters # or ; in option values (such as for NalimovPath), enclose the value in quotes. -.SS "[PolyGlot] section" +.Sh "[PolyGlot] section" .IX Subsection "[PolyGlot] section" This section is used by PolyGlot only. The engine is unaware of these options. The list of available options is detailed below. @@ -440,6 +439,15 @@ any data file. Put here the name of the engine executable file. You can also add command-line arguments. Path searching is used and the current directory will be \*(L"EngineDir\*(R". +.ie n .IP "\fBSettingsDir\fR (default: $HOME/.polyglot on Linux; "".\e_PG"" on Windows)" 4 +.el .IP "\fBSettingsDir\fR (default: \f(CW$HOME\fR/.polyglot on Linux; ``.\e_PG'' on Windows)" 4 +.IX Item "SettingsDir (default: $HOME/.polyglot on Linux; ._PG on Windows)" +The directory where ini files are stored for engines that are started with +\&\-noini. Such ini files may be created by pushing the \*(L"Save\*(R" button in the +Engine settings dialog in \s-1WB/XB\s0 4.4.0 and higher. As a special exception +(for \s-1WB/XB\s0 4.4.0 compatibility) this directory is also used in case +PolyGlot is started with config files named \*(L"polyglot_1st.ini\*(R" or +\&\*(L"polyglot_2nd.ini\*(R". .IP "\fBLog\fR (default: false)" 4 .IX Item "Log (default: false)" Whether PolyGlot should log all transactions with the interface and @@ -493,10 +501,10 @@ regardless of the delay. .IP "\fBKibitzInterval\fR (default: 0)" 4 .IX Item "KibitzInterval (default: 0)" This is another form of throttling. PolyGlot will usually wait this -many seconds before doing the next kibitz. +many seconds before doing the next kibitz. .IP "\fB\s-1UCI\s0\fR (default: false)" 4 .IX Item "UCI (default: false)" -If true PolyGlot will not understand xboard commands. +If true PolyGlot will not understand xboard commands. .IP "\fBMateScore\fR (default: 10000)" 4 .IX Item "MateScore (default: 10000)" Mate score reported to \s-1GUI\s0 when in xboard mode. @@ -518,17 +526,17 @@ does not matter. .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. +with the highest weight is selected. .IP "\fBBookLearn\fR (default: false)" 4 .IX Item "BookLearn (default: false)" Store learning information in the book (which must be writable). Currently -no engine actually uses this information. +no engine actually uses this information. .IP "\fBBookDepth\fR (default: 256)" 4 .IX Item "BookDepth (default: 256)" -Stop using the book after this number of moves. +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). +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 @@ -543,27 +551,16 @@ Win32 priority levels are mapped in a sensible way to Unix nice levels. .IP "\fBAffinity\fR (default: \-1)" 4 .IX Item "Affinity (default: -1)" This a bit vector in which each bit represents the processors that a -process is allowed to run on. This option works only on Windows. -.IP "\fBPersist\fR (default: true)" 4 -.IX Item "Persist (default: true)" -If true then PolyGlot will implement persistence by loading options -from an additional \s-1INI\s0 file whose name is by default derived from the -engine name. At exit PolyGlot will also save its options to this \s-1INI\s0 -file. -.IP "\fBPersistFile\fR (default: .ini)" 4 -.IX Item "PersistFile (default: .ini)" -The name of the file from which to take the additional options. It is -probably best to stick with the default. You can safely edit this -file, or delete it to restore the default options. -.ie n .IP "\fBPersistDir\fR (default: $HOME/.polyglot on Linux; "".\ePolyglot Settings"" on Windows)" 4 -.el .IP "\fBPersistDir\fR (default: \f(CW$HOME\fR/.polyglot on Linux; ``.\ePolyglot Settings'' on Windows)" 4 -.IX Item "PersistDir (default: $HOME/.polyglot on Linux; .Polyglot Settings on Windows)" -The directory where the PersistFile is stored. -.SS "Work arounds" +process is allowed to run on. This option works only on Windows. +.IP "\fBOnlyWbOptions\fR (default: true)" 4 +.IX Item "OnlyWbOptions (default: true)" +If true then PolyGlot restricts the options it sends to those that +are potentially useful for WinBoard. +.Sh "Work arounds" .IX Subsection "Work arounds" Work arounds are identical to options except that they should be used only when necessary. Their purpose is to try to hide problems with -various software (not just engines). +various software (not just engines). .PP \&\s-1IMPORTANT:\s0 Any of these work arounds might be removed in future versions of PolyGlot. You are strongly recommended to contact the @@ -599,22 +596,8 @@ score,depth and time usage) it got from the engine. Some engines however do not send a new pv string just before sending the move. In that case the output of PolyGlot would be inconsistent. When RepeatPV is false PolyGlot does not repeat the last pv string. -Due to the way kibitzing is implemented, KibitzMove is disabled in that case. -.IP "\fBWbWorkArounds\fR (default: true)" 4 -.IX Item "WbWorkArounds (default: true)" -The intention of these options is to provide work arounds for -xboard/winboard bugs should they arise. This one decapitalizes -the word Draw in options that contain this word. Some versions of -xboard/winboard contain a bug which causes such options to be -interpreted as draw claims by the engine. -.Sp -Engines that send options with \*(L"Draw\*(R" in their name are Rybka and \s-1HIARCS\s0. -.IP "\fBWbWorkArounds2\fR (default: false)" 4 -.IX Item "WbWorkArounds2 (default: false)" -Old version of Winboard clear the engine output window at depth 1. With this -work around \s-1PG\s0 will send info lines at depth >=2. This may or may not improve -the display. -.SS "[Engine] section" +Due to the way kibitzing is implemented, KibitzMove is disabled in that case. +.Sh "[Engine] section" .IX Subsection "[Engine] section" This section contains engine \s-1UCI\s0 options. PolyGlot does not understand them, but sends the information to the engine at startup @@ -626,7 +609,7 @@ tablebases). correct. It will be replaced by PolyGlot with \*(L"setoption name OwnBook value true\*(R" at engine startup. .PP -Standard \s-1UCI\s0 options are +Standard \s-1UCI\s0 options are .PP .Vb 4 \& Hash @@ -638,7 +621,7 @@ Standard \s-1UCI\s0 options are Hidden options like \*(L"Ponder\*(R" or \*(L"UCI_xxx\*(R" are automatic and should not be put in an \s-1INI\s0 file. .PP -The other options are engine-specific. Check their name using a \s-1UCI\s0 +The other options are engine\-specific. Check their name using a \s-1UCI\s0 \&\s-1GUI\s0 or launch the engine in a console and type \*(L"uci\*(R". .SH "EXAMPLES" .IX Header "EXAMPLES" @@ -690,7 +673,7 @@ Test epd file \*(L"test.epd\*(R" with a (maximum) search time of 7 minutes per p .Ve .SH "EXIT STATUS" .IX Header "EXIT STATUS" -PolyGlot always returns 0 on exit. +PolyGlot always returns 0 on exit. .SH "AUTHORS" .IX Header "AUTHORS" Main author: Fabien Letouzey @@ -699,7 +682,7 @@ Native Windows port: Huang Chen (\*(L"Morning Yello .PP Various enhancements: Fonzy Bleumers .PP -\&\s-1UCI\s0 port, option persistence and new \s-1WB\s0 protocol: Michel Van den Bergh +\&\s-1UCI\s0 port and implementation of new \s-1WB\s0 protocol: Michel Van den Bergh .SH "SEE ALSO" .IX Header "SEE ALSO" diff --git a/polyglot.pod b/polyglot.pod index a7c60d7..7d3a15d 100644 --- a/polyglot.pod +++ b/polyglot.pod @@ -142,31 +142,27 @@ set the engine option to . =item B<-ec> -This sets the EngineCommand. +This is an alias for -pg "EngineCommand=" =item B<-ed> -This sets the EngineDir. +This is an alias for -pg "EngineDir=" =item B<-en> -This sets the EngineName. +This is an alias for -pg "EngineName=" -=item B<-hash> +=item B<-log> (default: false) -This is an alias for -uci "Hash=". - -=item B<-log> - -This is an alias for -pg "Log=true". +This is an alias for -pg "Log=" =item B<-lf> (default: "polyglot.log") This is an alias for -pg "LogFile=". -=item B<-bk> +=item B<-wb> (default: "true") -This is an alias for -pg "Book=true" -pg "BookFile=". +This is an alias for -pg "OnlyWbOptions=". =back @@ -386,6 +382,15 @@ Put here the name of the engine executable file. You can also add command-line arguments. Path searching is used and the current directory will be "EngineDir". +=item B (default: $HOME/.polyglot on Linux; ".\_PG" on Windows) + +The directory where ini files are stored for engines that are started with +-noini. Such ini files may be created by pushing the "Save" button in the +Engine settings dialog in WB/XB 4.4.0 and higher. As a special exception +(for WB/XB 4.4.0 compatibility) this directory is also used in case +PolyGlot is started with config files named "polyglot_1st.ini" or +"polyglot_2nd.ini". + =item B (default: false) Whether PolyGlot should log all transactions with the interface and @@ -513,22 +518,10 @@ Win32 priority levels are mapped in a sensible way to Unix nice levels. This a bit vector in which each bit represents the processors that a process is allowed to run on. This option works only on Windows. -=item B (default: true) - -If true then PolyGlot will implement persistence by loading options -from an additional INI file whose name is by default derived from the -engine name. At exit PolyGlot will also save its options to this INI -file. - -=item B (default: .ini) - -The name of the file from which to take the additional options. It is -probably best to stick with the default. You can safely edit this -file, or delete it to restore the default options. +=item B (default: true) -=item B (default: $HOME/.polyglot on Linux; ".\Polyglot Settings" on Windows) - -The directory where the PersistFile is stored. +If true then PolyGlot restricts the options it sends to those that +are potentially useful for WinBoard. =back @@ -581,22 +574,6 @@ In that case the output of PolyGlot would be inconsistent. When RepeatPV is false PolyGlot does not repeat the last pv string. Due to the way kibitzing is implemented, KibitzMove is disabled in that case. -=item B (default: true) - -The intention of these options is to provide work arounds for -xboard/winboard bugs should they arise. This one decapitalizes -the word Draw in options that contain this word. Some versions of -xboard/winboard contain a bug which causes such options to be -interpreted as draw claims by the engine. - -Engines that send options with "Draw" in their name are Rybka and HIARCS. - -=item B (default: false) - -Old version of Winboard clear the engine output window at depth 1. With this -work around PG will send info lines at depth >=2. This may or may not improve -the display. - =back @@ -672,7 +649,7 @@ Native Windows port: Huang Chen ("Morning Yellow") Various enhancements: Fonzy Bleumers -UCI port, option persistence and new WB protocol: Michel Van den Bergh +UCI port and implementation of new WB protocol: Michel Van den Bergh diff --git a/polyglot.spec b/polyglot.spec index f3c173f..6e5d7f4 100644 --- a/polyglot.spec +++ b/polyglot.spec @@ -1,6 +1,6 @@ Summary: A Winboard protocol to UCI protocol adapter Name: polyglot -Version: 1.4.46b +Version: 1.4.50b Release: 1 License: GPL Group: Amusement/Games diff --git a/uci.c b/uci.c index 9326ec7..5eff8cc 100644 --- a/uci.c +++ b/uci.c @@ -10,6 +10,7 @@ #include "board.h" #include "engine.h" +#include "gui.h" #include "move.h" #include "move_do.h" #include "move_legal.h" @@ -18,6 +19,7 @@ #include "line.h" #include "uci.h" + // constants static const bool UseDebug = FALSE; @@ -148,6 +150,11 @@ void uci_open(uci_t * uci, engine_t * engine) { do { engine_get(uci->engine,string); + // Handle the case that the engine is really a WB engine somewhat gracefully. + if((strstr(string,"Illegal") || strstr(string,"Error")) + &&strstr(string,"uci")){ + my_fatal("uci_open(): Not an UCI engine (not found).\n"); + } event = uci_parse(uci,string); } while (!engine_eof(Engine) && (event & EVENT_UCI) == 0); } @@ -331,7 +338,7 @@ int uci_parse(uci_t * uci, const char string[]) { parse_open(parse,string); if (parse_get_word(parse,command,StringSize)) { - + parse_get_string(parse,argument,StringSize); if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" ARGUMENT \"%s\"\n",command,argument); diff --git a/util.c b/util.c index 32413ab..28e56b5 100644 --- a/util.c +++ b/util.c @@ -150,6 +150,10 @@ void my_log_open(const char file_name[]) { //line buffering doesn't work too well in MSVC and/or windows if (LogFile != NULL) setvbuf(LogFile,NULL,_IOLBF,0); // line buffering #endif + if(LogFile!=NULL){ + my_log("POLYGLOT *** LOGFILE OPENED ***\n"); + } + } // my_log_close() diff --git a/util.h b/util.h index 4eee73a..50eec99 100644 --- a/util.h +++ b/util.h @@ -91,8 +91,13 @@ } \ } \ +#define TO_BOOL(string) ((my_string_case_equal(string,"false") || \ + my_string_equal(string,"0"))?FALSE:TRUE) - +#define IS_BOOL(string) (my_string_case_equal(string,"false")|| \ + my_string_case_equal(string,"true") || \ + my_string_case_equal(string,"1") || \ + my_string_case_equal(string,"0")) // types typedef signed char sint8; -- 1.7.0.4