gochatai/pachi_py/pachi/uct/slave.c
/* genmoves gets in the args parameter
 * "played_games nodes main_time byoyomi_time byoyomi_periods byoyomi_stones @size"
 * and reads a binary array of coord, playouts, value to get stats of other slaves,
 * except possibly for the first call at a given move number.
 * See report_stats() for the description of the return value. */
genmoves gets in the args parameter
"played_games nodes main_time byoyomi_time byoyomi_periods byoyomi_stones @size"
and reads a binary array of coord, playouts, value to get stats of other slaves,
except possibly for the first call at a given move number.
See report_stats() for the description of the return value.
genmoves gets in the args parameter " played_games nodes main_time byoyomi_time byoyomi_periods byoyomi_stones @size " and reads a binary array of coord playouts value to get stats of other slaves except possibly for the first call at a given move number . See report_stats () for the description of the return value .
char *
uct_genmoves(struct engine *e, struct board *b, struct time_info *ti, enum stone color,
	     char *args, bool pass_all_alive, void **stats_buf, int *stats_size)
{
	struct uct *u = e->data;
	assert(u->slave);
	u->pass_all_alive |= pass_all_alive;
	if (!thread_manager_running)
		uct_genmove_setup(u, b, color);
	if ((ti->dim == TD_WALLTIME
	     && sscanf(args, "%d %lf %lf %d %d", &u->played_all,
		       &ti->len.t.main_time, &ti->len.t.byoyomi_time,
		       &ti->len.t.byoyomi_periods, &ti->len.t.byoyomi_stones) != 5)
	    || (ti->dim == TD_GAMES && sscanf(args, "%d", &u->played_all) != 1)) {
		return NULL;
	}
	static struct uct_search_state s;
	if (!thread_manager_running) {
		memset(&s, 0, sizeof(s));
		uct_search_start(u, b, color, u->t, ti, &s);
	}
	int size = 0;
	char *sizep = strchr(args, '@');
	if (sizep) size = atoi(sizep+1);
	if (!size) {
		time_sleep(u->stats_delay);
	} else if (!receive_stats(u, size)) {
		return NULL;
	}
	int played_games = uct_search_games(&s);
	uct_search_progress(u, b, color, u->t, ti, &s, played_games);
	u->played_own = played_games - s.base_playouts;
	*stats_size = 0;
	bool keep_looking = false;
	coord_t best_coord = pass;
	if (b->fbook)
		best_coord = fbook_check(b);
	if (best_coord == pass) {
		keep_looking = !uct_search_check_stop(u, b, color, u->t, ti, &s, played_games);
		uct_search_result(u, b, color, u->pass_all_alive, played_games, s.base_playouts, &best_coord);
		if (best_coord > 0) best_coord = 0; 
		if (u->shared_levels) {
			*stats_buf = report_incr_stats(u, stats_size);
		}
	}
	char *reply = report_stats(u, b, best_coord, keep_looking, *stats_size);
	return reply;
}
char * uct_genmoves ( struct engine * e , struct board * b , struct time_info * ti , enum stone color , char * args , bool pass_all_alive , void * * stats_buf , int * stats_size ) { struct uct * u = e -> data ; assert ( u -> slave ) ; u -> pass_all_alive |= pass_all_alive ; if ( ! thread_manager_running ) uct_genmove_setup ( u , b , color ) ; if ( ( ti -> dim == TD_WALLTIME && sscanf ( args , " " , & u -> played_all , & ti -> len . t . main_time , & ti -> len . t . byoyomi_time , & ti -> len . t . byoyomi_periods , & ti -> len . t . byoyomi_stones ) != 5 ) || ( ti -> dim == TD_GAMES && sscanf ( args , " " , & u -> played_all ) != 1 ) ) { return NULL ; } static struct uct_search_state s ; if ( ! thread_manager_running ) { memset ( & s , 0 , sizeof ( s ) ) ; uct_search_start ( u , b , color , u -> t , ti , & s ) ; } int size = 0 ; char * sizep = strchr ( args , ' ' ) ; if ( sizep ) size = atoi ( sizep + 1 ) ; if ( ! size ) { time_sleep ( u -> stats_delay ) ; } else if ( ! receive_stats ( u , size ) ) { return NULL ; } int played_games = uct_search_games ( & s ) ; uct_search_progress ( u , b , color , u -> t , ti , & s , played_games ) ; u -> played_own = played_games - s . base_playouts ; * stats_size = 0 ; bool keep_looking = false ; coord_t best_coord = pass ; if ( b -> fbook ) best_coord = fbook_check ( b ) ; if ( best_coord == pass ) { keep_looking = ! uct_search_check_stop ( u , b , color , u -> t , ti , & s , played_games ) ; uct_search_result ( u , b , color , u -> pass_all_alive , played_games , s . base_playouts , & best_coord ) ; if ( best_coord > 0 ) best_coord = 0 ; if ( u -> shared_levels ) { * stats_buf = report_incr_stats ( u , stats_size ) ; } } char * reply = report_stats ( u , b , best_coord , keep_looking , * stats_size ) ; return reply ; }
genmoves gets in the args parameter
 "played_games nodes main_time byoyomi_time byoyomi_periods byoyomi_stones @size"
 and reads a binary array of coord, playouts, value to get stats of other slaves,
 except possibly for the first call at a given move number.
genmoves gets in the args parameter " played_games nodes main_time byoyomi_time byoyomi_periods byoyomi_stones @size " and reads a binary array of coord playouts value to get stats of other slaves except possibly for the first call at a given move number .
/* Prepare the state if the search is not already running.
	 * We must do this first since we tweak the state below
	 * based on instructions from the master. */ /* Get playouts and time information from master. Keep this code
	 * in sync with distibuted/distributed.c:distributed_genmove(). */ /* This is the first genmoves issue, start the MCTS
		 * now and let it run while we receive stats. */ /* Read binary incremental stats if present, otherwise
	 * wait a bit to populate the statistics. */ /* Check the state of the Monte Carlo Tree Search. */ /* Give heavy weight only to pass, resign and book move: */