X-Git-Url: http://winboard.nl/cgi-bin?p=bonanza.git;a=blobdiff_plain;f=searchr.c;h=f82ee6908294f295eaffbe70ae95c493cb60a973;hp=a3aba068d9f351595cfd65ef313b6460372a3f30;hb=03c9ebfa52d12a4f1b53e393b68bc41cbefe497b;hpb=18b507e1b20fc6c32ee50f00fb910a59110c1a1d diff --git a/searchr.c b/searchr.c index a3aba06..f82ee69 100644 --- a/searchr.c +++ b/searchr.c @@ -13,7 +13,7 @@ static int mpv_set_bound( int alpha ); static int mpv_find_min( int *pnum ); static int mpv_add_result( tree_t * restrict ptree, int value ); static void mpv_sub_result( unsigned int move ); -static void mpv_out( tree_t * restrict ptree, int turn, unsigned int time ); +static void mpv_out( tree_t * restrict ptree, int turn, unsigned int time, int newest ); #endif #if defined(NO_STDOUT) && defined(NO_LOGGING) @@ -24,6 +24,10 @@ static int next_root_move( tree_t * restrict ptree ); static int next_root_move( tree_t * restrict ptree, int turn ); #endif +#ifdef XBOARD +extern char xboard_mode; +#endif + int searchr( tree_t * restrict ptree, int alpha, int beta, int turn, int depth ) { @@ -214,6 +218,21 @@ searchr( tree_t * restrict ptree, int alpha, int beta, int turn, int depth ) } +#ifdef XBOARD +void +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 out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) { @@ -242,6 +261,9 @@ out_pv( tree_t * restrict ptree, int value, int turn, unsigned int time ) if ( ptree->pv[0].length ) { int i = find_root_move( ptree->pv[0].a[1] ); +#ifdef XBOARD + if(xboard_mode) Out("%2d %6d %6d %8d ", iteration_depth, value, time/10, 1); else +#endif if ( root_move_list[i].status & flag_first ) { Out( " %2d %6s %7.2f ", iteration_depth, str, dvalue ); @@ -252,6 +274,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) % 4 ) ) @@ -287,6 +314,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) % 4 ) ) @@ -401,6 +433,9 @@ next_root_move( tree_t * restrict ptree, int turn ) ptree->current_move[1] = root_move_list[i].move; #if ! ( defined(NO_STDOUT) && defined(NO_LOGGING) ) +#ifdef XBOARD + if(!xboard_mode) +#endif if ( iteration_depth > 5 ) { const char *str_move; @@ -443,7 +478,7 @@ find_root_move( unsigned int move ) #if defined(MPV) static void -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; @@ -480,12 +515,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) % 4 ) ) @@ -523,6 +569,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) % 4 ) ) @@ -616,7 +667,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 ); @@ -661,6 +712,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 ); @@ -672,7 +724,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; }