X-Git-Url: http://winboard.nl/cgi-bin?p=bonanza.git;a=blobdiff_plain;f=proce.c;h=0a6df1a654f69350871aa3dcdc43e72e093ff7d4;hp=214c78b5e01b8538e16cdc5625d45dc31a972e89;hb=1e0b1da6687c3fd65817bdab4002b5f509810481;hpb=b850f7cbcdc13f78355a7dc302e3e27a0552bb37 diff --git a/proce.c b/proce.c index 214c78b..0a6df1a 100644 --- a/proce.c +++ b/proce.c @@ -52,7 +52,7 @@ static int cmd_thread( char **lasts ); #endif #if defined(MPV) -static int cmd_mpv( char **lasts ); +static int cmd_mpv( tree_t * restrict ptree, char **lasts ); #endif static int proce_cui( tree_t * restrict ptree ); @@ -75,6 +75,8 @@ static int cmd_read( tree_t * restrict ptree, char **lasts ); static int cmd_resign( tree_t * restrict ptree, char **lasts ); static int cmd_time( char **lasts ); static int cmd_undo( tree_t * restrict ptree ); // [HGM] undo +static int cmd_analyze( tree_t * restrict ptree ); // [HGM] analyze +static int cmd_exit( void ); static int is_move( const char *str ); @@ -99,6 +101,7 @@ int move_list[1024], move_ptr; int myTime, hisTime, movesPerSession, inc, plyNr; char xboard_mode; +char analyze_mode; static void SetTimes(void) @@ -124,8 +127,14 @@ proce_xboard(char *line, const char *command, tree_t * restrict ptree) sscanf(line + strlen(command) + 1, "%d", &value); Out("# command = '%s'\n", line); if(0) ; - IF("protover") { Out("feature variants=\"shogi\" usermove=1 myname=\"Bonanza " BNZ_VER - "\" memory=1 smp=1 debug=1 colors=0 setboard=1 ping=1 done=1\n"); } + IF("protover") { +#if defined(MPV) + Out("feature option=\"MultiPV -spin 1 1 100\"\n"); + Out("feature option=\"centi-Pawn margin -spin 200 0 25000\"\n"); +#endif + Out("feature variants=\"shogi\" usermove=1 myname=\"Bonanza " BNZ_VER + "\" memory=1 smp=1 debug=1 colors=0 setboard=1 ping=1 done=1\n"); + } IF("new") { forceMode = plyNr = 0; SetTimes(); return 0; } IF("easy") { strcpy(line, "ponder off"); return 0; } IF("hard") { strcpy(line, "ponder on"); return 0; } @@ -140,11 +149,14 @@ Out("# command = '%s'\n", line); IF("sd") { sprintf(line, "limit depth %d", value); return 0; } IF("st") { ; } IF("quit") { return 0; } - IF("analyze") { ; } - IF("exit") { ; } + IF("analyze") { return 0; } + IF("exit") { return 0; } IF("variant") { /* ignore, since it must be Shogi */; } IF("setboard") { ; } - IF("option") { ; } + IF("option") { + 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("level") { int min, sec; float fsec=0.; if(sscanf(line+6, "%d %d:%d %f", &movesPerSession, &min, &sec, &fsec) != 4) sscanf(line+6, "%d %d %f", &movesPerSession, &min, &fsec); @@ -153,7 +165,7 @@ Out("# command = '%s'\n", line); IF("usermove") { char fromX=line[9], fromY=line[10], toX=line[11], toY=line[12], promo=line[13]; int from; {int i,j;for(i=0;i<81;i+=9){printf("# ");for(j=0;j<9;j++)printf(" %3d", BOARD[i+j]);printf("\n");}} - if(forceMode) strcpy(line, "move "), line += 5; else plyNr++, SetTimes(); + if(forceMode || analyze_mode) strcpy(line, "move "), line += 5; else plyNr++, SetTimes(); if(fromY == '@') { // drop if(fromX >= 'a') fromX += 'A' - 'a'; switch(fromX) { // encode piece @@ -175,7 +187,7 @@ Out("# from=%d\n",from); plyNr++; return 0; } - IF("undo") { ; } + IF("undo") { return 0; } IF("remove") { ; } IF("ping") { Out("pong %d\n", value); } return 1; @@ -201,6 +213,14 @@ proce_cui( tree_t * restrict ptree ) if ( ! strcmp( token, "xboard" ) ) { xboard_mode = 1; game_status |= flag_noprompt; return 1; } } #endif + if ( ! strcmp( token, "analyze" ) ) { return cmd_analyze( ptree ); } // [HGM] analyze + if ( ! strcmp( token, "exit" ) ) { return cmd_exit(); } // [HGM] analyze + if ( ! strcmp( token, "move" ) ) { return cmd_move( ptree, &last ); } + if ( ! strcmp( token, "undo" ) ) { return cmd_undo( ptree ); } // [HGM] undo +#if defined(MPV) + if ( ! strcmp( token, "mpv" ) ) { return cmd_mpv( ptree, &last ); } +#endif + analyze_mode = 0; // [HGM] analyze: all other commands terminate analysis if ( is_move( token ) ) { return cmd_usrmove( ptree, token, &last ); } if ( ! strcmp( token, "s" ) ) { return cmd_move_now(); } if ( ! strcmp( token, "beep" ) ) { return cmd_beep( &last); } @@ -208,7 +228,6 @@ proce_cui( tree_t * restrict ptree ) if ( ! strcmp( token, "display" ) ) { return cmd_display( ptree, &last ); } if ( ! strcmp( token, "hash" ) ) { return cmd_hash( &last ); } if ( ! strcmp( token, "limit" ) ) { return cmd_limit( &last ); } - if ( ! strcmp( token, "move" ) ) { return cmd_move( ptree, &last ); } if ( ! strcmp( token, "new" ) ) { return cmd_new( ptree, &last ); } if ( ! strcmp( token, "peek" ) ) { return cmd_peek( &last ); } if ( ! strcmp( token, "ping" ) ) { return cmd_ping(); } @@ -219,7 +238,6 @@ proce_cui( tree_t * restrict ptree ) if ( ! strcmp( token, "resign" ) ) { return cmd_resign( ptree, &last ); } if ( ! strcmp( token, "suspend" ) ) { return cmd_suspend(); } if ( ! strcmp( token, "time" ) ) { return cmd_time( &last ); } - if ( ! strcmp( token, "undo" ) ) { return cmd_undo( ptree ); } // [HGM] undo #if defined(CSA_LAN) if ( ! strcmp( token, "connect" ) ) { return cmd_connect( ptree, &last ); } #endif @@ -229,9 +247,6 @@ proce_cui( tree_t * restrict ptree ) #if defined(DEKUNOBOU) if ( ! strcmp( token, "dekunobou" ) ) { return cmd_dek( &last ); } #endif -#if defined(MPV) - if ( ! strcmp( token, "mpv" ) ) { return cmd_mpv( &last ); } -#endif #if defined(TLP) if ( ! strcmp( token, "tlp" ) ) { return cmd_thread( &last ); } #endif @@ -391,6 +406,22 @@ cmd_mnjmove( tree_t * restrict ptree, char **lasts, int is_alter ) static int +do_analyze( tree_t * restrict ptree ) +{ // [HGM] analyze: do a ponder search on the current position + int iret; + if ( get_elapsed( &time_start ) < 0 ) { return -1; } + time_limit = time_max_limit = 1e9; // kludge: use huge time to mimic infinity +#ifdef XBOARD + Out("1 0 0 0 New Search\n"); // make sure lower depth is emitted, so XBoard undestand new search started +#endif + game_status |= flag_pondering; + iret = iterate( ptree, 0 ); + game_status &= ~flag_pondering; + return iret; +} + + +static int cmd_undo( tree_t * restrict ptree ) { // [HGM] undo: restart the game, and feed all moves except the last int i, last = move_ptr; @@ -407,6 +438,34 @@ cmd_undo( tree_t * restrict ptree ) for(i=0; i