+=========1.4w10UCIb16===========\r
+- xboard options commands\r
+- correction of handling of combo boxes in UCI protocol\r
+- "gui-mode". It is now possible to run PG without config file\r
+- The polyglot options are not exported, so they are now settable by the GUI\r
=========1.4w10UCIb15===========\r
- Due to refactoring time stamps in Windows would be written twice. \r
This has been fixed. \r
SYNOPSIS
polyglot [configfile]
+ polyglot -ec engine
+
polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply]
[-min-game games] [-min-score score] [-only-white] [-only-black] [-uni-
form]
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.
+
+ Options which normally appear in the [PolyGlot] section of the config
+ file (see below) are exported as options with their name prefixed by
+ "Polyglot". This makes it easy to filter them in the GUI.
+
+ NOTE: Not all options are exported, only those that make sense in the
+ given mode.
+
Book making utilities
PolyGlot supports the "PolyGlot opening book format". This is the
When invoked as
+ polyglot -ec engine
+
+ 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.
+
+ When invoked as
+
polyglot make-book
PolyGlot supports the following options
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.
+
Book (default: false)
Indicates whether a PolyGlot book should be used. This has no
effect on the engine own book (which can be controlled with the UCI
book. Remember that PolyGlot is unaware of whether the engine is
itself using a book or not.
- Chess960 (default: false)
- Play Chess960 (also called Fischer Random Chess or FRC),
-
- MateScore (default: 10000)
- Mate score reported to GUI when in xboard mode.
-
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.
- NOTE: When using PolyGlot with a UCI GUI this parameter can be set
- via the UCI option "Polyglot BookFile".
-
BookRandom (default: true)
Select moves according to their weights in the book. If false the
move with the highest weight is selected.
- 2009-01-10 POLYGLOT(6)
+ 2009-01-13 POLYGLOT(6)
Better check for legality of arguments (i.e. stuff after [configfile]).
-Implementation of new wb/xb options
-GUI mode
-Allow buttons in UCI mode
-Set book [none] instead of nothing as it is now.
-Implementation of Marc Lacrosse's utility
\ No newline at end of file
+Implementation of Marc Lacrosse's utility
static void send_board (int extra_move);\r
static void send_pv ();\r
\r
+static void send_xboard_options ();\r
\r
static void learn (int result);\r
\r
option_set("UCI","true");\r
return;\r
}else{\r
- if(!book_is_open() && option_get_bool("Book")){\r
- // restore old behaviour in xboard mode\r
- // missing book is fatal\r
- my_fatal("xboard_step(): can't open file \"%s\": %s\n",\r
- option_get_string("BookFile"),strerror(errno));\r
- }\r
//uci_send_isready(Uci); // In UCI mode this done by the GUI\r
//Grrr...Toga can fixes the number of threads after "isready"\r
//So we delay "isready" \r
\r
} else if (match(string,"protover *")) {\r
\r
- XB->proto_ver = atoi(Star[0]);\r
- ASSERT(XB->proto_ver>=2);\r
-\r
- gui_send(GUI,"feature done=0");\r
-\r
- gui_send(GUI,"feature analyze=1");\r
- gui_send(GUI,"feature colors=0");\r
- gui_send(GUI,"feature draw=1");\r
- gui_send(GUI,"feature ics=1");\r
- gui_send(GUI,"feature myname=\"%s\"",option_get_string("EngineName"));\r
- gui_send(GUI,"feature name=1");\r
- gui_send(GUI,"feature pause=0");\r
- gui_send(GUI,"feature ping=1");\r
- gui_send(GUI,"feature playother=1");\r
- gui_send(GUI,"feature reuse=1");\r
- gui_send(GUI,"feature san=0");\r
- gui_send(GUI,"feature setboard=1");\r
- gui_send(GUI,"feature sigint=0");\r
- gui_send(GUI,"feature sigterm=0");\r
- gui_send(GUI,"feature time=1");\r
- gui_send(GUI,"feature usermove=1");\r
- if (XB->has_feature_memory){\r
- gui_send(GUI,"feature memory=1");\r
- }\r
- if (XB->has_feature_smp){\r
- gui_send(GUI,"feature smp=1");\r
- }\r
- if (XB->has_feature_egt){\r
- // TODO: support for other types of table bases\r
- gui_send(GUI,"feature egt=\"nalimov\"");\r
- }\r
-\r
- if (uci_option_exist(Uci,"UCI_Chess960")) {\r
- gui_send(GUI,"feature variants=\"normal,fischerandom\"");\r
- } else {\r
- gui_send(GUI,"feature variants=\"normal\"");\r
- }\r
- gui_send(GUI,"feature done=1"); // moved from engine_step\r
-\r
- \r
- //if (Uci->ready) xboard_send(XBoard,"feature done=1");\r
-\r
- // otherwise "feature done=1" will be sent when the engine is ready\r
+ send_xboard_options();\r
\r
} else if (match(string,"quit")) {\r
my_log("POLYGLOT *** \"quit\" from GUI ***\n");\r
\r
gui_send(GUI,"Error (unknown command): %s",string);\r
\r
+ } else if (match(string,"option *=*")){\r
+ char *name=Star[0];\r
+ char *value=Star[1];\r
+ if(match(name, "Polyglot *")){\r
+ char *pg_name=Star[0];\r
+ polyglot_set_option(pg_name,value);\r
+ }else{\r
+ start_protected_command();\r
+ engine_send(Engine,"setoption name %s value %s",name,value);\r
+ end_protected_command();\r
+ }\r
+ } else if (match(string,"option *")){\r
+ char *name=Star[0];\r
+ start_protected_command();\r
+ engine_send(Engine,"setoption name %s",name);\r
+ end_protected_command();\r
} else if (XB->has_feature_smp && match(string,"cores *")){\r
int cores=atoi(Star[0]);\r
if(cores>=1){\r
}\r
}\r
\r
+// format_xboard_option_line\r
+\r
+void format_xboard_option_line(char * option_line, option_t *opt){\r
+ int j;\r
+ char option_string[StringSize];\r
+ strcpy(option_line,"");\r
+ strcat(option_line,"feature option=\"");\r
+ if(opt->mode&PG){\r
+ strcat(option_line,"Polyglot ");\r
+ }\r
+ sprintf(option_string,"%s",opt->name);\r
+ strcat(option_line,option_string);\r
+ sprintf(option_string," -%s",opt->type);\r
+ strcat(option_line,option_string);\r
+ if(strcmp(opt->type,"button") && strcmp(opt->type,"combo")){\r
+ if(strcmp(opt->type,"check")){\r
+ sprintf(option_string," %s",opt->default_);\r
+ }else{\r
+ sprintf(option_string," %d",\r
+ strcmp(opt->default_,"true")?0:1);\r
+ }\r
+ strcat(option_line,option_string);\r
+ }\r
+ if(!strcmp(opt->type,"spin")){\r
+ sprintf(option_string," %s",opt->min);\r
+ strcat(option_line,option_string);\r
+ }\r
+ if(!strcmp(opt->type,"spin")){\r
+ sprintf(option_string," %s",opt->max);\r
+ strcat(option_line,option_string);\r
+ }\r
+ for(j=0;j<opt->var_nb;j++){\r
+ if(!strcmp(opt->var[j],opt->default_)){\r
+ sprintf(option_string," *%s",opt->var[j]);\r
+ }else{\r
+ sprintf(option_string," %s",opt->var[j]);\r
+ }\r
+ strcat(option_line,option_string);\r
+ if(j!=opt->var_nb-1){\r
+ strcat(option_line," ///");\r
+ }\r
+ }\r
+ strcat(option_line,"\"");\r
+}\r
+\r
+// send_xboard_options\r
+\r
+static void send_xboard_options(){\r
+ int i;\r
+ char option_line[StringSize]="";\r
+ option_t *p=Option;\r
+ const char * name;\r
+ XB->proto_ver = atoi(Star[0]);\r
+ ASSERT(XB->proto_ver>=2);\r
+ \r
+ gui_send(GUI,"feature done=0");\r
+ \r
+ gui_send(GUI,"feature analyze=1");\r
+ gui_send(GUI,"feature colors=0");\r
+ gui_send(GUI,"feature draw=1");\r
+ gui_send(GUI,"feature ics=1");\r
+ gui_send(GUI,"feature myname=\"%s\"",option_get_string("EngineName"));\r
+ gui_send(GUI,"feature name=1");\r
+ gui_send(GUI,"feature pause=0");\r
+ gui_send(GUI,"feature ping=1");\r
+ gui_send(GUI,"feature playother=1");\r
+ gui_send(GUI,"feature reuse=1");\r
+ gui_send(GUI,"feature san=0");\r
+ gui_send(GUI,"feature setboard=1");\r
+ gui_send(GUI,"feature sigint=0");\r
+ gui_send(GUI,"feature sigterm=0");\r
+ gui_send(GUI,"feature time=1");\r
+ gui_send(GUI,"feature usermove=1");\r
+ if (XB->has_feature_memory){\r
+ gui_send(GUI,"feature memory=1");\r
+ }else{\r
+ gui_send(GUI,"feature memory=0");\r
+ }\r
+ if (XB->has_feature_smp){\r
+ gui_send(GUI,"feature smp=1");\r
+ }else{\r
+ gui_send(GUI,"feature smp=0");\r
+ }\r
+ if (XB->has_feature_egt){\r
+ // TODO: support for other types of table bases\r
+ gui_send(GUI,"feature egt=\"nalimov\"");\r
+ }else{\r
+ gui_send(GUI,"feature egt=\"\"");\r
+ }\r
+ \r
+ if (uci_option_exist(Uci,"UCI_Chess960")) {\r
+ gui_send(GUI,"feature variants=\"normal,fischerandom\"");\r
+ } else {\r
+ gui_send(GUI,"feature variants=\"normal\"");\r
+ }\r
+ \r
+ for(i=0;i<Uci->option_nb;i++){\r
+ if(!strcmp(Uci->option[i].name,PolyglotBookFile)) continue;\r
+ if(my_string_case_equal(Uci->option[i].name,"UCI_AnalyseMode")) continue;\r
+ if(my_string_case_equal(Uci->option[i].name,"Ponder")) continue;\r
+ if(my_string_case_equal(Uci->option[i].name,"Hash")) continue;\r
+ if(my_string_case_equal(Uci->option[i].name,"NalimovPath")) continue;\r
+ if((name=uci_thread_option(Uci))!=NULL && my_string_case_equal(Uci->option[i].name,name)) continue;\r
+ format_xboard_option_line(option_line,Uci->option+i);\r
+\r
+ gui_send(GUI,"%s",option_line);\r
+\r
+ }\r
+ while(p->name){\r
+ if(p->mode &XBOARD){\r
+ format_xboard_option_line(option_line,p);\r
+ gui_send(GUI,"%s",option_line);\r
+ }\r
+ p++;\r
+ } \r
+ gui_send(GUI,"feature done=1"); \r
+ \r
+}\r
+\r
// comp_move()\r
\r
static void comp_move(int move) {\r
#define PACKAGE_NAME "polyglot"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "polyglot 1.4w10UCIb15"
+#define PACKAGE_STRING "polyglot 1.4w10UCIb16"
/* 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.4w10UCIb15"
+#define PACKAGE_VERSION "1.4w10UCIb16"
/* 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.4w10UCIb15"
+#define VERSION "1.4w10UCIb16"
/* 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.4w10UCIb15.
+# Generated by GNU Autoconf 2.61 for polyglot 1.4w10UCIb16.
#
# Report bugs to <michel.vandenbergh@uhasselt.be>.
#
# Identity of this package.
PACKAGE_NAME='polyglot'
PACKAGE_TARNAME='polyglot'
-PACKAGE_VERSION='1.4w10UCIb15'
-PACKAGE_STRING='polyglot 1.4w10UCIb15'
+PACKAGE_VERSION='1.4w10UCIb16'
+PACKAGE_STRING='polyglot 1.4w10UCIb16'
PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be'
ac_unique_file="adapter.cpp"
# 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.4w10UCIb15 to adapt to many kinds of systems.
+\`configure' configures polyglot 1.4w10UCIb16 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.4w10UCIb15:";;
+ short | recursive ) echo "Configuration of polyglot 1.4w10UCIb16:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-polyglot configure 1.4w10UCIb15
+polyglot configure 1.4w10UCIb16
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.4w10UCIb15, which was
+It was created by polyglot $as_me 1.4w10UCIb16, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='polyglot'
- VERSION='1.4w10UCIb15'
+ VERSION='1.4w10UCIb16'
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.4w10UCIb15, which was
+This file was extended by polyglot $as_me 1.4w10UCIb16, 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.4w10UCIb15
+polyglot config.status 1.4w10UCIb16
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.4w10UCIb15], [michel.vandenbergh@uhasselt.be])
+AC_INIT([polyglot], [1.4w10UCIb16], [michel.vandenbergh@uhasselt.be])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([adapter.cpp])
AC_CONFIG_HEADER([config.h])
+polyglot (1.4w10UCIb16) unstable; urgency=low
+
+ * xboard option commands
+
+ * correction of handling of combo boxes in UCI protocol
+
+ * "gui-mode". It is now possible to run PG without config file
+
+ * 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
+
polyglot (1.4w10UCIb15) unstable; urgency=low
* bugfix : due to refactoring time stamps in Windows would be written twice. This has been fixed.
#include <cstring>\r
\r
#include <sys/types.h>\r
+#include <sys/resource.h>\r
#include <unistd.h>\r
\r
#include "engine.h"\r
\r
// set a low priority\r
\r
- if (option_get_bool("UseNice"))\r
- {\r
+ if (option_get_bool("UseNice")) {\r
my_log("POLYGLOT Adjust Engine Piority");\r
- nice(+option_get_int("NiceValue"));\r
+ nice(option_get_int("NiceValue"));\r
}\r
\r
// change the current directory\r
engine->io->in_fd = from_engine[0];\r
engine->io->out_fd = to_engine[1];\r
engine->io->name = "Engine";\r
+ engine->pid=pid;\r
\r
io_init(engine->io);\r
}\r
}\r
\r
+// engine_set_nice_value()\r
+\r
+void engine_set_nice_value(engine_t * engine, int value){\r
+ setpriority(PRIO_PROCESS,engine->pid,value);\r
+}\r
+\r
+\r
// engine_close()\r
\r
void engine_close(engine_t * engine) {\r
SetProcessAffinityMask((engine->pipeEngine).hProcess,affin);\r
}\r
\r
+// Eric Mullins!\r
+\r
+void engine_set_nice_value(engine_t *engine, int value){\r
+ SetPriorityClass((engine->pipeEngine).hProcess,\r
+ GetWin32Priority(value));\r
+}\r
\r
\r
void engine_send_queue(engine_t * engine,const char *szFormat, ...) {\r
// set a low priority\r
if (option_get_bool("UseNice")){\r
my_log("POLYGLOT Adjust Engine Piority\n");\r
- SetPriorityClass((engine->pipeEngine).hProcess,\r
- GetWin32Priority(option_get_int("NiceValue")));\r
+ engine_set_nice_value(engine, option_get_int("NiceValue"));\r
}\r
\r
}\r
struct engine_t {\r
#ifndef _WIN32\r
io_t io[1];\r
+ pid_t pid;\r
#else\r
PipeStruct pipeEngine;\r
#endif\r
extern void engine_send_queue (engine_t * engine, const char format[], ...);\r
extern bool engine_get_non_blocking(engine_t * engine, char string[], int size);\r
extern void engine_get (engine_t * engine, char string[], int size);\r
-\r
+extern void engine_set_nice_value(engine_t * engine, int value);\r
\r
#endif // !defined ENGINE_H\r
#ifdef _WIN32
(gui->pipeStdin).Open();
#else
- // xboard
-
+
gui->io->in_fd = STDIN_FILENO;
gui->io->out_fd = STDOUT_FILENO;
gui->io->name = "GUI";
bool gui_get_non_blocking(gui_t * gui, char string[], int size) {
- ASSERT(xboard!=NULL);
+ ASSERT(gui!=NULL);
ASSERT(string!=NULL);
ASSERT(size>=256);
#ifndef _WIN32
va_list arg_list;
char string[StringSize];
- ASSERT(xboard!=NULL);
+ ASSERT(gui!=NULL);
ASSERT(format!=NULL);
// format
// constants\r
\r
\r
-static const char * const Version = "1.4W10UCIb15";\r
+static const char * const Version = "1.4W10UCIb16";\r
static const char * const HelpMessage = "\\r
SYNTAX\n\\r
polyglot [configfile]\n\\r
return EXIT_SUCCESS;\r
}\r
\r
+ if (argc >= 3 && my_string_equal(argv[1],"-ec")) {\r
+ option_set("EngineCommand",argv[2]);\r
+ Init=true;\r
+ engine_open(Engine);\r
+ gui_init(GUI);\r
+ uci_open(Uci,Engine);\r
+ if (my_string_equal(option_get_string("EngineName"),"<empty>")) {\r
+ option_set("EngineName",Uci->name);\r
+ }\r
+ adapter_loop();\r
+ return EXIT_SUCCESS; // we don't get here\r
+ }\r
+\r
// read options\r
\r
if (argc == 2) option_set("OptionFile",argv[1]); // HACK for compatibility\r
return EXIT_SUCCESS; // we never get here....\r
}\r
\r
+// polyglot_set_option\r
+\r
+void polyglot_set_option(char *name, char *value){ // this must be cleaned up!\r
+ option_set(name,value);\r
+ if(option_get_bool("Book")&&(my_string_case_equal(name,"BookFile")||my_string_case_equal(name,"Book"))){\r
+ my_log("POLYGLOT *** SETTING BOOK ***\n");\r
+ my_log("POLYGLOT BOOK \"%s\"\n",option_get_string("BookFile"));\r
+ book_close();\r
+ book_clear();\r
+ book_open(option_get_string("BookFile"));\r
+ if(!book_is_open()){\r
+ my_log("POLYGLOT Unable to open book \"%s\"\n",option_get_string("BookFile"));\r
+ }\r
+ }else if(option_get_bool("Log")&&(my_string_case_equal(name,"LogFile") ||my_string_case_equal(name,"Log"))){\r
+ my_log("POLYGLOT *** SETTING LOGFILE ***\n");\r
+ my_log("POLYGLOT LOGFILE \"%s\"\n",option_get_string("LogFile"));\r
+ my_log_close();\r
+ my_log_open(option_get_string("LogFile"));\r
+ }else if(option_get_bool("UseNice") &&(my_string_case_equal(name,"NiceValue")||my_string_case_equal(name,"UseNice"))){\r
+ my_log("POLYGLOT Adjust Engine Piority\n");\r
+ engine_set_nice_value(Engine,atoi(option_get_string("NiceValue")));\r
+ }else if(my_string_case_equal(name,"Book") && !option_get_bool("Book")){\r
+ book_close();\r
+ book_clear();\r
+ }else if(my_string_case_equal(name,"UseNice") && !option_get_bool("UseNice")){\r
+ my_log("POLYGLOT Adjust Engine Piority\n");\r
+ engine_set_nice_value(Engine,0);\r
+ }else if(my_string_case_equal(name,"Log") && !option_get_bool("Log")){\r
+ my_log("POLYGLOT QUIT LOGGING\n");\r
+ my_log_close();\r
+ }\r
+}\r
+\r
+\r
// init_book()\r
\r
static void init_book(){\r
+ const char *empty_var[]={};\r
book_clear();\r
if (option_get_bool("Book")){\r
my_log("POLYGLOT *** SETTING BOOK ***\n");\r
my_log("POLYGLOT BOOK \"%s\"\n",option_get_string("BookFile"));\r
- uci_set_option(Uci,\r
- PolyglotBookFile, // name\r
- option_get_string("BookFile"), // value\r
- "string", // type\r
- "<empty>", // max\r
- "<empty>", // min\r
- "<empty>" // var\r
- );\r
book_open(option_get_string("BookFile"));\r
if(!book_is_open()){\r
my_log("POLYGLOT Unable to open book \"%s\"\n",\r
option_get_string("BookFile"));\r
}\r
- } else {\r
- uci_set_option(Uci,\r
- PolyglotBookFile, // name\r
- "<empty>", // value\r
- "string", // type\r
- "<empty>", // max\r
- "<empty>", // min\r
- "<empty>" // var\r
- );\r
- \r
}\r
}\r
\r
\r
if (my_string_case_equal(line,"[engine]")) break;\r
\r
- if (parse_line(line,&name,&value)) option_set(name,value);\r
+ if (parse_line(line,&name,&value)) {\r
+ option_set(name,value);\r
+ option_set_default(name,value);\r
+ }\r
}\r
\r
if (option_get_bool("Log")) {\r
Init = true;\r
uci_open(Uci,Engine);\r
while (my_file_read_line(file,line,256)) {\r
- \r
if (line[0] == '[') my_fatal("parse_option(): unknown section %s\n",line);\r
+ if (line[0]=='#') continue;\r
\r
if (parse_line(line,&name,&value)) {\r
uci_send_option(Uci,name,"%s",value);\r
if (my_string_equal(option_get_string("EngineName"),"<empty>")) {\r
option_set("EngineName",Uci->name);\r
}\r
+\r
fclose(file);\r
}\r
\r
engine_get(Engine,string,StringSize); // HACK: calls exit() on receiving EOF\r
}\r
}\r
+ exit(EXIT_SUCCESS);\r
}\r
\r
// stop_search()\r
// functions\r
\r
extern void quit ();\r
+extern void polyglot_set_option(char *name, char *value);\r
\r
#endif // !defined MAIN_H\r
\r
\r
static const bool UseDebug = false;\r
\r
-// types\r
-\r
-struct option_t {\r
- const char * var;\r
- const char * val;\r
-};\r
\r
// variables\r
\r
-static option_t Option[] = {\r
+option_t Option[] = {\r
\r
- { "OptionFile", NULL, }, // string\r
+ { "OptionFile", "string","0","0", "polyglot.ini", NULL,0,{}, PG}, \r
\r
// options\r
\r
- { "EngineName", NULL, }, // string\r
- { "EngineDir", NULL, }, // string\r
- { "EngineCommand", NULL, }, // string\r
-\r
- { "Log", NULL, }, // true/false\r
- { "LogFile", NULL, }, // string\r
+ { "EngineName", "string","0","0", "<empty>" , NULL,0,{}, PG}, \r
+ { "EngineDir", "string","0","0", "." , NULL,0,{}, PG}, \r
+ { "EngineCommand", "string","0","0", "<empty>" , NULL,0,{}, PG}, \r
\r
- { "UCI", NULL, }, // true/false\r
+ { "Log", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI}, \r
+ { "LogFile", "string","0","0", "polyglot.log", NULL,0,{}, PG|XBOARD|UCI}, \r
\r
- { "UseNice", NULL, }, // true/false\r
+ { "UCI", "string","0","0", "false" , NULL,0,{}, PG}, \r
\r
- { "NiceValue", NULL, }, // true/false\r
+ { "UseNice", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI}, \r
+ { "NiceValue", "spin", "0","20", "5" , NULL,0,{}, PG|XBOARD|UCI}, \r
\r
- { "Chess960", NULL, }, // true/false\r
+ { "Chess960", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "Resign", NULL, }, // true/false\r
- { "ResignMoves", NULL, }, // move number\r
- { "ResignScore", NULL, }, // centipawns\r
+ { "Resign", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
+ { "ResignMoves", "spin","0","10000", "3" , NULL,0,{}, PG|XBOARD}, \r
+ { "ResignScore", "spin","0","10000", "600" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "MateScore", NULL, }, // centipawns\r
+ { "MateScore", "spin","0","1000000", "10000" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "Book", NULL, }, // true/false\r
- { "BookFile", NULL, }, // string\r
+ { "Book", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI}, \r
+ { "BookFile", "string","0","0", "book.bin" , NULL,0,{}, PG|XBOARD|UCI}, \r
\r
- { "BookRandom", NULL, }, // true/false\r
- { "BookLearn", NULL, }, // true/false\r
+ { "BookRandom", "check","0","0", "true" , NULL,0,{}, PG|XBOARD|UCI}, \r
+ { "BookLearn", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "KibitzMove", NULL, }, // true/false\r
- { "KibitzPV", NULL, }, // true/false\r
+ { "KibitzMove", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
+ { "KibitzPV", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "KibitzCommand", NULL, }, // string\r
- { "KibitzDelay", NULL, }, // seconds\r
+ { "KibitzCommand", "string","0","0", "tellall" , NULL,0,{}, PG|XBOARD}, \r
+ { "KibitzDelay", "check","0","10000", "5" , NULL,0,{}, PG|XBOARD}, \r
\r
- { "ShowPonder", NULL, }, // true/false\r
+ { "ShowPonder", "check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
\r
// work-arounds\r
\r
- { "UCIVersion", NULL, }, // 1-\r
- { "CanPonder", NULL, }, // true/false\r
- { "SyncStop", NULL, }, // true/false\r
- { "Affinity", NULL, }, // -1 else 0-32 //won't do much on *nix systems\r
- { "RepeatPV", NULL, },\r
- { "PromoteWorkAround", NULL, }, // true/false\r
+ { "UCIVersion", "spin","1","2", "2" , NULL,0,{}, PG|XBOARD}, \r
+ { "CanPonder", "check","1","2", "false" , NULL,0,{}, PG|XBOARD}, \r
+ { "SyncStop", "check","1","2", "false" , NULL,0,{}, PG|XBOARD}, \r
+ { "Affinity", "spin","-1","32", "-1" , NULL,0,{}, PG}, \r
+ { "RepeatPV", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},\r
+ { "PromoteWorkAround","check","0","0", "false" , NULL,0,{}, PG|XBOARD}, \r
\r
- // { "", NULL, },\r
-\r
- { NULL, NULL, },\r
+ { NULL, NULL,"0","0", NULL , NULL,0,{}, 0},\r
};\r
\r
// prototypes\r
\r
void option_init() {\r
\r
- option_set("OptionFile","polyglot.ini");\r
+ option_t *p=Option;\r
+ const char * name;\r
\r
- // options\r
+ while(name=(p++)->name){\r
+ option_set(name,option_get_default(name));\r
+ }\r
+}\r
\r
- option_set("EngineName","<empty>");\r
- option_set("EngineDir",".");\r
- option_set("EngineCommand","<empty>");\r
\r
- option_set("Log","false");\r
- option_set("LogFile","polyglot.log");\r
+// option_set()\r
+\r
+bool option_set(const char name[], const char value[]) {\r
\r
- option_set("UCI","false");\r
+ option_t * opt;\r
+ ASSERT(name!=NULL);\r
+ ASSERT(value!=NULL);\r
\r
- option_set("UseNice","false");\r
- option_set("NiceValue","5");\r
- \r
- option_set("Chess960","false");\r
+ opt = option_find(name);\r
+ if (opt == NULL) return false;\r
\r
- option_set("Resign","false");\r
- option_set("ResignMoves","3");\r
- option_set("ResignScore","600");\r
+ my_string_set(&opt->value,value);\r
\r
- option_set("MateScore","10000");\r
+ if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->name,opt->value);\r
\r
- option_set("Book","false");\r
- option_set("BookFile","book.bin");\r
+ return true;\r
+}\r
+// option_set()\r
\r
- option_set("BookRandom","true");\r
- option_set("BookLearn","false");\r
+bool option_set_default(const char name[], const char value[]) {\r
\r
- option_set("KibitzMove","false");\r
- option_set("KibitzPV","false");\r
+ option_t * opt;\r
+ ASSERT(name!=NULL);\r
+ ASSERT(value!=NULL);\r
\r
- option_set("KibitzCommand","tellall");\r
- option_set("KibitzDelay","5");\r
+ opt = option_find(name);\r
+ if (opt == NULL) return false;\r
\r
- option_set("ShowPonder","true");\r
+ opt->default_=my_strdup(value);\r
\r
- // work-arounds\r
+ if (UseDebug) my_log("POLYGLOT OPTION DEFAULT SET \"%s\" -> \"%s\"\n",opt->name,opt->default_);\r
\r
- option_set("UCIVersion","2");\r
- option_set("CanPonder","false");\r
- option_set("SyncStop","false");\r
- option_set("Affinity","-1");\r
- option_set("PromoteWorkAround","false");\r
- option_set("RepeatPV","true");\r
- // option_set("","");\r
+ return true;\r
}\r
\r
-// option_set()\r
+// option_get()\r
\r
-bool option_set(const char var[], const char val[]) {\r
+const char * option_get(const char name[]) {\r
\r
option_t * opt;\r
\r
- ASSERT(var!=NULL);\r
- ASSERT(val!=NULL);\r
-\r
- opt = option_find(var);\r
- if (opt == NULL) return false;\r
+ ASSERT(name!=NULL);\r
\r
- my_string_set(&opt->val,val);\r
+ opt = option_find(name);\r
+ if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);\r
\r
- if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->var,opt->val);\r
+ if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);\r
\r
- return true;\r
+ return opt->value;\r
}\r
\r
-// option_get()\r
+// option_get_default()\r
\r
-const char * option_get(const char var[]) {\r
+const char * option_get_default(const char name[]) {\r
\r
option_t * opt;\r
\r
- ASSERT(var!=NULL);\r
+ ASSERT(name!=NULL);\r
\r
- opt = option_find(var);\r
- if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",var);\r
+ opt = option_find(name);\r
+ if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);\r
\r
- if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->var,opt->val);\r
+ if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);\r
\r
- return opt->val;\r
+ return opt->default_;\r
}\r
\r
// option_get_bool()\r
\r
-bool option_get_bool(const char var[]) {\r
+bool option_get_bool(const char name[]) {\r
\r
- const char * val;\r
+ const char * value;\r
\r
- val = option_get(var);\r
+ value = option_get(name);\r
\r
if (false) {\r
- } else if (my_string_case_equal(val,"true") || my_string_case_equal(val,"yes") || my_string_equal(val,"1")) {\r
+ } else if (my_string_case_equal(value,"true") || my_string_case_equal(value,"yes") || my_string_equal(value,"1")) {\r
return true;\r
- } else if (my_string_case_equal(val,"false") || my_string_case_equal(val,"no") || my_string_equal(val,"0")) {\r
+ } else if (my_string_case_equal(value,"false") || my_string_case_equal(value,"no") || my_string_equal(value,"0")) {\r
return false;\r
}\r
\r
\r
// option_get_double()\r
\r
-double option_get_double(const char var[]) {\r
+double option_get_double(const char name[]) {\r
\r
- const char * val;\r
+ const char * value;\r
\r
- val = option_get(var);\r
+ value = option_get(name);\r
\r
- return atof(val);\r
+ return atof(value);\r
}\r
\r
// option_get_int()\r
\r
-int option_get_int(const char var[]) {\r
+int option_get_int(const char name[]) {\r
\r
- const char * val;\r
+ const char * value;\r
\r
- val = option_get(var);\r
+ value = option_get(name);\r
\r
- return atoi(val);\r
+ return atoi(value);\r
}\r
\r
// option_get_string()\r
\r
-const char * option_get_string(const char var[]) {\r
+const char * option_get_string(const char name[]) {\r
\r
- const char * val;\r
+ const char * value;\r
\r
- val = option_get(var);\r
+ value = option_get(name);\r
\r
- return val;\r
+ return value;\r
}\r
\r
// option_find()\r
\r
-static option_t * option_find(const char var[]) {\r
+static option_t * option_find(const char name[]) {\r
\r
option_t * opt;\r
\r
- ASSERT(var!=NULL);\r
+ ASSERT(name!=NULL);\r
+\r
\r
- for (opt = &Option[0]; opt->var != NULL; opt++) {\r
- if (my_string_case_equal(opt->var,var)) return opt;\r
+ for (opt = &Option[0]; opt->name != NULL; opt++) {\r
+ if (my_string_case_equal(opt->name,name)) return opt;\r
}\r
\r
return NULL;\r
\r
#include "util.h"\r
\r
+// constants\r
+\r
+const int VarNb = 16;\r
+\r
+// defines\r
+\r
+#define XBOARD 1\r
+#define UCI 2\r
+#define PG 4\r
+\r
+// types\r
+\r
+struct option_t { // TODO: put back in more logical order\r
+ const char * name;\r
+ const char * type;\r
+ const char * min;\r
+ const char * max;\r
+ const char * default_;\r
+ const char * value;\r
+ int var_nb;\r
+ const char * var[VarNb];\r
+ int mode;\r
+};\r
+\r
+// variables\r
+\r
+extern option_t Option[];\r
+\r
// functions\r
\r
extern void option_init ();\r
\r
extern bool option_set (const char var[], const char val[]);\r
+extern bool option_set_default(const char var[], const char val[]);\r
extern const char * option_get (const char var[]);\r
+extern const char * option_get_default(const char var[]);\r
\r
extern bool option_get_bool (const char var[]);\r
extern double option_get_double (const char var[]);\r
.\" ========================================================================
.\"
.IX Title "POLYGLOT 6"
-.TH POLYGLOT 6 "2009-01-10" "" ""
+.TH POLYGLOT 6 "2009-01-13" "" ""
.SH "NAME"
PolyGlot \- Winboard protocol to UCI protocol adapter
\- book engine for Polyglot books
.IX Header "SYNOPSIS"
polyglot [configfile]
.PP
+polyglot \-ec engine
+.PP
polyglot make-book [\-pgn inputfile] [\-bin outputfile] [\-max\-ply ply] [\-min\-game games] [\-min\-score score] [\-only\-white] [\-only\-black] [\-uniform]
.PP
polyglot merge-book \-in1 inputfile1 \-in2 inputfile2 [\-out outputfile]
When in \s-1UCI\s0 mode PolyGlot mostly passes commands from the \s-1GUI\s0
to the engine and vice versa, except that it will play book moves on
behalf of the engine when the occasion arises.
+.PP
+The engine options are exported as \s-1UCI\s0 options in \s-1UCI\s0
+mode and as \*(L"feature option=\*(R" commands in xboard mode. The latter form
+an extension of the xboard protocol as defined by H.G. Muller.
+.PP
+Options which normally appear in the [PolyGlot] section of the
+config file (see below) are exported as options with their name prefixed
+by \*(L"Polyglot\*(R". This makes it easy to filter them in the \s-1GUI\s0.
+.PP
+\&\s-1NOTE:\s0 Not all options are exported, only those that make sense in the
+given mode.
.Sh "Book making utilities"
.IX Subsection "Book making utilities"
PolyGlot supports the \*(L"PolyGlot opening book format\*(R". This is 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.
+.PP
+When invoked as
.Sh "polyglot make-book"
.IX Subsection "polyglot make-book"
PolyGlot supports the following options
.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.
.IP "\fBBook\fR (default: false)" 4
.IX Item "Book (default: false)"
Indicates whether a PolyGlot book should be used. This has no effect
book will be used whenever PolyGlot is out of book. Remember that
PolyGlot is unaware of whether the engine is itself using a book or
not.
-.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.
.IP "\fBBookFile\fR (default: book.bin)" 4
.IX Item "BookFile (default: book.bin)"
The name of the (binary) book file. Note that PolyGlot will look for
it in the directory it was launched from, not in the engine directory.
Of course, full path can be used in which case the current directory
does not matter.
-.Sp
-\&\s-1NOTE:\s0 When using PolyGlot with a \s-1UCI\s0 \s-1GUI\s0 this parameter can be set
-via the \s-1UCI\s0 option \*(L"Polyglot BookFile\*(R".
.IP "\fBBookRandom\fR (default: true)" 4
.IX Item "BookRandom (default: true)"
Select moves according to their weights in the book. If false the move
polyglot [configfile]
+polyglot -ec engine
+
polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]
polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]
to the engine and vice versa, except that it will play book moves on
behalf of the engine when the occasion arises.
+The engine options are exported as UCI options in UCI
+mode and as "feature option=" commands in xboard mode. The latter form
+an extension of the xboard protocol as defined by H.G. Muller.
+
+Options which normally appear in the [PolyGlot] section of the
+config file (see below) are exported as options with their name prefixed
+by "Polyglot". This makes it easy to filter them in the GUI.
+
+NOTE: Not all options are exported, only those that make sense in the
+given mode.
+
=head2 Book making utilities
PolyGlot supports the "PolyGlot opening book format". This is the
When invoked as
+=head2 polyglot -ec engine
+
+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.
+
+When invoked as
+
=head2 polyglot make-book
PolyGlot supports the following options
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.
+
=item B<Book> (default: false)
Indicates whether a PolyGlot book should be used. This has no effect
PolyGlot is unaware of whether the engine is itself using a book or
not.
-=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.
-
=item B<BookFile> (default: book.bin)
The name of the (binary) book file. Note that PolyGlot will look for
Of course, full path can be used in which case the current directory
does not matter.
-NOTE: When using PolyGlot with a UCI GUI this parameter can be set
-via the UCI option "Polyglot BookFile".
-
=item B<BookRandom> (default: true)
Select moves according to their weights in the book. If false the move
Summary: A Winboard protocol to UCI protocol adapter
Name: polyglot
-Version: 1.4w10UCIb15
+Version: 1.4w10UCIb16
Release: 1
License: GPL
Group: Amusement/Games
return false;\r
}\r
\r
+const char * uci_thread_option(uci_t * uci){\r
+ const char **thread_options_copy = thread_options;\r
+ const char *thread_option;\r
+ int i;\r
+ while((thread_option = *(thread_options_copy++))){\r
+ i=uci_get_option(uci,thread_option);\r
+ if(i>=0){\r
+ return Uci->option[i].name;\r
+ break;\r
+ }\r
+ }\r
+ return NULL;\r
+}\r
+\r
// uci_is_ok()\r
\r
static bool uci_is_ok(const uci_t * uci) {\r
for (i = 0; i < uci->option_nb; i++) {\r
opt = &uci->option[i];\r
my_string_clear(&opt->name);\r
- my_string_clear(&opt->value);\r
+ my_string_clear(&opt->default_);\r
}\r
\r
uci->option_nb = 0;\r
\r
opt = &uci->option[i];\r
\r
- if (my_string_case_equal(opt->name,option) && !my_string_equal(opt->value,value)) {\r
+ if (my_string_case_equal(opt->name,option) && !my_string_equal(opt->default_,value)) {\r
engine_send(uci->engine,"setoption name %s value %s",opt->name,value);\r
- my_string_set(&opt->value,value);\r
+ my_string_set(&opt->default_,value);\r
break;\r
}\r
}\r
\r
void uci_set_option(uci_t * uci,\r
const char * name,\r
- const char * value,\r
+ const char * default_,\r
const char * type,\r
const char * max,\r
const char * min,\r
- const char * var){\r
- int i;\r
+ int var_nb,\r
+ const char * var[]){\r
+ int i,j;\r
for(i=0;i<Uci->option_nb;i++){\r
if(my_string_equal(Uci->option[i].name,name)){\r
break;\r
}\r
if(i<OptionNb){\r
my_string_set(&(Uci->option[i].name),name);\r
- my_string_set(&(Uci->option[i].value),value);\r
+ my_string_set(&(Uci->option[i].default_),default_);\r
my_string_set(&(Uci->option[i].type),type);\r
my_string_set(&(Uci->option[i].min),min);\r
my_string_set(&(Uci->option[i].max),max);\r
- my_string_set(&(Uci->option[i].var),var);\r
+ Uci->option[i].var_nb=var_nb;\r
+ for(j=0;j<var_nb;j++){\r
+ my_string_set(&(Uci->option[i].var[j]),var[j]);\r
+ }\r
if(i==Uci->option_nb){\r
Uci->option_nb++;\r
}\r
opt = &uci->option[uci->option_nb];\r
uci->option_nb++;\r
\r
+ opt->value=NULL;\r
+ opt->mode=0;\r
+\r
opt->name = NULL;\r
my_string_set(&opt->name,"<empty>");\r
\r
- opt->value = NULL;\r
- my_string_set(&opt->value,"<empty>");\r
+ \r
+ opt->default_ = NULL;\r
+ my_string_set(&opt->default_,"<empty>");\r
\r
opt->max = NULL;\r
my_string_set(&opt->max,"<empty>");\r
opt->type = NULL;\r
my_string_set(&opt->type,"<empty>");\r
\r
- opt->var = NULL;\r
- my_string_set(&opt->var,"<empty>");\r
-\r
+ opt->var_nb=0;\r
+ \r
parse_open(parse,string);\r
parse_add_keyword(parse,"default");\r
parse_add_keyword(parse,"max");\r
// loop\r
\r
while (parse_get_word(parse,option,StringSize)) {\r
-\r
parse_get_string(parse,argument,StringSize);\r
if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument);\r
\r
// ASSERT(!my_string_empty(argument)); // HACK for Pepito\r
\r
if (!my_string_empty(argument)) {\r
- my_string_set(&opt->value,argument);\r
+ my_string_set(&opt->default_,argument);\r
}\r
\r
} else if (my_string_equal(option,"max")) {\r
} else if (my_string_equal(option,"var")) {\r
\r
ASSERT(!my_string_empty(argument));\r
- my_string_set(&opt->var,argument);\r
+ my_string_set(&opt->var[opt->var_nb++],argument);\r
+ if(opt->var_nb==VarNb) break;\r
\r
} else {\r
\r
\r
parse_close(parse);\r
\r
- if (UseDebug) my_log("POLYGLOT option name \"%s\" value \"%s\"\n",opt->name,opt->value);\r
+ if (UseDebug) my_log("POLYGLOT option name \"%s\" default \"%s\"\n",opt->name,opt->default_);\r
}\r
\r
// parse_score()\r
#include "engine.h"\r
#include "line.h"\r
#include "move.h"\r
+#include "option.h"\r
#include "util.h"\r
\r
// constants\r
\r
const int OptionNb = 256;\r
\r
-// types\r
-\r
-struct option_t {\r
- const char * name;\r
- const char * value;\r
- const char * type;\r
- const char * max;\r
- const char * min;\r
- const char * var;\r
-};\r
-\r
struct uci_t {\r
\r
engine_t * engine;\r
extern void uci_send_ucinewgame (uci_t * uci);\r
extern void uci_set_threads (uci_t * uci, int n);\r
extern bool uci_thread_option_exist(uci_t * uci);\r
+extern const char * uci_thread_option(uci_t * uci);\r
extern int uci_get_option (uci_t * uci, const char * name);\r
\r
extern bool uci_option_exist (uci_t * uci, const char option[]);\r
\r
void uci_set_option(uci_t * uci,\r
const char * name,\r
- const char * value,\r
+ const char * default_,\r
const char * type,\r
const char * max,\r
const char * min,\r
- const char * var);\r
+ int var_nb,\r
+ const char * var[]);\r
\r
#endif // !defined UCI_H\r
\r
gui_send(GUI,"bestmove %s",move_string);
}
+// format_uci_option_line()
+
+static void format_uci_option_line(char * option_line,option_t *opt){
+ char option_string[StringSize];
+ int j;
+ strcpy(option_line,"");
+ strcat(option_line,"option name");
+ if(opt->mode&PG){
+ strcat(option_line," Polyglot");
+ }
+ sprintf(option_string," %s",opt->name);
+ strcat(option_line,option_string);
+ sprintf(option_string," type %s",opt->type);
+ strcat(option_line,option_string);
+ if(strcmp(opt->type,"button")){
+ sprintf(option_string," default %s",opt->default_);
+ strcat(option_line,option_string);
+ }
+ if(!strcmp(opt->type,"spin")){
+ sprintf(option_string," min %s",opt->min);
+ strcat(option_line,option_string);
+ }
+ if(!strcmp(opt->type,"spin")){
+ sprintf(option_string," max %s",opt->max);
+ strcat(option_line,option_string);
+ }
+ for(j=0;j<opt->var_nb;j++){
+ sprintf(option_string," var %s",opt->var[j]);
+ strcat(option_line,option_string);
+ }
+}
+
// send_uci_options()
void send_uci_options() {
- int i;
+ int i,j;
+ option_t *p=Option;
+ const char * name;
char option_line[StringSize]="";
- char option_string[StringSize]="";
gui_send(GUI,"id name %s", Uci->name);
gui_send(GUI,"id author %s", Uci->author);
for(i=0;i<Uci->option_nb;i++){
- strcat(option_line,"option");
- if(strcmp(Uci->option[i].name,"<empty>")){
- sprintf(option_string," name %s",Uci->option[i].name);
- strcat(option_line,option_string);
- }
- if(strcmp(Uci->option[i].type,"<empty>")){
- sprintf(option_string," type %s",Uci->option[i].type);
- strcat(option_line,option_string);
- }
- if(strcmp(Uci->option[i].value,"<empty>")){
- sprintf(option_string," default %s",Uci->option[i].value);
- strcat(option_line,option_string);
- }
- if(strcmp(Uci->option[i].min,"<empty>")){
- sprintf(option_string," min %s",Uci->option[i].min);
- strcat(option_line,option_string);
- }
- if(strcmp(Uci->option[i].max,"<empty>")){
- sprintf(option_string," max %s",Uci->option[i].max);
- strcat(option_line,option_string);
- }
- if(strcmp(Uci->option[i].var,"<empty>")){
- sprintf(option_string," var %s",Uci->option[i].var);
- strcat(option_line,option_string);
- }
- gui_send(GUI,"%s",option_line);
- strcpy(option_line,"");
+ format_uci_option_line(option_line,Uci->option+i);
+ gui_send(GUI,"%s",option_line);
}
+ while(p->name){
+ if(p->mode &UCI){
+ format_uci_option_line(option_line,p);
+ gui_send(GUI,"%s",option_line);
+ }
+ p++;
+ }
gui_send(GUI,"uciok");
}
static void parse_setoption(const char string[]) {
parse_t parse[1];
- char option[StringSize];
- char name[StringSize];
- char value[StringSize];
+ char *name;
+ char *pg_name;
+ char *value;
char * string_copy;
string_copy=my_strdup(string);
- parse_open(parse,string_copy);
- parse_add_keyword(parse,"setoption");
- parse_add_keyword(parse,"name");
- parse_add_keyword(parse,"value");
- parse_get_word(parse,option,StringSize);
- ASSERT(my_string_equal(option,"setoption"));
- if(parse_get_word(parse,option,StringSize)){
- if(my_string_equal(option,"name")){
- parse_get_string(parse,name,StringSize);
- if(parse_get_word(parse,option,StringSize)){
- if(my_string_equal(option,"value")){
- parse_get_string(parse,value,StringSize);
- if(my_string_case_equal(name,PolyglotBookFile)){
- my_log("POLYGLOT *** SETTING BOOK ***\n");
- my_log("POLYGLOT BOOK \"%s\"\n",value);
- book_close();
- book_clear();
- book_open(value);
- if(!book_is_open()){
- my_log("POLYGLOT Unable to open book \"%s\"\n",value);
- }
- }else{
- engine_send(Engine,"%s",string);
- }
- }
- }
+ if(match(string_copy,"setoption name * value *")){
+ name=Star[0];
+ value=Star[1];
+ if(match(name, "Polyglot *")){
+ pg_name=Star[0];
+ polyglot_set_option(pg_name,value);
+ }else{
+ engine_send(Engine,"%s",string);
}
+ }else{
+ engine_send(Engine,"%s",string);
}
- parse_close(parse);
free(string_copy);
}
void my_log_close() {\r
\r
if (LogFile != NULL) fclose(LogFile);\r
+ LogFile=NULL;\r
}\r
\r
// my_log()\r