X-Git-Url: http://winboard.nl/cgi-bin?p=bonanza.git;a=blobdiff_plain;f=searchr.c;h=9a1d24406aa6e846efd9a758199c78f14c286681;hp=3afd2aa99c91986d41f774862788e505aaafbef4;hb=cygwin;hpb=31daebfc1031441aa180e3af2e547a8cd2b92c32 diff --git a/searchr.c b/searchr.c index 3afd2aa..9a1d244 100644 --- a/searchr.c +++ b/searchr.c @@ -12,8 +12,7 @@ static int CONV mpv_set_bound( int alpha ); static int CONV mpv_find_min( int *pnum ); static int CONV mpv_add_result( tree_t * restrict ptree, int value ); static void CONV mpv_sub_result( unsigned int move ); -static void CONV mpv_out( tree_t * restrict ptree, int turn, - unsigned int time ); +static void CONV mpv_out( tree_t * restrict ptree, int turn, unsigned int time, int newest ); #endif #if defined(NO_STDOUT) && defined(NO_LOGGING) @@ -24,6 +23,10 @@ static int CONV next_root_move( tree_t * restrict ptree ); static int CONV next_root_move( tree_t * restrict ptree, int turn ); #endif +#ifdef XBOARD +extern char xboard_mode; +#endif + static int CONV search_wrapper( tree_t * restrict ptree, int alpha, int beta, int turn, int depth, int ply, unsigned int state_node ) @@ -311,6 +314,21 @@ searchr( tree_t * restrict ptree, int alpha, int beta, int turn, int depth ) } +#ifdef XBOARD +void CONV +out_xboard_move( int move, int tt ) +{ + int from = I2From(move), to = I2To(move); + char inPromoZone = tt > 0 ? from >= 6*9 || to >= 6*9 : to < 3*9|| from < 3*9; + if(from >= nsquare) + Out(" %c@%c%c", "PLNSGBR"[From2Drop(from)-1], 'a'+to%9, '9'-to/9); + else + Out(" %c%c%c%c%s", 'a'+from%9, '9'-from/9, 'a'+to%9, '9'-to/9, + inPromoZone ? I2IsPromote(move) ? "+" : "=" : ""); +} +#endif + + void CONV out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) { @@ -351,6 +369,14 @@ out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) if ( ptree->pv[0].length ) { +#ifdef XBOARD + if(xboard_mode) { + Out("%2d %6d %6d %8d ", iteration_depth, value, time/10, 1); + if(game_status & flag_pondering && ! analyze_mode) { + Out("("); out_xboard_move( ponder_move, 1-tt ); Out(") "); + } + } else +#endif if ( root_move_list[root_index].status & flag_first ) { Out( " %2d %6s %7.2f ", iteration_depth, str, dvalue ); @@ -361,6 +387,11 @@ out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) for ( ply = 1; ply <= ptree->pv[0].length; ply++ ) { +#ifdef XBOARD + if(xboard_mode && is_out) { // print PV move in WB format + out_xboard_move( ptree->pv[0].a[ply], tt ); + } else +#endif if ( is_out ) { if ( ply > 1 && ! ( (ply-1) % 5 ) ) @@ -407,6 +438,11 @@ out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) for ( i = 1; i < ply; i++ ) if ( ptree->pv[0].a[i] == ptree->pv[0].a[ply] ) { goto rep_esc; } +#ifdef XBOARD + if(xboard_mode && is_out) { // print PV move in WB format + out_xboard_move( ptree->pv[0].a[ply], tt ); + } else +#endif if ( is_out ) { if ( ply > 1 && ! ( (ply-1) % 5 ) ) @@ -546,6 +582,9 @@ next_root_move( tree_t * restrict ptree, int turn ) root_index = i; #if ! ( defined(NO_STDOUT) && defined(NO_LOGGING) ) +#ifdef XBOARD + if(!xboard_mode) +#endif if ( iteration_depth > 5 ) { const char *str_move; @@ -574,7 +613,7 @@ next_root_move( tree_t * restrict ptree, int turn ) #if defined(MPV) static void CONV -mpv_out( tree_t * restrict ptree, int turn, unsigned int time ) +mpv_out( tree_t * restrict ptree, int turn, unsigned int time, int newest ) { int mpv_out, ipv, best; @@ -611,12 +650,23 @@ mpv_out( tree_t * restrict ptree, int turn, unsigned int time ) str = str_time_symple( time ); ply = mpv_pv[ipv].depth; +#ifdef XBOARD + if(xboard_mode) { + if(ipv != newest) continue; // skip all but the newest, to prevent duplicates + Out("%2d %6d %6d %8d ", ply, value, time/10, 1); + } else +#endif if ( ! ipv ) { Out( "o%2d %6s %7.2f ", ply, str, dvalue ); } else { Out( " %2d %7.2f ", ply, dvalue ); } } for ( ply = 1; ply <= mpv_pv[ipv].length; ply++ ) { +#ifdef XBOARD + if(xboard_mode && is_out) { // print PV move in WB format + out_xboard_move( mpv_pv[ipv].a[ply], tt ); + } else +#endif if ( is_out ) { if ( ply > 1 && ! ( (ply-1) % 5 ) ) @@ -656,6 +706,11 @@ mpv_out( tree_t * restrict ptree, int turn, unsigned int time ) if ( mpv_pv[ipv].a[i] == mpv_pv[ipv].a[ply] ) { goto rep_esc; } +#ifdef XBOARD + if(xboard_mode && is_out) { // print PV move in WB format + out_xboard_move( mpv_pv[ipv].a[ply], tt ); + } else +#endif if ( is_out ) { if ( ply > 1 && ! ( (ply-1) % 5 ) ) @@ -748,7 +803,7 @@ mpv_add_result( tree_t * restrict ptree, int value ) { pv_t pv_tmp, pv; unsigned int time; - int i, vmin, num; + int i, vmin, num, new_pv; vmin = mpv_find_min( &num ); assert( num <= mpv_num ); @@ -793,6 +848,7 @@ mpv_add_result( tree_t * restrict ptree, int value ) pv = ptree->pv[1]; pv.a[0] = (unsigned int)(value+32768); + new_pv = i; // [HGM] xboard: remember which is the new one, so we can print only that do { assert( i < mpv_num*2 ); assert( i < root_nmove*2 ); @@ -804,7 +860,7 @@ mpv_add_result( tree_t * restrict ptree, int value ) if ( get_elapsed( &time ) < 0 ) { return -1; } - mpv_out( ptree, root_turn, time - time_start ); + mpv_out( ptree, root_turn, time - time_start, new_pv ); return 1; }