Make some Bonanza commands available as CECP option
[bonanza.git] / proce.c
diff --git a/proce.c b/proce.c
index a17a5de..c7df52a 100644 (file)
--- a/proce.c
+++ b/proce.c
@@ -109,6 +109,24 @@ int CONV is_move( const char *str )
 }
 
 
+#if defined(_WIN32)
+char *
+strtok_r( char *s, const char *t, char **next)
+{
+  char *p, *r;
+  if( ! s ) s = *next;
+  if( ! s ) return NULL;
+  while( *s && strchr(t, *s) ) s++;
+  if( ! *s ) return NULL;
+  r = s; 
+  while( *s && ! (p = strchr(t, *s)) ) s++;
+  *next = s + 1;
+  if( ! *s ) *next = NULL;
+  *s = '\0';
+  return r; 
+}
+#endif
+
 int CONV
 procedure( tree_t * restrict ptree )
 {
@@ -284,6 +302,13 @@ Out("# command = '%s'\n", line);
                    Out("feature option=\"MultiPV -spin 1 1 100\"\n");
                    Out("feature option=\"centi-Pawn margin -spin 200 0 25000\"\n");
 #endif
+                   Out("feature option=\"Resign threshold -spin 1000 0 2000\"\n");
+                   Out("feature option=\"Create Learn File -button\"\n");
+                   Out("feature option=\"Learn -check 1\"\n");
+                   Out("feature option=\"Use book -check 1\"\n");
+                   Out("feature option=\"Book -combo wide /// narrow\"\n");
+                   Out("feature option=\"\"\n");
+                   Out("feature option=\"\"\n");
                    Out("feature variants=\"shogi\" usermove=1 myname=\"Bonanza " BNZ_VER
                        "\" memory=1 smp=1 debug=1 colors=0 setboard=1 ping=1 sigint=0 exclude=1 done=1\n");
                  }
@@ -304,10 +329,16 @@ Out("# command = '%s'\n", line);
   IF("analyze")  { return 0; }
   IF("exit")     { return 0; }
   IF("variant")  { /* ignore, since it must be Shogi */; }
-  IF("setboard") { forceMode = plyNr = 0; read_fen( line ); return 0; }
+  IF("setboard") { forceMode = 1; plyNr = 0; read_fen( line ); return 0; }
   IF("option")   {
+                  char buf[100];
                    if(sscanf(line+7, "MultiPV=%d", &value) == 1) { sprintf(line, "mpv num %d", value); return 0; }
                    if(sscanf(line+7, "centi-Pawn margin=%d", &value) == 1) { sprintf(line, "mpv width %d", value); return 0; }
+                   if(sscanf(line+7, "Resign threshold=%d", &value) == 1) { sprintf(line, "resign %d", value); return 0; }
+                   if(sscanf(line+7, "Learn=%d", &value) == 1) { sprintf(line, "hash learn %s", value ? "on" : "off"); return 0; }
+                   if(sscanf(line+7, "Create Learn File") == 1) { sprintf(line, "hash learn create"); return 0; }
+                   if(sscanf(line+7, "Use book=%d", &value) == 1) { sprintf(line, "book %s", value ? "on" : "off"); return 0; }
+                   if(sscanf(line+7, "Book=%s", buf) == 1) { sprintf(line, "book %s", buf); return 0; }
                  }
   IF("level")    { int min, sec; float fsec=0.;
                    if(sscanf(line+6, "%d %d:%d %f", &movesPerSession, &min, &sec, &fsec) != 4)