+=========1.4.54b================\r
+- More graceful handling of engine crashes.\r
+- New EngineCommand is now passed through wordexp on Linux.\r
=========1.4.53b================\r
- Multipv code by HGM. \r
=========1.4.52b================\r
DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS COPYING \
- ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \
- install-sh missing
+ ChangeLog INSTALL NEWS TODO depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
NAME
PolyGlot - Winboard protocol to UCI protocol adapter
- book engine for Polyglot books
- - a collection of utilities for creating and analyzing open-
- ing books
+ - a collection of utilities for creating and analyzing
+ opening books
- a utility for analyzing epd files
- a perft counter
<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-
- form]
+ [-min-game games] [-min-score score] [-only-white] [-only-black]
+ [-uniform]
polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]
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. Nor-
- mally 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.
+ Normally 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
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 "fea-
- ture 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
+ "feature 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
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 docu-
- mented here
+ defacto standard non-proprietary opening book format. It is fully
+ documented here
http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html
.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 fur-
- thermore it can merge two such binary books into a third one.
+ 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 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 posi-
- tion) in which the given color makes only book moves and the other
+ 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).
Since a PolyGlot book is built up from positions and not lines there
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 argu-
- ments specify when to stop the search in any given position.
-
- Perft counts
+ record the number of times the right best move was found. The
+ arguments specify when to stop the search in any given position.
+ 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 how-
- ever much slower than other more dedicated programs.
+ up to a given depth. PolyGlot can perform such perft counts. It is
+ however much slower than other more dedicated programs.
OPTIONS
When PolyGlot is invoked as an adapter of in epd-test mode it gets its
When invoked as
- polyglot make-book
-
+ polyglot make-book
PolyGlot supports the following options
-pgn (default: "book.pgn")
When invoked as
- polyglot merge-book
-
+ polyglot merge-book
PolyGlot supports the following options
-in1
When invoked as
- polyglot dump-book
-
+ polyglot dump-book
PolyGlot supports the following options
-bin (default: book.bin)
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 iso-
- lated ones. Note that this takes a very long time.
+ Attempt to count the provably unreachable positions among the
+ isolated 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.
When invoked as
- polyglot perft
-
+ polyglot perft
PolyGlot supports the following options
-fen (default: starting position)
The characters "#" and ";" serve as comment characters.
- 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
+ Initial and final white space is stripped from option names and values.
+ If you need to use characters which have a special meaning to PolyGlot
+ (these are ';#[]=\') you should quote them by preceding them with '\'.
+ "Quoting" other characters in this way has no effect. In particular the
+ use of '\' as a path separator in windows should normally not affected.
+ [PolyGlot] section
This section is used by PolyGlot only. The engine is unaware of these
options. The list of available options is detailed below.
EngineCommand
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".
+ directory will be "EngineDir". On Linux the EngineCommand is passed
+ to wordexp so that shell quoting rules and expansions are applied.
+ On Windows the EngineCommand is simply passed to CreateProcess
+ which does its own shell like processing.
SettingsDir (default: $HOME/.polyglot on Linux; ".\_PG" on Windows)
The directory where ini files are stored for engines that are
move are ignored.
ResignScore (default: 600)
- This is the score in centipawns that will trigger resign "count-
- ing".
+ This is the score in centipawns that will trigger resign
+ "counting".
ShowPonder (default: true)
Show search information during engine pondering. Turning this off
move).
KibitzCommand (default: "tellall")
- xboard command to use for kibitzing, normally "tellall" for kibitz-
- ing or "tellothers" for whispering.
+ xboard command to use for kibitzing, normally "tellall" for
+ kibitzing or "tellothers" for whispering.
KibitzDelay (default: 5)
How many seconds to wait before starting kibitzing. This has an
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 cur-
- rent directory does not matter.
+ directory. Of course, full path can be used in which case the
+ current directory does not matter.
BookRandom (default: true)
Select moves according to their weights in the book. If false the
If true then PolyGlot restricts the options it sends to those that
are potentially useful for WinBoard.
- 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 ver-
- sions 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
+ versions of PolyGlot. You are strongly recommended to contact the
+ author of faulty software and truly fix the problem.
PolyGlot supports the following work arounds:
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 pon-
- der do not declare the option. This work around lets PolyGlot know
- that they can ponder.
+ "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.
SyncStop (default: false)
- 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.
+ 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.
PromoteWorkAround (default: false)
Some engines do not specify a promotion piece, e.g. they send
to the way kibitzing is implemented, KibitzMove is disabled in that
case.
- [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 cor-
- rect. It will be replaced by PolyGlot with "setoption name OwnBook
+ NOTE: use INI syntax, not UCI. For example "OwnBook = true" is
+ correct. It will be replaced by PolyGlot with "setoption name OwnBook
value true" at engine startup.
Standard UCI options are
- 2009-09-11 POLYGLOT(6)
+ 2009-11-30 POLYGLOT(6)
#define PACKAGE_NAME "polyglot"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "polyglot 1.4.53b"
+#define PACKAGE_STRING "polyglot 1.4.54b"
/* 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.53b"
+#define PACKAGE_VERSION "1.4.54b"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
-#define VERSION "1.4.53b"
+#define VERSION "1.4.54b"
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for polyglot 1.4.53b.
+# Generated by GNU Autoconf 2.63 for polyglot 1.4.54b.
#
# Report bugs to <michel.vandenbergh@uhasselt.be>.
#
# Identity of this package.
PACKAGE_NAME='polyglot'
PACKAGE_TARNAME='polyglot'
-PACKAGE_VERSION='1.4.53b'
-PACKAGE_STRING='polyglot 1.4.53b'
+PACKAGE_VERSION='1.4.54b'
+PACKAGE_STRING='polyglot 1.4.54b'
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.53b to adapt to many kinds of systems.
+\`configure' configures polyglot 1.4.54b 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.53b:";;
+ short | recursive ) echo "Configuration of polyglot 1.4.54b:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-polyglot configure 1.4.53b
+polyglot configure 1.4.54b
generated by GNU Autoconf 2.63
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.53b, which was
+It was created by polyglot $as_me 1.4.54b, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='polyglot'
- VERSION='1.4.53b'
+ VERSION='1.4.54b'
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.53b, which was
+This file was extended by polyglot $as_me 1.4.54b, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-polyglot config.status 1.4.53b
+polyglot config.status 1.4.54b
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_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.53b], [michel.vandenbergh@uhasselt.be])
+AC_INIT([polyglot], [1.4.54b], [michel.vandenbergh@uhasselt.be])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([mainloop.c])
AC_CONFIG_HEADER([config.h])
FINISHED =8,
} parse_state_t;
+// variables
+
+const char *ini_specials=";\\#[]=";
+
// functions
// ini_line_parse()
char c;
int type=SYNTAX_ERROR;
int spaces=0;
- bool outer_quote=FALSE;
+ bool quoted;
while(state!=FINISHED){
c=line[index++];
-// printf("STATE=%d c=[%c]\n",state,c);
+ quoted=FALSE;
+ if(c=='\\'){
+ if(strchr(ini_specials,line[index])){
+ quoted=TRUE;
+ c=line[index++];
+ }
+ }
+ // printf("STATE=%d quoted=%d c=[%c]\n",state,quoted,c);
switch(state){
case START:
- if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ if(!quoted && ((c==';')||(c=='#')||(c=='\r')||
+ (c=='\n')||(c=='\0'))){
type=EMPTY_LINE;
state=FINISHED;
- }else if(c=='['){
+ }else if(!quoted && c=='['){
state=SECTION_NAME;
- }else if(c!=' '){
+ }else if(quoted || c!=' '){
name[name_index++]=c;
state=NAME;
}
goto next;
break;
case NAME:
- if(c=='='){
+ if(!quoted && c=='='){
state=START_VALUE;
- }else if(c==' '){
+ }else if(!quoted && c==' '){
state=NAME_SPACE;
spaces=1;
- }else if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ }else if(!quoted && ((c==';')||(c=='#')||(c=='\r')
+ ||(c=='\n')||(c=='\0'))){
type=SYNTAX_ERROR;
state=FINISHED;
}else{
goto next;
break; // we don't get here
case NAME_SPACE:
- if(c==' '){
+ if(!quoted && c==' '){
spaces++;
- }else if(c=='='){
+ }else if(!quoted && c=='='){
state=START_VALUE;
- }else if((c==';')||(c=='#')||(c=='\r')||(c=='\n')||(c=='\0')){
+ }else if(!quoted && ((c==';')||(c=='#')||(c=='\r')||
+ (c=='\n')||(c=='\0'))){
type=SYNTAX_ERROR;
state=FINISHED;
}else{
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')){
+ if(!quoted && ((c==';')||(c=='#')||(c=='\r')||
+ (c=='\n')||(c=='\0'))){
type=EMPTY_VALUE;
state=FINISHED;
- }else if(c!=' '){
+ }else if(quoted || 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==' '){
+ if(!quoted && c==' '){
state=VALUE_SPACE;
spaces=1;
- }else if((c=='\r' || c=='\n' || c==';' || c=='#'||(c=='\0'))&&
- !outer_quote){
+ }else if(!quoted && ((c=='\r' || c=='\n' || c==';' ||
+ c=='#'||(c=='\0')))){
type=NAME_VALUE;
state=FINISHED;
}else{
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==' '){
+ if(!quoted && c==' '){
spaces++;
- }else if(c=='\r' || c=='\n' || c==';' || c=='#'||(c=='\0')){
+ }else if(!quoted && ((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;
- }
+ value[value_index++]=c;
+ state=VALUE;
}
goto next;
break; // we don't get here
case SECTION_NAME:
- if(c==']'){
+ if(!quoted && c==']'){
type=SECTION;
state=FINISHED;
}else{
}else if(result==NAME_VALUE){
ini_insert_ex(ini,current_section,name,value);
}else if(result==SYNTAX_ERROR){
- // Dirty hack.
- // The "not found" triggers xboard to show the error.
- my_fatal("ini_parse(): Syntax error in \"%s\": line %d (not found)\n",
+ my_fatal("ini_parse(): Syntax error in \"%s\": line %d\n",
filename,
line_nr);
char *name,
char *value);
+extern const char * ini_specials;
+
#endif // !defined INI_H
// end of ini.h
// constants\r
\r
\r
-static const char * const Version = "1.4.53b";\r
+static const char * const Version = "1.4.54b";\r
static const char * const HelpMessage = "\\r
SYNTAX\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
\r
static void write_ini(const char *filename,\r
ini_t *ini){\r
+ // TODO Quote, dequote\r
const char *quote;\r
ini_entry_t *entry;\r
char tmp[StringSize];\r
+ char tmp1[StringSize];\r
+ char tmp2[StringSize];\r
FILE *f;\r
time_t t=time(NULL);\r
f=fopen(filename,"w");\r
ini_start_iter(ini);\r
while((entry=ini_next(ini))){\r
if(my_string_case_equal(entry->section,"polyglot")){\r
- if(strchr(entry->value,';')|| strchr(entry->value,'#')|| strchr(entry->value,'"')){\r
- quote="\"";\r
- }else{\r
- quote="";\r
- }\r
- snprintf(tmp,sizeof(tmp),"%s=%s%s%s\n",\r
- entry->name,\r
- quote,\r
- entry->value,\r
- quote);\r
+ my_quote(tmp1,entry->name,ini_specials);\r
+ my_quote(tmp2,entry->value,ini_specials);\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
+ tmp1,\r
+ tmp2);\r
tmp[sizeof(tmp)-1]='\0';\r
fprintf(f,"%s",tmp);\r
}\r
fprintf(f,"[Engine]\n");\r
ini_start_iter(ini);\r
while((entry=ini_next(ini))){\r
- if(my_string_case_equal(entry->section,"engine")){\r
- if(strchr(entry->value,';')|| strchr(entry->value,'#')|| strchr(entry->value,'"')){\r
- quote="\"";\r
- }else{\r
- quote="";\r
- }\r
- snprintf(tmp,sizeof(tmp),"%s=%s%s%s\n",\r
- entry->name,\r
- quote,\r
- entry->value,\r
- quote);\r
+ if(my_string_case_equal(entry->section,"engine")){\r
+ my_quote(tmp1,entry->name,ini_specials);\r
+ my_quote(tmp2,entry->value,ini_specials);\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
+ tmp1,\r
+ tmp2);\r
tmp[sizeof(tmp)-1]='\0';\r
fprintf(f,"%s",tmp);\r
}\r
\r
Init = FALSE;\r
\r
+ gui_init(GUI);\r
+\r
util_init();\r
option_init_pg();\r
\r
// start engine\r
\r
engine_open(Engine);\r
+\r
if(!engine_active(Engine)){\r
my_fatal("Could not start \"%s\"\n",option_get(Option,"EngineCommand"));\r
}\r
// initialize uci parsing and send uci command. \r
// Parse options and wait for uciok\r
\r
+ // XXX\r
uci_open(Uci,Engine);\r
\r
option_set_default(Option,"EngineName",Uci->name);\r
}\r
}\r
\r
- gui_init(GUI);\r
+ // gui_init(GUI);\r
mainloop();\r
return EXIT_SUCCESS; \r
}\r
ini_t ini[1];\r
int ret;\r
ini_init(ini);\r
- my_log("POLYGLOT Setting PolyGlot option %s=\"%s\"\n",name,value);\r
+ my_log("POLYGLOT Setting PolyGlot option \"%s=%s\"\n",name,value);\r
if(my_string_case_equal(name,"Save")){\r
ret=my_mkdir(option_get(Option,"SettingsDir"));\r
if(ret){\r
\r
my_log("POLYGLOT *** QUIT ***\n");\r
\r
- if (Init) {\r
+ if (Init && !Engine->pipex->quit_pending) {\r
\r
stop_search();\r
+ Engine->pipex->quit_pending=TRUE;\r
engine_send(Engine,"quit");\r
my_log("POLYGLOT Closing engine\n");\r
engine_close(Engine);\r
\r
void mainloop() {\r
char string[StringSize];\r
+ my_log("POLYGLOT *** Mainloop started ***\n");\r
mainloop_init();\r
while (!engine_eof(Engine)) {\r
// process buffered lines\r
char szWriteBuffer[LINE_INPUT_MAX_CHAR];
DWORD dwWriteIndex;
const char *name;
+ const char *command;
+ BOOL quit_pending;
} pipex_t;
io_t io[1];
pid_t pid;
int state;
+ bool quit_pending;
+ const char *command;
} pipex_t;
#endif
#include <string.h>
#include <errno.h>
+#include <wordexp.h>
+#include <sys/wait.h>
#include "pipex.h"
// constants
char * ptr;
char * argv[256];
int from_child[2], to_child[2];
+ wordexp_t p;
+ int i,ret;
pipex->pid=-1;
pipex->io->name=name;
+ pipex->quit_pending=FALSE;
+ pipex->command=command;
if(command==NULL){
pipex->io->in_fd = STDIN_FILENO;
}else{
// parse the command line and create the argument list
-
+#if 0
if (strlen(command) >= StringSize) my_fatal("pipex_open(): buffer overflow\n");
strcpy(string,command);
argc = 0;
}
argv[argc] = NULL;
-
+#else
+ //printf("command=[%s]\n",command);
+ //Buffer overflow alert
+ ret=wordexp(command, &p, 0);
+ if(ret!=0){
+ my_fatal("pipex_open(): %s: Unable to parse command.\n",command);
+ }
+ argc = p.we_wordc;
+ if(argc>=256-2){
+ my_fatal("pipex_open(): %s: Too many arguments.\n",command);
+ }
+ for(i=0;i<argc;i++){
+ argv[i] = p.we_wordv[i];
+ }
+ // int i;
+ //for(i=0;i<argc;i++){
+ // printf("[%s]",argv[i]);
+ //}
+ //printf("\n");
+ argv[argc] = NULL;
+#endif
// create the pipes
if (pipe(from_child) == -1) {
// execvp() only returns when an error has occured
- my_fatal("engine_open(): execvp(): %s: %s\n",command,strerror(errno));
+ my_fatal("engine_open(): execvp(): %s: %s\n",argv[0],strerror(errno));
} else { // pid > 0
// pipex_exit()
void pipex_exit(pipex_t *pipex){
- // NOOP for now
+ int status;
+ my_log("POLYGLOT Waiting for child process to exit.\n");
+ waitpid(pipex->pid,&status,0);
+ if(WIFEXITED(status)){
+ if(pipex->quit_pending){
+ my_log("POLYGLOT Child exited with status %d.\n",WEXITSTATUS(status));
+ }else{
+ // Suppress further messages.
+ pipex->quit_pending=TRUE;
+ my_fatal("pipex_exit(): %s: child exited with status %d.\n",pipex->command,WEXITSTATUS(status));
+ }
+ }else if(WIFSIGNALED(status)){
+ if(pipex->quit_pending){
+ my_log("POLYGLOT pipex_exit(): %s: child terminated with signal %d.\n",pipex->command,WTERMSIG(status));
+ }else{
+ // Suppress further messages.
+ pipex->quit_pending=TRUE;
+ my_fatal("pipex_exit(): %s: child terminated with signal %d.\n",pipex->command,WTERMSIG(status));
+ }
+ }
return;
}
char *szCurrentDir;
pipex->state=0;
pipex->name=szName;
+ pipex->command=szProcFile;
+ pipex->quit_pending=FALSE;
pipex->hProcess=NULL;
if (szProcFile == NULL) {
pipex->hInput = GetStdHandle(STD_INPUT_HANDLE);
my_fatal("pipex_open(): cannot change directory: %s\n",
strerror(errno));
}
- if(CreateProcess(NULL,
+ if(CreateProcess(NULL,
(LPSTR) szProcFile,
NULL,
NULL,
DWORD lpexit;
CloseHandle(pipex->hInput);
CloseHandle(pipex->hOutput);
-
+ if(!pipex->quit_pending){
+ // suppress further errors
+ pipex->quit_pending=TRUE;
+ my_fatal("pipex_exit(): %s: child exited unexpectedly.\n",pipex->command);
+ }
if(GetExitCodeProcess(pipex->hProcess,&lpexit)){
if(lpexit==STILL_ACTIVE)
//must be java,hammer it down!
-.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
.\"
.\" 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
. 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 (.Sh), items (.Ip), and index
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
-.if \nF \{\
+.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
-.\"
-.\" For nroff, turn off justification. Always turn off hyphenation; it makes
-.\" way too many mistakes in technical documents.
-.hy 0
-.if n .na
+.el \{\
+. de IX
+..
+.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
.\" ========================================================================
.\"
.IX Title "POLYGLOT 6"
-.TH POLYGLOT 6 "2009-09-11" "" ""
+.TH POLYGLOT 6 "2009-11-30" "" ""
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
.SH "NAME"
PolyGlot \- Winboard protocol to UCI protocol adapter
\- book engine for Polyglot books
.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"
-.Sh "PolyGlot as adapter and book engine"
+.SS "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.
.PP
\&\s-1NOTE:\s0 Not all options are exported, only those that make sense in the
given mode.
-.Sh "Book making utilities"
+.SS "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
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).
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
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.
-.Sh "Epd test mode"
+.SS "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.
-.Sh "Perft counts"
+.SS "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
.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>.
+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>.
+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"
This is an alias for \-pg \*(L"OnlyWbOptions=<value>\*(R".
.PP
When invoked as
-.Sh "polyglot make-book"
+.SS "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.
.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.
.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
-.Sh "polyglot merge-book"
+.SS "polyglot merge-book"
.IX Subsection "polyglot merge-book"
PolyGlot supports the following options
.IP "\fB\-in1\fR" 4
.PP
When invoked
as
-.Sh "polyglot dump-book"
+.SS "polyglot dump-book"
.IX Subsection "polyglot dump-book"
PolyGlot supports the following options
.IP "\fB\-bin\fR (default: book.bin)" 4
.PP
When invoked
as
-.Sh "polyglot info-book"
+.SS "polyglot info-book"
.IX Subsection "polyglot info-book"
PolyGlot supports the following options
.IP "\fB\-bin\fR (default: book.bin)" 4
.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
-.Sh "polyglot epd-test"
+.SS "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
Minimal search time when the search is stopped using \*(L"\-depth\-delta\*(R".
.PP
When invoked as
-.Sh "polyglot perft"
+.SS "polyglot perft"
.IX Subsection "polyglot perft"
PolyGlot supports the following
options
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]
\& ...
.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.
-.Sh "[PolyGlot] section"
+Initial and final white space is stripped from option names and
+values. If you need to use characters which have a special meaning to
+PolyGlot (these are ';#[]=\e') you should quote them by preceding them
+with '\e'. \*(L"Quoting\*(R" other characters in this way has no effect. In
+particular the use of '\e' as a path separator in windows should
+normally not affected.
+.SS "[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.
.IX Item "EngineCommand"
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".
+directory will be \*(L"EngineDir\*(R". On Linux the EngineCommand is passed
+to wordexp so that shell quoting rules and expansions are applied.
+On Windows the EngineCommand is simply passed to CreateProcess which
+does its own shell like processing.
.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)"
.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.
.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
.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.
+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"
+are potentially useful for WinBoard.
+.SS "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
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.
-.Sh "[Engine] section"
+Due to the way kibitzing is implemented, KibitzMove is disabled in that case.
+.SS "[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
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
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"
.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<fabien_letouzey(at)hotmail.com>
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.
+Initial and final white space is stripped from option names and
+values. If you need to use characters which have a special meaning to
+PolyGlot (these are ';#[]=\') you should quote them by preceding them
+with '\'. "Quoting" other characters in this way has no effect. In
+particular the use of '\' as a path separator in windows should
+normally not affected.
=head2 [PolyGlot] section
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".
+directory will be "EngineDir". On Linux the EngineCommand is passed
+to wordexp so that shell quoting rules and expansions are applied.
+On Windows the EngineCommand is simply passed to CreateProcess which
+does its own shell like processing.
=item B<SettingsDir> (default: $HOME/.polyglot on Linux; ".\_PG" on Windows)
Summary: A Winboard protocol to UCI protocol adapter
Name: polyglot
-Version: 1.4.53b
+Version: 1.4.54b
Release: 1
License: GPL
Group: Amusement/Games
// Handle the case that the engine is really a WB engine somewhat gracefully.\r
if((strstr(string,"Illegal") || strstr(string,"Error"))\r
&&strstr(string,"uci")){\r
- my_fatal("uci_open(): Not an UCI engine (not found).\n");\r
+ my_fatal("uci_open(): Not an UCI engine.\n");\r
}\r
event = uci_parse(uci,string);\r
} while (!engine_eof(Engine) && (event & EVENT_UCI) == 0);\r
\r
#include "main.h"\r
#include "util.h"\r
+#include "gui.h"\r
\r
// macros\r
\r
\r
CONSTRUCT_ARG_STRING(format,string);\r
\r
- fprintf(stderr,"%s",string);\r
my_log("POLYGLOT %s",string);\r
+ // This should be gui_send but this does not work.\r
+ // Why?\r
+\r
+ fprintf(stderr,"tellusererror POLYGLOT: %s",string);\r
\r
if (Error) { // recursive error\r
my_log("POLYGLOT *** RECURSIVE ERROR ***\n");\r
exit(EXIT_FAILURE);\r
// abort();\r
} else {\r
- Error = TRUE;\r
- quit();\r
+ Error = TRUE;\r
+ quit();\r
}\r
}\r
\r
}\r
\r
\r
+void my_dequote(char *out, const char *in, const char *special){\r
+ const char *p; \r
+ char *q;\r
+ char c;\r
+ p=in;\r
+ q=out;\r
+ while((c=*(p++))){\r
+ if(c=='\\' && strchr(special,*p)){\r
+ *(q++)=*(p++);\r
+ }else{\r
+ *(q++)=c;\r
+ }\r
+ }\r
+ *q='\0';\r
+}\r
+\r
+void my_quote(char *out, const char *in, const char *special){\r
+ const char *p;\r
+ char *q;\r
+ char c;\r
+ p=in;\r
+ q=out;\r
+ while(q-out< StringSize-2 && (c=*(p++))){\r
+ if(c=='\\'){\r
+ if(*p!=0 && strchr(special,*p)){\r
+ *(q++)='\\';\r
+ }\r
+ }else if(strchr(special,c)){\r
+ *(q++)='\\';\r
+ }\r
+ *(q++)=c;\r
+ }\r
+ *q='\0';\r
+}\r
+\r
\r
\r
extern char * my_error();\r
\r
+extern void my_dequote (char *out, \r
+ const char *in, \r
+ const char *special);\r
+extern void my_quote (char *out, \r
+ const char *in, \r
+ const char *special);\r
+\r
#endif // !defined UTIL_H\r
\r
// end of util.h\r