From: H.G. Muller Date: Sun, 15 Sep 2013 10:44:40 +0000 (+0200) Subject: Fix pondering in XBoard mode X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=b254afaa5659484d8643f4aac1fb18245d7e0199;p=bonanza.git Fix pondering in XBoard mode Even the root move list was wrong during pondering, because it was the list from the position after the ponder move was made. We now make a copy of the board position in ponder(), before it starts to do anything, so we can get the moved piece from that copy if a move comes in during pondering. --- diff --git a/ponder.c b/ponder.c index 634ce23..eeb5451 100644 --- a/ponder.c +++ b/ponder.c @@ -22,6 +22,11 @@ ponder( tree_t * restrict ptree ) Out( "\nSearch a move to ponder\n\n" ); OutCsaShogi( "info ponder start\n" ); +#if defined(XBOARD) + // [HGM] for converting to CSA move during ponder + for( iret = 0; iret < nsquare; iret++ ) root_pos[iret] = BOARD[iret]; +#endif + game_status |= flag_puzzling; iret = iterate( ptree ); game_status &= ~flag_puzzling; diff --git a/proce.c b/proce.c index a08b5d9..cb98efa 100644 --- a/proce.c +++ b/proce.c @@ -136,6 +136,7 @@ int all_moves[MAX_LEGAL_MOVES]; int myTime, hisTime, movesPerSession, inc, plyNr; char xboard_mode; +int root_pos[nsquare]; int xboard_to_CSA( tree_t * restrict ptree, char *in, char *out, int status ) @@ -160,7 +161,7 @@ xboard_to_CSA( tree_t * restrict ptree, char *in, char *out, int status ) int flag = (promo == '+' ? FLAG_PROMO : 0); piece = abs( BOARD[from] ); // this only works when not searching! printf("# piece from board: %d\n", piece);fflush(stdout); - if( status & ( flag_pondering | flag_puzzling | flag_thinking ) ) { + if( status & flag_thinking ) { int i, to = ('9' - toY)*9 + (toX - 'a'), l = (status == (flag_pondering | flag_thinking)); piece = 0; // kludge to force illegal CSA move for( i = 0; l ? all_moves[i] : i < root_nmove; i++ ) { // determine the piece from the move list @@ -172,8 +173,8 @@ printf("# piece from board: %d\n", piece);fflush(stdout); bonanza_move = move; break; } + } else if( status & ( flag_pondering | flag_puzzling ) ) piece = abs( root_pos[from] ); // we have valid copy! printf("# piece corrected to %d\n", piece);fflush(stdout); - } if( promo ) piece += promote; sprintf(out, "%c%c%c%c%s", 'a'+'9'-fromX, '1'+'9'-fromY, 'a'+'9'-toX, '1'+'9'-toY, astr_table_piece[piece]); } diff --git a/shogi.h b/shogi.h index 395126f..ecc1ed1 100644 --- a/shogi.h +++ b/shogi.h @@ -956,6 +956,7 @@ extern const int aikkp_hand[8]; extern const char ach_turn[2]; extern const unsigned char aifile[ nsquare ]; extern const unsigned char airank[ nsquare ]; +extern int root_pos[]; // [HGM] remembers root position during pondering extern int move_list[], move_ptr; // [HGM] undo: game history (used in proce.c and makemove.c) extern char analyze_mode; // [HGM] exclude: used in proce.c and root.c