-=========1.4.38b================\r
-- MSVC++ portability fixes (E.M.)\r
+=========1.4.39b================\r
+- Refactoring of config file parsing\r
+- Fix crash bug in epd-test\r
+- Do not export Chess960. This is handled completely internally. \r
+- Do not export UCI_Opponent and UCI_Chess960. These are handled internally.\r
+- PG can now also be comfortably configured through command line options (i.e. without using a config file). \r
+- Allow quotes in configfile (as in Fonzy Bleumer's PG). \r
=========1.4.37b================\r
- 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.\r
=========1.4.36b================\r
#AM_CXXFLAGS=-g
bin_PROGRAMS = polyglot
-polyglot_SOURCES = mainloop.c attack.c board.c book.c book_make.c book_merge.c colour.c engine.c epd.c fen.c gui.c game.c hash.c io.c line.c list.c main.c move.c move_do.c move_gen.c move_legal.c option.c parse.c pgn.c piece.c pipex_posix.c pipex_win32.c random.c san.c search.c square.c uci.c uci2uci.c util.c xboard2uci.c mainloop.h colour.h hash.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipex.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h xboard2uci.h
+polyglot_SOURCES = mainloop.c attack.c board.c book.c book_make.c book_merge.c colour.c engine.c epd.c fen.c gui.c game.c hash.c ini.c io.c line.c list.c main.c move.c move_do.c move_gen.c move_legal.c option.c parse.c pgn.c piece.c pipex_posix.c pipex_win32.c random.c san.c search.c square.c uci.c uci2uci.c util.c xboard2uci.c mainloop.h colour.h hash.h ini.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipex.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h xboard2uci.h
dist_doc_DATA = README README1.3 README1.4 README1.4w README1.4w10UCI book_format.html
board.$(OBJEXT) book.$(OBJEXT) book_make.$(OBJEXT) \
book_merge.$(OBJEXT) colour.$(OBJEXT) engine.$(OBJEXT) \
epd.$(OBJEXT) fen.$(OBJEXT) gui.$(OBJEXT) game.$(OBJEXT) \
- hash.$(OBJEXT) io.$(OBJEXT) line.$(OBJEXT) list.$(OBJEXT) \
- main.$(OBJEXT) move.$(OBJEXT) move_do.$(OBJEXT) \
+ hash.$(OBJEXT) ini.$(OBJEXT) io.$(OBJEXT) line.$(OBJEXT) \
+ list.$(OBJEXT) main.$(OBJEXT) move.$(OBJEXT) move_do.$(OBJEXT) \
move_gen.$(OBJEXT) move_legal.$(OBJEXT) option.$(OBJEXT) \
parse.$(OBJEXT) pgn.$(OBJEXT) piece.$(OBJEXT) \
pipex_posix.$(OBJEXT) pipex_win32.$(OBJEXT) random.$(OBJEXT) \
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-polyglot_SOURCES = mainloop.c attack.c board.c book.c book_make.c book_merge.c colour.c engine.c epd.c fen.c gui.c game.c hash.c io.c line.c list.c main.c move.c move_do.c move_gen.c move_legal.c option.c parse.c pgn.c piece.c pipex_posix.c pipex_win32.c random.c san.c search.c square.c uci.c uci2uci.c util.c xboard2uci.c mainloop.h colour.h hash.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipex.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h xboard2uci.h
+polyglot_SOURCES = mainloop.c attack.c board.c book.c book_make.c book_merge.c colour.c engine.c epd.c fen.c gui.c game.c hash.c ini.c io.c line.c list.c main.c move.c move_do.c move_gen.c move_legal.c option.c parse.c pgn.c piece.c pipex_posix.c pipex_win32.c random.c san.c search.c square.c uci.c uci2uci.c util.c xboard2uci.c mainloop.h colour.h hash.h ini.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipex.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h xboard2uci.h
dist_doc_DATA = README README1.3 README1.4 README1.4w README1.4w10UCI book_format.html
man6_MANS = polyglot.man
EXTRA_DIST = makefile.gcc makefile.ms polyglot.man polyglot.pod polyglot.spec debian/changelog debian/control debian/docs debian/README debian/compat debian/copyright debian/files debian/polyglot.substvars debian/rules
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
- a perft counter
SYNOPSIS
- polyglot [configfile]
-
- polyglot -ec engine
+ polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en
+ enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg
+ <name>=<value>]* [-uci <name>=<value>]*
polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply]
[-min-game games] [-min-score score] [-only-white] [-only-black] [-uni-
polyglot dump-book [-bin inputfile] -color color [-out outputfile]
- polyglot [configfile] epd-test [-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]
polyglot perft [-fen fen] [-max-depth depth]
ever much slower than other more dedicated programs.
OPTIONS
- When invoked without options or with a config file as argument PolyGlot
- acts as an adapter. The config file format is documented below. The
- default config file is "polyglot.ini".
+ When PolyGlot is invoked as an adapter of in epd-test mode it gets its
+ options from a config file and then from the command line. The default
+ config file is "polyglot.ini" but an alternative one may be optionally
+ included as first argument. The config file format is described below.
- When invoked as
+ The following engine options may be specified on the command line.
+
+ -noini
+ Do not use a config file, even if one was specified on the command
+ line.
+
+ -pg The argument is a string of the form <name>=<value>. This option
+ will set the Polyglot option <name> to <value>.
+
+ -uci
+ The argument is a string of the form <name>=<value>. This option
+ will set the engine option <name> to <value>.
+
+ -ec This is an alias for -pg "EngineCommand=<value>".
+
+ -ed This is an alias for -pg "EngineDir=<value>".
- polyglot -ec engine
+ -en This is an alias for -pg "EngineName=<value>"
- PolyGlot simply starts "engine" and acts as an adapter. No config file
- is used and thus it is expected that all properties will be set by the
- GUI.
+ -hash
+ This is an alias for -uci "Hash=<value>".
+
+ -log
+ This is an alias for -pg "Log=true".
+
+ -lf (default: "polyglot.log")
+ This is an alias for -pg "LogFile=<value>".
+
+ -bk This is an alias for -pg "Book=true" -pg "BookFile=<value>".
When invoked as
polyglot epd-test
- (possibly with a config file as first argument) PolyGlot supports the
- following options
+ (possibly with a config file as first argument) PolyGlot supports
+ besides the generic options described above the following additional
+ options.
-max-depth (default: 63)
Unconditionally stop the search when this depth has been reached.
The characters "#" and ";" serve as comment characters.
- NOTE: There can be spaces in option names or values. Do not use
- quotes. Boolean values are written as "true" or "false".
+ 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
UCI (default: false)
If true PolyGlot will not understand xboard commands.
- Chess960 (default: false)
- Play Chess960 (also called Fischer Random Chess or FRC),
-
MateScore (default: 10000)
Mate score reported to GUI when in xboard mode.
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.
+ SaveSettingsOnExit (default: true)
+ If true then PolyGlot will implement persistence by loading its
+ options from an additional INI file which is specified by the
+ option "SaveFile". At exit PolyGlot will also save its options to
+ this INI file.
+
+ SaveFile (default: <EngineName>.ini)
+ The name of the file from which to take the additional options.
+
Work arounds
Work arounds are identical to options except that they should be used
polyglot epd-test -epd test.epd -max-time 420
- The command line for using the UCI engine "fruit" in a GUI which uses
- the xboard protocol.
+ The command line for using the UCI engine "fruit" with 128M hash in
+ xboard with logging enabled.
- polyglot -ec fruit
+ xboard -fcp "polyglot -noini -log -ec fruit -hash 128"
- The equivalent config file:
+ The equivalent config file would be:
[PolyGlot]
EngineCommand = fruit
+ Log = true
[Engine]
+ Hash=128
EXIT STATUS
PolyGlot always returns 0 on exit.
- 2009-08-13 POLYGLOT(6)
+ 2009-08-31 POLYGLOT(6)
\r
if (move != MoveNone &&\r
move_is_legal(move,board) &&\r
- score/10>option_get_int(Option,"BookTreshold")) {\r
+ score>10*option_get_int(Option,"BookTreshold")) {\r
\r
// pick this move?\r
\r
if (entry->key != board->key) break;\r
\r
move = entry->move;\r
- score = (entry->count*10000)/sum; // 32 bit safe!\r
+ score = (((uint32)entry->count)*((uint32)10000))/sum; // 32 bit safe!\r
\r
- if (score > 0 && move != MoveNone && move_is_legal(move,board)) {\r
- list_add_ex(list,move,score);\r
+ if (move != MoveNone && move_is_legal(move,board)) {\r
+ list_add_ex(list,move,score);\r
}\r
}\r
\r
char move_string[256];\r
list_t list[1];\r
int i;\r
+ int treshold=option_get_int(Option,"BookTreshold");\r
\r
ASSERT(board!=NULL);\r
\r
\r
for(i=0; i<list_size(list); i++){\r
move_to_san(list->move[i],board,move_string,256);\r
- printf(" %6s %5.2f%%\n",move_string,list->value[i]/100.0);\r
+ if(list->value[i]>10*treshold){\r
+ printf(" %6s %5.2f%%\n",move_string,list->value[i]/100.0);\r
+ }else{\r
+ printf(" %6s %5.2f%% (below treshold %4.2f%%)\n",\r
+ move_string,list->value[i]/100.0,treshold/10.0);\r
+ }\r
}\r
+ // this is necessary by the xboard protocol\r
+ printf("\n");\r
}\r
\r
// book_learn_move()\r
#define PACKAGE_NAME "polyglot"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "polyglot 1.4.38b"
+#define PACKAGE_STRING "polyglot 1.4.39b"
/* 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.38b"
+#define PACKAGE_VERSION "1.4.39b"
/* Define to 1 if the C compiler supports function prototypes. */
#define PROTOTYPES 1
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
-#define VERSION "1.4.38b"
+#define VERSION "1.4.39b"
/* Define like PROTOTYPES; this can be used by system headers. */
#define __PROTOTYPES 1
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for polyglot 1.4.38b.
+# Generated by GNU Autoconf 2.61 for polyglot 1.4.39b.
#
# Report bugs to <michel.vandenbergh@uhasselt.be>.
#
# Identity of this package.
PACKAGE_NAME='polyglot'
PACKAGE_TARNAME='polyglot'
-PACKAGE_VERSION='1.4.38b'
-PACKAGE_STRING='polyglot 1.4.38b'
+PACKAGE_VERSION='1.4.39b'
+PACKAGE_STRING='polyglot 1.4.39b'
PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be'
ac_unique_file="mainloop.c"
# 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.38b to adapt to many kinds of systems.
+\`configure' configures polyglot 1.4.39b to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of polyglot 1.4.38b:";;
+ short | recursive ) echo "Configuration of polyglot 1.4.39b:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-polyglot configure 1.4.38b
+polyglot configure 1.4.39b
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
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.38b, which was
+It was created by polyglot $as_me 1.4.39b, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='polyglot'
- VERSION='1.4.38b'
+ VERSION='1.4.39b'
cat >>confdefs.h <<_ACEOF
# 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.38b, which was
+This file was extended by polyglot $as_me 1.4.39b, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-polyglot config.status 1.4.38b
+polyglot config.status 1.4.39b
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([polyglot], [1.4.38b], [michel.vandenbergh@uhasselt.be])
+AC_INIT([polyglot], [1.4.39b], [michel.vandenbergh@uhasselt.be])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([mainloop.c])
AC_CONFIG_HEADER([config.h])
+polyglot (1.4.39b) unstable; urgency=low
+
+ * Refactoring of config file parsing
+
+ * Fix crash bug in epd-test
+
+ * Do not export Chess960. This is handled completely internally.
+
+ * Do not export UCI_Opponent and UCI_Chess960. These are handled internally.
+
+ * PG can now also be comfortably configured through command line options (i.e. without using a config file).
+
+ * Allow quotes in configfile (as in Fonzy Bleumer's PG).
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sun, 23 Aug 2009 21:00:00 +0100
+
+polyglot (1.4.37b) unstable; urgency=low
+
+ * 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.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Fri, 12 Aug 2009 21:00:00 +0100
+
+polyglot (1.4.36b) unstable; urgency=low
+
+ * Bugfix: option = 0/1 was translated incorrectly.
+
+ * EOF received from the engine should now be logged correctly (i.e. after the buffer is empty)
+
+ * Bugfix: Nasty buffer overflow in the macro CONSTRUCT_ARG_STRING.
+
+ * Bugfix: pipex_writeln (win32) was logging at the wrong spot.
+
+ * Log board when an illegal move is received.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Tue, 11 Aug 2009 21:00:00 +0100
+
+polyglot (1.4.35b) unstable; urgency=low
+
+ * New WbWorkAround for silly bug in WB. Depth <=1 clears the engine output window. Why shouldn't an engine be allowed to send info at depth one?
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Thu, 7 Aug 2009 20:00:00 +0100
+
+polyglot (1.4.34b) unstable; urgency=low
+
+ * Allow spaces around "=" in "option =" commands.
+
+ * WbWorkArounds is now true by default.
+
+ * Trying to set a non existent UCI option gives an error.
+
+ * PG will now resign in case of an illegal engine move.
+
+ * More code has been moved into the I/O abstraction layer pipex. This has reduced to win32 dependence of utils.c
+
+ * info strings and unrecognized info lines are relayed to the GUI.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Thu, 6 Aug 2009 20:00:00 +0100
+
+polyglot (1.4.33b) unstable; urgency=low
+
+ * New option: "WbWorkArounds". Currently it blocks options which contain "Draw" in their name from being sent to the GUI. Engines that have such options are Rybka and HIARCS.
+
+ * Bugfix for ASSERT failure in bright. Now another ASSERT failure has appeared which seems to be bright's fault however.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Thu, 6 Aug 2009 20:00:00 +0100
+
+polyglot (1.4.32b) unstable; urgency=low
+
+ * Bugfix: the default setting for RepeatPV had become false again...
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Tue, 4 Aug 2009 14:00:00 +0100
+
+polyglot (1.4.31b) unstable; urgency=low
+
+ * Bugfix: improper handling of vararg function.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sun, 2 Aug 2009 11:00:00 +0100
+
+polyglot (1.4.30b) unstable; urgency=low
+
+ * Some more meaningful error messages added.
+ * Some buffer overflow checks added.
+ * Simplification of strange signal kludge in gui.c.
+ * Removal of obsolete code in engine.c and gui.c. Platform specific code has been abstracted and pushed into pipex_win32.c and pipex_posix.c
+ * The format of the version number has changed once again. Debian was unhappy with the previous one.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sun, 2 Aug 2009 16:00:00 +0100
+
+polyglot (1.4b29) unstable; urgency=low
+
+ * Conversion from C++ to C (suggested by E.M.).
+
+ * More refactoring. The win32 and posix I/O have now a uniform interface (see pipex.h).
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Fri, 31 Jul 2009 10:00:00 +0100
+
+polyglot (1.4b28) unstable; urgency=low
+
+ * Some comments added to explain the exact behaviour of some of the public functions in pipe.cpp.
+ * LineInput now returns a bool which is FALSE in case of EOF.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Fri, 31 Jul 2009 10:00:00 +0100
+
+polyglot (1.4b27) unstable; urgency=low
+
+ * Option "ScoreWhite" : report score from white's point of view (suggested by E.M.).
+
+ * Option "KibitzInterval" : try to wait this many seconds between kibitzes (suggested by E.M.).
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sun, 26 Jul 2009 10:00:00 +0100
+
+polyglot (1.4b26) unstable; urgency=low
+
+ * Contraction of version number.
+
+ * Log if SetProcessAffinityMask is not available (suggested by E.M.).
+
+ * pipe.cpp : Make PipeStruct a proper class with private/public members.
+
+ * Check for EOF in GUI input.
+
+ * pipe.cpp : delay reporting EOF until buffer is empty.
+
+ * Messages from the Engine to PG were not logged in the windows version.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 25 Jul 2009 10:00:00 +0100
+
+polyglot (1.4w10UCIb24) unstable; urgency=low
+
+ * Portability fixes for WIN9X (Eric Mullins).
+
+ * Portability fixes for MSVC++ (Eric Mullins).
+
+ * Default setting of RepeatPV is now true.
+
+ * Do not read data if input buffer is full (windows).
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Mon, 20 Jul 2009 21:00:00 +0100
+
+polyglot (1.4w10UCIb22) unstable; urgency=low
+
+ * Polyglot is now completely poll free...
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 18 Jan 2009 21:00:00 +0100
+
+polyglot (1.4w10UCIb21) unstable; urgency=low
+
+ * Crash bug in memory command fixed
+
+ * Small optimizations
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 18 Jan 2009 21:00:00 +0100
+
+polyglot (1.4w10UCIb20) unstable; urgency=low
+
+ * More refactoring.
+
+ * No more polling for GUI input
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Wed, 28 Jan 2009 21:00:00 +0100
+
+
+polyglot (1.4w10UCIb18) unstable; urgency=low
+
+ * Two new utilities: info-book and dump-book.
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 15 Jan 2009 21:00:00 +0100
+
+polyglot (1.4w10UCIb17) unstable; urgency=low
+
+ * More refactoring. main.cpp is now #ifdef _WIN32 free.
+
+ * The main loop (previously in adapter.cpp) is now in its own file mainloop.cpp.
+
+ * adapter.cpp has been renamed into xboard2uci.cpp. It is #ifdef _WIN32 free.
+
+ * EOF from the engine no longer kills PG. It should now be possible to close an engine and reopen another one (if that ever were useful)
+
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 14 Jan 2009 21:00:00 +0100
+
polyglot (1.4w10UCIb16) unstable; urgency=low
* xboard option commands
* The polyglot options are not exported, so they are now settable by the GUI
- -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 10 Jan 2009 21:00:00 +0100
+ -- Michel Van den Bergh <michel.vandenbergh@uhasselt.be> Sat, 12 Jan 2009 21:00:00 +0100
polyglot (1.4w10UCIb15) unstable; urgency=low
-polyglot_1.4w10UCIb15_i386.deb games extra
+polyglot_1.4.39b_i386.deb games extra
-shlibs:Depends=libgcc1 , libstdc++6 (>= 4.1.1-21), libc6 (>= 2.4)
+shlibs:Depends=libc6 (>= 2.4)
if (!board_from_fen(board,epd)) ASSERT(FALSE);\r
if (!board_to_fen(board,string,StringSize)) ASSERT(FALSE);\r
\r
- engine_send(Engine,"position fen %s");\r
+ engine_send(Engine,"position fen %s",string);\r
\r
// search\r
\r
--- /dev/null
+// includes
+
+#include <stdio.h>
+#include "option.h"
+#include "ini.h"
+#include "string.h"
+#include "util.h"
+#include "errno.h"
+
+// macros
+
+#define StringSize ((int) 4096)
+
+// types
+
+typedef enum {
+ START =0,
+ SECTION_NAME =1,
+ NAME =2,
+ NAME_SPACE =3,
+ START_VALUE =4,
+ VALUE =5,
+ VALUE_SPACE =6,
+ QUOTE_SPACE =7,
+ FINISHED =8,
+} parse_state_t;
+
+// functions
+
+// ini_line_parse()
+
+line_type_t ini_line_parse(const char *line,
+ char *section,
+ char *name,
+ char *value){
+ int i;
+ parse_state_t state=START;
+ int name_index=0;
+ int value_index=0;
+ int section_index=0;
+ int index=0;
+ char c;
+ int type=SYNTAX_ERROR;
+ int spaces=0;
+ bool outer_quote=FALSE;
+ while(state!=FINISHED){
+ c=line[index++];
+// printf("STATE=%d c=[%c]\n",state,c);
+ switch(state){
+ case START:
+ if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ type=EMPTY_LINE;
+ state=FINISHED;
+ }else if(c=='['){
+ state=SECTION_NAME;
+ }else if(c!=' '){
+ name[name_index++]=c;
+ state=NAME;
+ }
+ goto next;
+ break;
+ case NAME:
+ if(c=='='){
+ state=START_VALUE;
+ }else if(c==' '){
+ state=NAME_SPACE;
+ spaces=1;
+ }else if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ type=SYNTAX_ERROR;
+ state=FINISHED;
+ }else{
+ name[name_index++]=c;
+ }
+ goto next;
+ break; // we don't get here
+ case NAME_SPACE:
+ if(c==' '){
+ spaces++;
+ }else if(c=='='){
+ state=START_VALUE;
+ }else if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ type=SYNTAX_ERROR;
+ state=FINISHED;
+ }else{
+ for(i=0;i<spaces;i++){
+ name[name_index++]=' ';
+ }
+ spaces=0;
+ name[name_index++]=c;
+ state=NAME;
+ }
+ goto next;
+ break; // we don't get here
+ case START_VALUE:
+ if(c=='"'){
+ outer_quote=TRUE;
+ spaces=0;
+ state=VALUE_SPACE;
+ }else if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ type=EMPTY_VALUE;
+ state=FINISHED;
+ }else if(c!=' '){
+ value[value_index++]=c;
+ state=VALUE;
+ }
+ goto next;
+ break; // we don't get here
+ case VALUE:
+ if(c=='"'){
+ state=QUOTE_SPACE;
+ spaces=0;
+ }else if(c==' '){
+ state=VALUE_SPACE;
+ spaces=1;
+ }else if((c=='\r' || c=='\n' || c==';' || c=='#'||(c=='\0'))&&
+ !outer_quote){
+ type=NAME_VALUE;
+ state=FINISHED;
+ }else{
+ value[value_index++]=c;
+ }
+ goto next;
+ break; // we don't get here
+ case VALUE_SPACE:
+ if(c==' '){
+ spaces++;
+ }else if((c=='\r' || c=='\n' || c==';' || c=='#'||(c=='\0'))&&
+ !outer_quote){
+ type=NAME_VALUE;
+ state=FINISHED;
+ }else{
+ for(i=0;i<spaces;i++){
+ value[value_index++]=' ';
+ }
+ spaces=0;
+ if(c!='"'){
+ value[value_index++]=c;
+ state=VALUE;
+ }else{
+ state=QUOTE_SPACE;
+ }
+ }
+ goto next;
+ break; // we don't get here
+ case QUOTE_SPACE:
+ if(c==' '){
+ spaces++;
+ }else if(c=='\r' || c=='\n' || c==';' || c=='#'||(c=='\0')){
+ type=NAME_VALUE;
+ state=FINISHED;
+ }else{
+ value[value_index++]='"';
+ for(i=0;i<spaces;i++){
+ value[value_index++]=' ';
+ }
+ spaces=0;
+ if(c!='"'){
+ value[value_index++]=c;
+ state=VALUE;
+ }else{
+ state=QUOTE_SPACE;
+ }
+ }
+ goto next;
+ break; // we don't get here
+ case SECTION_NAME:
+ if(c==']'){
+ type=SECTION;
+ state=FINISHED;
+ }else{
+ section[section_index++]=c;
+ }
+ goto next;
+ break; // we don't get here
+ default:
+ break;
+ }
+ next: if(!c) break;
+ }
+ section[section_index]='\0';
+ name[name_index]='\0';
+ value[value_index]='\0';
+ return type;
+}
+
+// ini_init()
+
+void ini_init(ini_t *ini){
+ memset(ini,0,sizeof(ini_t));
+}
+
+// ini_clear()
+
+void ini_clear(ini_t *ini){
+ int i;
+ ini_entry_t * entry;
+ for(i=0; i< ini->index; i++){
+ entry=ini->entries+i;
+ if(entry->name!=NULL){
+ my_string_clear(&entry->name);
+ }
+ if(entry->value!=NULL){
+ my_string_clear(&entry->value);
+ }
+ if(entry->comment!=NULL){
+ my_string_clear(&entry->comment);
+ }
+ }
+ ini->index=0;
+}
+
+// ini_find()
+
+ini_entry_t *ini_find(ini_t *ini, const char *section, const char* name){
+ int i;
+ ini_entry_t * entry;
+ for(i=0; i< ini->index; i++){
+ entry=ini->entries+i;
+ if(my_string_case_equal(entry->name,name) &&
+ my_string_case_equal(entry->section,section)){
+ return entry;
+ }
+ }
+ return NULL;
+}
+
+// ini_insert()
+
+void ini_insert(ini_t *ini, ini_entry_t *entry){
+ ini_entry_t * ini_entry;
+ ini_entry=ini_find(ini,entry->section,entry->name);
+ if(ini_entry!=NULL){
+ my_string_set(&ini_entry->value,entry->value);
+ }else{
+ if(ini->index>=IniEntriesNb){
+ my_fatal("ini_insert(): too many options\n");
+ }
+ ini_entry=ini->entries+(ini->index++);
+ my_string_set(&ini_entry->value,entry->value);
+ my_string_set(&ini_entry->name,entry->name);
+ my_string_set(&ini_entry->section,entry->section);
+ }
+}
+
+// ini_insert_ex()
+
+void ini_insert_ex(ini_t *ini,
+ const char *section,
+ const char *name,
+ const char *value){
+ ini_entry_t entry[1];
+ memset(entry,0,sizeof(ini_entry_t));
+ my_string_set(&entry->section,section);
+ my_string_set(&entry->name,name);
+ my_string_set(&entry->value,value);
+ ini_insert(ini,entry);
+ my_string_clear(&entry->section);
+ my_string_clear(&entry->name);
+ my_string_clear(&entry->value);
+}
+
+// ini_parse()
+
+int ini_parse(ini_t *ini, const char *filename){
+ char name[StringSize];
+ char value[StringSize];
+ char section[StringSize];
+ char line[StringSize];
+ ini_entry_t entry[1];
+ line_type_t result;
+ const char *current_section=NULL;
+ FILE *f;
+ int line_nr=0;
+ my_string_set(¤t_section,"Main");
+ memset(entry,0,sizeof(ini_entry_t));
+ f=fopen(filename,"r");
+ if(!f) {
+ // my_fatal("ini_parse(): Can't open file \"%s\": %s\n",
+ // filename,
+ // strerror(errno));
+ // For now fail silently
+ return -1;
+ }
+ while(TRUE){
+ if(!fgets(line,StringSize,f)){
+ break;
+ }
+ line_nr++;
+ result=ini_line_parse(line,section,name,value);
+ if(result==SECTION){
+ my_string_set(¤t_section,section);
+ }else if(result==NAME_VALUE){
+ ini_insert_ex(ini,current_section,name,value);
+ }else if(result==SYNTAX_ERROR){
+ my_fatal("ini_parse(): Syntax error in \"%s\": line %d\n",
+ filename,
+ line_nr);
+
+ }else { // empty line
+ }
+
+ }
+ fclose(f);
+ return 0;
+
+}
+
+// ini_disp()
+
+void ini_disp(ini_t *ini){
+ int i;
+ my_log("POLYGLOT Current options\n");
+ for(i=0;i<ini->index;i++){
+ my_log("POLYGLOT [%s] %s=\"%s\"\n",
+ (ini->entries)[i].section,
+ (ini->entries)[i].name,
+ (ini->entries)[i].value);
+ }
+}
+
+// ini_start_iter()
+
+void ini_start_iter(ini_t *ini){
+ ini->iter=0;
+}
+
+// ini_next()
+
+ini_entry_t * ini_next(ini_t *ini){
+ ASSERT(ini->iter<=ini->index);
+ if(ini->iter==ini->index){
+ return NULL;
+ }
+ return &ini->entries[ini->iter++];
+}
+
+// ini_create_pg()
+
--- /dev/null
+// ini.h
+
+#ifndef INI_H
+#define INI_H
+
+// defines
+
+#define IniEntriesNb 256
+
+// includes
+
+#include "option.h"
+
+// types
+
+typedef struct {
+ const char *section;
+ const char *name;
+ const char *value;
+ const char *comment;
+} ini_entry_t;
+
+typedef struct {
+ ini_entry_t entries[IniEntriesNb];
+ int index;
+ int iter;
+} ini_t;
+
+typedef enum {
+ SYNTAX_ERROR,
+ EMPTY_LINE,
+ NAME_VALUE,
+ EMPTY_VALUE,
+ SECTION
+} line_type_t;
+
+// functions
+
+extern void ini_init (ini_t *ini);
+extern void ini_clear (ini_t *ini);
+extern int ini_parse (ini_t *ini, const char *filename);
+extern void ini_disp (ini_t *ini);
+extern void ini_insert (ini_t *ini, ini_entry_t *entry);
+extern void ini_insert_ex (ini_t *ini,
+ const char *section,
+ const char *name,
+ const char *value);
+extern void ini_start_iter (ini_t *ini);
+extern ini_entry_t *ini_next (ini_t *ini);
+extern ini_entry_t *ini_find (ini_t *ini,
+ const char *section,
+ const char *name);
+extern line_type_t ini_line_parse (const char *line,
+ char *section,
+ char *name,
+ char *value);
+
+#endif // !defined INI_H
+
+// end of ini.h
#include "util.h"\r
#include "xboard2uci.h"\r
#include "uci2uci.h"\r
+#include "ini.h"\r
\r
// constants\r
\r
\r
-static const char * const Version = "1.4.38b";\r
+static const char * const Version = "1.4.39b";\r
static const char * const HelpMessage = "\\r
SYNTAX\n\\r
-* polyglot [configfile]\n\\r
-* polyglot -ec enginecommand\n\\r
+* polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg <name>=<value>]* [-uci <name>=<value>]*\n\\r
* polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]\n\\r
* polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]\n\\r
* polyglot info-book [-bin inputfile] [-exact]\n\\r
* polyglot dump-book [-bin inputfile] -color color [-out outputfile]\n\\r
-* polyglot [configfile] epd-test [-epd inputfile] [-min-depth depth] [-max-depth depth] [-min-time time] [-max-time time] [-depth-delta delta]\n\\r
+* polyglot [configfile] epd-test [engineoptions] [-epd inputfile] [-min-depth depth] [-max-depth depth] [-min-time time] [-max-time time] [-depth-delta delta]\n\\r
* polyglot perft [-fen fen] [-max-depth depth]\\r
";\r
\r
\r
// prototypes\r
\r
-static void parse_option ();\r
static void init_book ();\r
-static bool parse_line (char line[], char * * name_ptr, char * * value_ptr);\r
static void stop_search ();\r
\r
// functions\r
\r
+// arg_shift_left()\r
+\r
+void arg_shift_left(char **argv, int index){\r
+ int i;\r
+ for(i=index; argv[i]!=NULL; i++){\r
+ argv[i]=argv[i+1];\r
+ }\r
+}\r
+\r
+\r
+void write_ini(const char *filename,\r
+ option_list_t *pg_options,\r
+ option_list_t *uci_options){\r
+ option_t *opt;\r
+ char tmp[StringSize];\r
+ FILE *f;\r
+ f=fopen(filename,"w");\r
+ if(!f){\r
+ my_fatal("ini_create_pg(): Cannot open %s for writing.\n",filename);\r
+ }\r
+ fprintf(f,"[PolyGlot]\n");\r
+ option_start_iter(pg_options);\r
+ while((opt=option_next(pg_options))){\r
+ if(opt->mode & XBOARD){\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
+ tmp[sizeof(tmp)-1]='\0';\r
+ fprintf(f,"%s",tmp);\r
+ }\r
+ }\r
+ fprintf(f,"[Engine]\n");\r
+ option_start_iter(uci_options);\r
+ while((opt=option_next(uci_options))){\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
+ tmp[sizeof(tmp)-1]='\0';\r
+ fprintf(f,"%s",tmp);\r
+ }\r
+ fclose(f);\r
+}\r
+\r
+\r
// main()\r
\r
int main(int argc, char * argv[]) {\r
-\r
+ ini_t ini[1];\r
+ ini_entry_t *entry;\r
+ char *arg;\r
+ int arg_index;\r
+ bool NoIni;\r
+ \r
if(!DEBUG){\r
printf("PolyGlot %s by Fabien Letouzey.\n",Version);\r
}else{\r
attack_init();\r
\r
hash_init();\r
- \r
+\r
my_random_init();\r
\r
- // build book\r
+ // book utilities\r
\r
if (argc >= 2 && my_string_equal(argv[1],"make-book")) {\r
book_make(argc,argv);\r
return EXIT_SUCCESS;\r
}\r
\r
- if (argc >= 2 && my_string_equal(argv[1],"merge-book")) {\r
- book_merge(argc,argv);\r
- return EXIT_SUCCESS;\r
- }\r
-\r
- if (argc >= 2 && my_string_equal(argv[1],"dump-book")) {\r
- book_dump(argc,argv);\r
- return EXIT_SUCCESS;\r
- }\r
+ if (argc >= 2 && my_string_equal(argv[1],"dump-book")) {\r
+ book_dump(argc,argv);\r
+ return EXIT_SUCCESS;\r
+ }\r
+ \r
+ if (argc >= 2 && my_string_equal(argv[1],"info-book")) {\r
+ book_info(argc,argv);\r
+ return EXIT_SUCCESS;\r
+ }\r
\r
- if (argc >= 2 && my_string_equal(argv[1],"info-book")) {\r
- book_info(argc,argv);\r
- return EXIT_SUCCESS;\r
- }\r
+ // perft\r
\r
if (argc >= 2 && my_string_equal(argv[1],"perft")) {\r
do_perft(argc,argv);\r
return EXIT_SUCCESS;\r
}\r
+\r
+ // what is the config file? This is very hacky right now?\r
+\r
+ // Do we want a config file at all?\r
+\r
+ arg_index=0;\r
+ NoIni=FALSE;\r
+ while((arg=argv[arg_index++])){\r
+ if(my_string_equal(arg,"-noini")){\r
+ NoIni=TRUE;\r
+ break;\r
+ }\r
+ }\r
+ arg_shift_left(argv,arg_index-1);\r
+ if(NoIni){\r
+ option_set(Option,"OptionFile","<empty>");\r
+ }\r
+\r
+ // Ok see if first argument looks like config file\r
+ \r
+ if(argv[1] && !my_string_equal(argv[1],"epd-test") && !(argv[1][0]=='-')){\r
+ // first argument must be config file\r
+ if(!NoIni){\r
+ option_set(Option,"OptionFile",argv[1]);\r
+ }else{\r
+ // ignore\r
+ }\r
+ arg_shift_left(argv,1);\r
+ }else{\r
+ // Config file is the default.\r
+ // This has already been set above or in "option_init_pg"\r
+ }\r
+ \r
+ ini_init(ini);\r
+\r
+ // if we use a config file: load it!\r
\r
- if (argc >= 3 && my_string_equal(argv[1],"-ec")) {\r
- option_set(Option,"EngineCommand",argv[2]);\r
- engine_open(Engine);\r
- if(!engine_active(Engine)){\r
- my_fatal("Could not start \"%s\"\n",\r
- option_get(Option,"EngineCommand"));\r
+ if(!my_string_equal(option_get_string(Option,"OptionFile"),"<empty>")){\r
+ if(ini_parse(ini,option_get_string(Option,"OptionFile"))){\r
+ my_fatal("main(): Can't open file \"%s\": %s\n",\r
+ option_get_string(Option,"OptionFile"),\r
+ strerror(errno));\r
+ }\r
+ }\r
+\r
+ // parse the command line and merge options\r
+\r
+ arg_index=1;\r
+ while((arg=argv[arg_index])){\r
+// int i=1;\r
+// char *arg1;\r
+// printf("arg_index=%d\n",arg_index);\r
+// while((arg1=argv[i++])){\r
+// printf("arg=%s ",arg1);\r
+// }\r
+// printf("\n");\r
+ if(my_string_equal(arg,"-ec") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"PolyGlot","EngineCommand",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ if(my_string_equal(arg,"-ed") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"PolyGlot","EngineDir",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
}\r
- Init=TRUE;\r
- gui_init(GUI);\r
- uci_open(Uci,Engine);\r
- if (my_string_equal(option_get_string(Option,"EngineName"),"<empty>")) {\r
- option_set(Option,"EngineName",Uci->name);\r
+ if(my_string_equal(arg,"-en") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"PolyGlot","EngineName",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
}\r
- mainloop();\r
- return EXIT_SUCCESS; \r
+ if(my_string_equal(arg,"-log")){\r
+ ini_insert_ex(ini,"PolyGlot","Log","true");\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ if(my_string_equal(arg,"-lf") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"PolyGlot","LogFile",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ if(my_string_equal(arg,"-hash") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"Engine","Hash",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ if(my_string_equal(arg,"-bk") && argv[arg_index+1]){\r
+ ini_insert_ex(ini,"PolyGlot","Book","true");\r
+ ini_insert_ex(ini,"PolyGlot","BookFile",argv[arg_index+1]);\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ if((my_string_equal(arg,"-pg")||my_string_equal(arg,"-uci")) &&\r
+ argv[arg_index]){\r
+ int ret;\r
+ char section[StringSize];\r
+ char name[StringSize];\r
+ char value[StringSize];\r
+ ret=ini_line_parse(argv[arg_index++],section,name,value);\r
+ if(ret==NAME_VALUE){\r
+ if(my_string_equal(arg,"-pg")){\r
+ ini_insert_ex(ini,"PolyGlot",name,value);\r
+ }else{\r
+ ini_insert_ex(ini,"Engine",name,value);\r
+ }\r
+ }\r
+ arg_shift_left(argv,arg_index);\r
+ arg_shift_left(argv,arg_index);\r
+ continue;\r
+ }\r
+ arg_index++;\r
+ }\r
+\r
+ // extract PG options\r
+ // this sets both the default and the value\r
+ \r
+ option_from_ini(Option,ini,"polyglot");\r
+ \r
+ // start logging if required\r
+ \r
+ if (option_get_bool(Option,"Log")) {\r
+ my_log_open(option_get_string(Option,"LogFile"));\r
}\r
+\r
+ // log welcome stuff\r
+ \r
+ if(!DEBUG){\r
+ my_log("PolyGlot %s by Fabien Letouzey\n",Version);\r
+ }else{\r
+ my_log("PolyGlot %s by Fabien Letouzey (debug build)\n",Version);\r
+ } \r
+ my_log("POLYGLOT *** START ***\n");\r
+ my_log("POLYGLOT INI file \"%s\"\n",option_get_string(Option,"OptionFile"));\r
+\r
+ // start engine\r
+ \r
+ engine_open(Engine);\r
+ if(!engine_active(Engine)){\r
+ my_fatal("Could not start \"%s\"\n",option_get(Option,"EngineCommand"));\r
+ }\r
+\r
+ // switch to UCI mode if necessary\r
+ \r
+ if (option_get_bool(Option,"UCI")) {\r
+ my_log("POLYGLOT *** Switching to UCI mode ***\n");\r
+ }\r
+\r
+ // initialize uci parsing and send uci command. Parse options and wait\r
+ // for uciok\r
\r
- // read options\r
+ uci_open(Uci,Engine);\r
\r
+ // get engine name from engine if not supplied in config file\r
\r
- if (argc == 2) option_set(Option,"OptionFile",argv[1]); // HACK for compatibility\r
+ if (my_string_equal(option_get_string(Option,"EngineName"),"<empty>")) {\r
+ option_set(Option,"EngineName",Uci->name);\r
+ }\r
+\r
+ // if there is a save file: load it!\r
\r
- parse_option(); // HACK: also launches the engine\r
+ if(my_string_equal(option_get_string(Option,"SaveFile"),"<empty>")){\r
+ char tmp[StringSize];\r
+ snprintf(tmp,sizeof(tmp),"%s.ini",\r
+ option_get_string(Option,"EngineName"));\r
+ tmp[sizeof(tmp)-1]='\0';\r
+ option_set(Option,"SaveFile",tmp);\r
+ }\r
+ if(option_get_bool(Option,"SaveSettingsOnExit")){\r
+ my_log("POLYGLOT SaveFile=%s\n",option_get_string(Option,"SaveFile"));\r
+ if(ini_parse(ini,option_get_string(Option,"SaveFile"))){\r
+ my_log("POLYGLOT Unable to open SaveFile\n"); \r
+ }\r
+ }\r
+ // start if it was enabled in the SaveFile\r
+ \r
+ if (option_get_bool(Option,"Log")) {\r
+ my_log_close();\r
+ my_log_open(option_get_string(Option,"LogFile"));\r
+ }\r
+ // remind the user of the options that are now in effect\r
+ \r
+ ini_disp(ini);\r
+\r
+\r
+\r
+ // done initializing\r
+ \r
+ Init = TRUE;\r
+ \r
+ // collect engine options from config file(s) and send to engine\r
+ \r
+ ini_start_iter(ini);\r
+ while((entry=ini_next(ini))){\r
+ if(my_string_case_equal(entry->section,"engine")){\r
+ // also updates value in Uci->option\r
+ uci_send_option(Uci,entry->name,"%s",entry->value);\r
+ // since this comes from the ini file, also update default\r
+ option_set_default(Uci->option,entry->name,entry->value);\r
+ //to get a decent display in winboard_x we need to now if an engine really is doing multipv analysis\r
+ // "multipv 1" in the pv is meaningless,f.i. toga sends that all the time\r
+ //therefore check if MultiPV is set to a decent value in the polyglot ini file\r
+ if(my_string_case_equal(entry->name,"MultiPV") &&\r
+ atoi(entry->value)>1){\r
+ Uci->multipv_mode=TRUE;\r
+ }\r
+ }\r
+ }\r
+ \r
\r
// EPD test\r
\r
- if (argc >= 2 && my_string_equal(argv[1],"epd-test")){\r
- epd_test(argc,argv);\r
- return EXIT_SUCCESS;\r
- }else if(argc >= 3 && my_string_equal(argv[2],"epd-test")){\r
- epd_test(argc-1,argv+1);\r
+ if (argv[1] && my_string_equal(argv[1],"epd-test")){\r
+ argc=0;\r
+ while((arg=argv[argc++]));\r
+ epd_test(argc-1,argv);\r
return EXIT_SUCCESS;\r
}\r
\r
- if (argc >= 3) my_fatal("Too many arguments\n");\r
+ // Anything that hasn't been parsed yet is a syntax error\r
+\r
+ if(argv[1]){\r
+ my_fatal("main(): Unknown option: %s\n",argv[1]);\r
+ }\r
\r
\r
init_book();\r
}\r
}\r
\r
-// parse_option()\r
-\r
-static void parse_option() {\r
-\r
- const char * file_name;\r
- FILE * file;\r
- char line[256];\r
- char * name, * value;\r
- file_name = option_get_string(Option,"OptionFile");\r
- \r
- file = fopen(file_name,"r");\r
- if (file == NULL) {\r
- my_fatal("Can't open file \"%s\": %s\n",file_name,strerror(errno));\r
- }\r
- \r
- // PolyGlot options (assumed first)\r
- \r
- while (TRUE) {\r
- \r
- if (!my_file_read_line(file,line,256)) {\r
- my_fatal("parse_option(): missing [Engine] section\n");\r
- }\r
- \r
- if (my_string_case_equal(line,"[engine]")) break;\r
- \r
- if (parse_line(line,&name,&value)) {\r
- option_set(Option,name,value);\r
- option_set_default(Option,name,value);\r
- }\r
- }\r
- \r
- if (option_get_bool(Option,"Log")) {\r
- my_log_open(option_get_string(Option,"LogFile"));\r
- }\r
- \r
- if(!DEBUG){\r
- my_log("PolyGlot %s by Fabien Letouzey\n",Version);\r
- }else{\r
- my_log("PolyGlot %s by Fabien Letouzey (debug build)\n",Version);\r
- }\r
-\r
- my_log("POLYGLOT *** START ***\n");\r
- my_log("POLYGLOT INI file \"%s\"\n",file_name);\r
- engine_open(Engine);\r
- if(!engine_active(Engine)){\r
- my_fatal("Could not start \"%s\"\n",option_get(Option,"EngineCommand"));\r
- }\r
-\r
- if (option_get_bool(Option,"UCI")) {\r
- my_log("POLYGLOT *** Switching to UCI mode ***\n");\r
- }\r
- uci_open(Uci,Engine);\r
- Init = TRUE;\r
- while (my_file_read_line(file,line,256)) {\r
- if (line[0] == '[') my_fatal("parse_option(): unknown section %s\n",line);\r
- if (parse_line(line,&name,&value)) {\r
- uci_send_option(Uci,name,"%s",value);\r
- //to get a decent display in winboard_x we need to now if an engine really is doing multipv analysis\r
- // "multipv 1" in the pv is meaningless,f.i. toga sends that all the time\r
- //therefore check if MultiPV is set to a decent value in the polyglot ini file\r
- if(my_string_case_equal(name,"MultiPV") && atoi(value)>1) Uci->multipv_mode=TRUE;\r
- }\r
- }\r
- if (my_string_equal(option_get_string(Option,"EngineName"),"<empty>")) {\r
- option_set(Option,"EngineName",Uci->name);\r
- }\r
- \r
- fclose(file);\r
-}\r
-\r
-// parse_line()\r
-\r
-static bool parse_line(char line[], char * * name_ptr, char * * value_ptr) {\r
- \r
- char * ptr;\r
- char * name, * value;\r
- \r
- ASSERT(line!=NULL);\r
- ASSERT(name_ptr!=NULL);\r
- ASSERT(value_ptr!=NULL);\r
- \r
- // remove comments\r
- \r
- ptr = strchr(line,';');\r
- if (ptr != NULL) *ptr = '\0';\r
- \r
- ptr = strchr(line,'#');\r
- if (ptr != NULL) *ptr = '\0';\r
- \r
- // split at '='\r
- \r
- ptr = strchr(line,'=');\r
- if (ptr == NULL) return FALSE;\r
- \r
- name = line;\r
- value = ptr+1;\r
- \r
- // cleanup name\r
- \r
- while (*name == ' ') name++; // remove leading spaces\r
- \r
- while (ptr > name && ptr[-1] == ' ') ptr--; // remove trailing spaces\r
- *ptr = '\0';\r
- \r
- if (*name == '\0') return FALSE;\r
- \r
- // cleanup value\r
- \r
- ptr = &value[strlen(value)]; // pointer to string terminator\r
- \r
- while (*value == ' ') value++; // remove leading spaces\r
- \r
- while (ptr > value && ptr[-1] == ' ') ptr--; // remove trailing spaces\r
- *ptr = '\0';\r
- \r
- if (*value == '\0') return FALSE;\r
- \r
- // end\r
- \r
- *name_ptr = name;\r
- *value_ptr = value;\r
- \r
- return TRUE;\r
-}\r
\r
// quit()\r
\r
engine_close(Engine);\r
\r
}\r
+ if(option_get_bool(Option,"SaveSettingsOnExit")){\r
+ write_ini(option_get_string(Option,"SaveFile"),Option,Uci->option);\r
+ }\r
my_log("POLYGLOT Calling exit\n");\r
exit(EXIT_SUCCESS);\r
}\r
#include "engine.h"\r
#include "gui.h"\r
#include "option.h"\r
+//#include "ini.h"\r
#include "xboard2uci.h"\r
#include "uci2uci.h"\r
\r
\r
// options\r
\r
+ { "SaveSettingsOnExit","check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, \r
+ { "SaveFile", "string","0","0", "<empty>" , NULL,0,NNB, PG|XBOARD},\r
+ \r
{ "EngineName", "string","0","0", "<empty>" , NULL,0,NNB, PG}, \r
{ "EngineDir", "string","0","0", "." , NULL,0,NNB, PG}, \r
{ "EngineCommand", "string","0","0", "<empty>" , NULL,0,NNB, PG}, \r
{ "UseNice", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI}, \r
{ "NiceValue", "spin", "0","20", "5" , NULL,0,NNB, PG|XBOARD|UCI}, \r
\r
- { "Chess960", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, \r
+ { "Chess960", "check","0","0", "false" , NULL,0,NNB, PG}, \r
\r
{ "Resign", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, \r
{ "ResignMoves", "spin","0","10000", "3" , NULL,0,NNB, PG|XBOARD}, \r
opt = option_find(option,name);\r
if (opt == NULL) return FALSE;\r
\r
- opt->default_=my_strdup(value);\r
+ my_string_set(&opt->default_,value);\r
\r
if (UseDebug) my_log("POLYGLOT OPTION DEFAULT SET \"%s\" -> \"%s\"\n",opt->name,opt->default_);\r
\r
return NULL;\r
}\r
\r
+// option_start_iter()\r
+\r
void option_start_iter(option_list_t *option){\r
option->iter=0;\r
}\r
\r
+// option_next()\r
+\r
option_t * option_next(option_list_t *option){\r
ASSERT(option->iter<=option->option_nb);\r
if(option->iter==option->option_nb){\r
option->mode=0;\r
}\r
\r
+// option_clear()\r
+\r
void option_clear(option_list_t *option){\r
int i;\r
for (i = 0; i < option->option_nb; i++) {\r
option->option_nb=0;\r
}\r
\r
+// option_from_ini()\r
+\r
+void option_from_ini(option_list_t *option,\r
+ ini_t *ini,\r
+ const char *section){\r
+ ini_entry_t *entry;\r
+ ini_start_iter(ini);\r
+ while((entry=ini_next(ini))){\r
+ option_set(option,entry->name,entry->value);\r
+ option_set_default(option,entry->name,entry->value);\r
+ }\r
+}\r
+\r
// end of option.cpp\r
\r
// includes\r
\r
#include "util.h"\r
+#include "ini.h"\r
\r
// defines\r
\r
extern int option_get_int (option_list_t *option, const char var[]);\r
extern const char * option_get_string (option_list_t *option, const char var[]);\r
\r
+extern void option_from_ini (option_list_t *option,\r
+ ini_t *ini,\r
+ const char *section);\r
+\r
extern bool option_is_ok (const option_list_t *option);\r
extern option_t * option_find (option_list_t *option, const char var[]);\r
extern void option_clear (option_list_t *option);\r
.\" ========================================================================
.\"
.IX Title "POLYGLOT 6"
-.TH POLYGLOT 6 "2009-08-13" "" ""
+.TH POLYGLOT 6 "2009-08-31" "" ""
.SH "NAME"
PolyGlot \- Winboard protocol to UCI protocol adapter
\- book engine for Polyglot books
\- a perft counter
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
-polyglot [configfile]
-.PP
-polyglot \-ec engine
+polyglot [configfile] [\-noini] [\-ec engine] [\-ed enginedirectory] [\-en enginename] [\-log] [\-lf logfile] [\-hash value] [\-bk book] [\-pg <name>=<value>]* [\-uci <name>=<value>]*
.PP
polyglot make-book [\-pgn inputfile] [\-bin outputfile] [\-max\-ply ply] [\-min\-game games] [\-min\-score score] [\-only\-white] [\-only\-black] [\-uniform]
.PP
.PP
polyglot dump-book [\-bin inputfile] \-color color [\-out outputfile]
.PP
-polyglot [configfile] epd-test [\-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"
is however much slower than other more dedicated programs.
.SH "OPTIONS"
.IX Header "OPTIONS"
-When invoked without options or with a config file as argument PolyGlot
-acts as an adapter. The config file format is documented below. The
-default config file is \*(L"polyglot.ini\*(R".
-.PP
-When invoked as
-.Sh "polyglot \-ec engine"
-.IX Subsection "polyglot -ec engine"
-PolyGlot simply starts \*(L"engine\*(R" and acts as an adapter. No config file
-is used and thus it is expected that all properties will be set by the
-\&\s-1GUI\s0.
+When PolyGlot is invoked as an adapter of in epd-test mode it gets its
+options from a config file and then from the command line. The
+default config file is \*(L"polyglot.ini\*(R" but an alternative one may be
+optionally included as first argument. The config file format is
+described below.
+.PP
+The following engine options may be specified on the command line.
+.IP "\fB\-noini\fR" 4
+.IX Item "-noini"
+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 <name>=<value>. This option will
+set the Polyglot option <name> to <value>.
+.IP "\fB\-uci\fR" 4
+.IX Item "-uci"
+The argument is a string of the form <name>=<value>. This option will
+set the engine option <name> to <value>.
+.IP "\fB\-ec\fR" 4
+.IX Item "-ec"
+This is an alias for \-pg \*(L"EngineCommand=<value>\*(R".
+.IP "\fB\-ed\fR" 4
+.IX Item "-ed"
+This is an alias for \-pg \*(L"EngineDir=<value>\*(R".
+.IP "\fB\-en\fR" 4
+.IX Item "-en"
+This is an alias for \-pg \*(L"EngineName=<value>\*(R"
+.IP "\fB\-hash\fR" 4
+.IX Item "-hash"
+This is an alias for \-uci \*(L"Hash=<value>\*(R".
+.IP "\fB\-log\fR" 4
+.IX Item "-log"
+This is an alias for \-pg \*(L"Log=true\*(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=<value>\*(R".
+.IP "\fB\-bk\fR" 4
+.IX Item "-bk"
+This is an alias for \-pg \*(L"Book=true\*(R" \-pg \*(L"BookFile=<value>\*(R".
.PP
When invoked as
.Sh "polyglot make-book"
When invoked as
.Sh "polyglot epd-test"
.IX Subsection "polyglot epd-test"
-(possibly with a config file as first argument) PolyGlot supports the following
-options
+(possibly with a config file as first argument) PolyGlot supports
+besides the generic options described above the following additional
+options.
.IP "\fB\-max\-depth\fR (default: 63)" 4
.IX Item "-max-depth (default: 63)"
Unconditionally stop the search when this depth has
.PP
The characters \*(L"#\*(R" and \*(L";\*(R" serve as comment characters.
.PP
-\&\s-1NOTE:\s0 There can be spaces in option names or values. Do not use
-quotes. Boolean values are written as \*(L"true\*(R" or \*(L"false\*(R".
+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.
.Sh "[PolyGlot] section"
.IX Subsection "[PolyGlot] section"
This section is used by PolyGlot only. The engine is unaware of these
.IP "\fB\s-1UCI\s0\fR (default: false)" 4
.IX Item "UCI (default: false)"
If true PolyGlot will not understand xboard commands.
-.IP "\fBChess960\fR (default: false)" 4
-.IX Item "Chess960 (default: false)"
-Play Chess960 (also called Fischer Random Chess or \s-1FRC\s0),
.IP "\fBMateScore\fR (default: 10000)" 4
.IX Item "MateScore (default: 10000)"
-Mate score reported to \s-1GUI\s0 when in xboard mode.
+Mate score reported to \s-1GUI\s0 when in xboard mode.
.IP "\fBBook\fR (default: false)" 4
.IX Item "Book (default: false)"
Indicates whether a PolyGlot book should be used. This has no effect
.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 "\fBSaveSettingsOnExit\fR (default: true)" 4
+.IX Item "SaveSettingsOnExit (default: true)"
+If true then PolyGlot will implement persistence by loading its
+options from an additional \s-1INI\s0 file which is specified by the option
+\&\*(L"SaveFile\*(R". At exit PolyGlot will also save its options to this \s-1INI\s0
+file.
+.IP "\fBSaveFile\fR (default: <EngineName>.ini)" 4
+.IX Item "SaveFile (default: <EngineName>.ini)"
+The name of the file from which to take the additional options.
.Sh "Work arounds"
.IX Subsection "Work arounds"
Work arounds are identical to options except that they should be used
\& polyglot epd\-test \-epd test.epd \-max\-time 420
.Ve
.PP
-The command line for using the \s-1UCI\s0 engine \*(L"fruit\*(R" in a \s-1GUI\s0 which uses the
-xboard protocol.
+The command line for using the \s-1UCI\s0 engine \*(L"fruit\*(R" with 128M hash in xboard with logging enabled.
.PP
.Vb 1
-\& polyglot \-ec fruit
+\& xboard \-fcp "polyglot \-noini \-log \-ec fruit \-hash 128"
.Ve
.PP
-The equivalent config file:
+The equivalent config file would be:
.PP
-.Vb 3
+.Vb 5
\& [PolyGlot]
\& EngineCommand = fruit
+\& Log = true
\& [Engine]
+\& Hash=128
.Ve
.SH "EXIT STATUS"
.IX Header "EXIT STATUS"
=head1 SYNOPSIS
-polyglot [configfile]
-
-polyglot -ec engine
+polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg <name>=<value>]* [-uci <name>=<value>]*
polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]
polyglot dump-book [-bin inputfile] -color color [-out outputfile]
-polyglot [configfile] epd-test [-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]
polyglot perft [-fen fen] [-max-depth depth]
=head1 OPTIONS
-When invoked without options or with a config file as argument PolyGlot
-acts as an adapter. The config file format is documented below. The
-default config file is "polyglot.ini".
+When PolyGlot is invoked as an adapter of in epd-test mode it gets its
+options from a config file and then from the command line. The
+default config file is "polyglot.ini" but an alternative one may be
+optionally included as first argument. The config file format is
+described below.
-When invoked as
+The following engine options may be specified on the command line.
+
+=over 4
+
+=item B<-noini>
+
+Do not use a config file, even if one was specified on the command line.
+
+=item B<-pg>
+
+The argument is a string of the form <name>=<value>. This option will
+set the Polyglot option <name> to <value>.
+
+=item B<-uci>
+
+The argument is a string of the form <name>=<value>. This option will
+set the engine option <name> to <value>.
+
+=item B<-ec>
+
+This is an alias for -pg "EngineCommand=<value>".
+
+=item B<-ed>
+
+This is an alias for -pg "EngineDir=<value>".
+
+=item B<-en>
+
+This is an alias for -pg "EngineName=<value>"
-=head2 polyglot -ec engine
+=item B<-hash>
-PolyGlot simply starts "engine" and acts as an adapter. No config file
-is used and thus it is expected that all properties will be set by the
-GUI.
+This is an alias for -uci "Hash=<value>".
+
+=item B<-log>
+
+This is an alias for -pg "Log=true".
+
+=item B<-lf> (default: "polyglot.log")
+
+This is an alias for -pg "LogFile=<value>".
+
+=item B<-bk>
+
+This is an alias for -pg "Book=true" -pg "BookFile=<value>".
+
+=back
When invoked as
=head2 polyglot epd-test
-(possibly with a config file as first argument) PolyGlot supports the following
-options
+(possibly with a config file as first argument) PolyGlot supports
+besides the generic options described above the following additional
+options.
=over 4
The characters "#" and ";" serve as comment characters.
-NOTE: There can be spaces in option names or values. Do not use
-quotes. Boolean values are written as "true" or "false".
+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.
=head2 [PolyGlot] section
If true PolyGlot will not understand xboard commands.
-=item B<Chess960> (default: false)
-
-Play Chess960 (also called Fischer Random Chess or FRC),
-
=item B<MateScore> (default: 10000)
-Mate score reported to GUI when in xboard mode.
+Mate score reported to GUI when in xboard mode.
=item B<Book> (default: false)
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<SaveSettingsOnExit> (default: true)
+
+If true then PolyGlot will implement persistence by loading its
+options from an additional INI file which is specified by the option
+"SaveFile". At exit PolyGlot will also save its options to this INI
+file.
+
+=item B<SaveFile> (default: <EngineName>.ini)
+
+The name of the file from which to take the additional options.
=back
polyglot epd-test -epd test.epd -max-time 420
-The command line for using the UCI engine "fruit" in a GUI which uses the
-xboard protocol.
+The command line for using the UCI engine "fruit" with 128M hash in xboard with logging enabled.
- polyglot -ec fruit
+ xboard -fcp "polyglot -noini -log -ec fruit -hash 128"
-The equivalent config file:
+The equivalent config file would be:
[PolyGlot]
EngineCommand = fruit
+ Log = true
[Engine]
-
+ Hash=128
=head1 EXIT STATUS
Summary: A Winboard protocol to UCI protocol adapter
Name: polyglot
-Version: 1.4.38b
+Version: 1.4.39b
Release: 1
License: GPL
Group: Amusement/Games
CONSTRUCT_ARG_STRING(format,string);\r
\r
fprintf(stderr,"%s",string);\r
- if (LogFile != NULL) fprintf(LogFile,"%s",string);\r
+ my_log("POLYGLOT %s",string);\r
\r
if (Error) { // recursive error\r
my_log("POLYGLOT *** RECURSIVE ERROR ***\n");\r
\r
return tv->tv_sec + tv->tv_usec * 1E-6;\r
#else\r
- return (double) GetTickCount() / 1000.0; // we can do better here:-)\r
+ struct _timeb timeptr;\r
+ _ftime(&timeptr);\r
+ return(timeptr.time+((double)timeptr.millitm)/1000.0);\r
+// return (double) GetTickCount() / 1000.0; // we can do better here:-)\r
#endif\r
}\r
\r
// includes\r
\r
#include <stdio.h>\r
+#include <sys/types.h>\r
+#include <sys/timeb.h>\r
\r
// defines\r
\r
option_start_iter(Uci->option);\r
while((opt=option_next(Uci->option))){\r
if(my_string_case_equal(opt->name,"UCI_AnalyseMode")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_Opponent")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_Chess960")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShowCurrLine")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShowRefutations")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShredderbasesPath")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_SetPositionValue")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_DrawOffers")) continue;\r
if(my_string_case_equal(opt->name,"Ponder")) continue;\r
if(my_string_case_equal(opt->name,"Hash")) continue;\r
if(my_string_case_equal(opt->name,"NalimovPath")) continue;\r