gochatai/pachi_py/pachi/uct/slave.c
/* Get stats for the distributed engine. Return a buffer with one
 * line "played_own root_playouts threads keep_looking @size", then
 * a list of lines "coord playouts value" with absolute counts for
 * children of the root node (including contributions from other
 * slaves). The last line must not end with \n.
 * If c is non-zero, add this move with a large weight.
 * This function is called only by the main thread, but may be
 * called while the tree is updated by the worker threads. Keep this
 * code in sync with distributed/distributed.c:select_best_move(). */
Get stats for the distributed engine. Return a buffer with one
line "played_own root_playouts threads keep_looking @size", then
a list of lines "coord playouts value" with absolute counts for
children of the root node (including contributions from other
slaves). The last line must not end with \n.
If c is non-zero, add this move with a large weight.
This function is called only by the main thread, but may be
called while the tree is updated by the worker threads. Keep this
code in sync with distributed/distributed.c:select_best_move().
Get stats for the distributed engine . Return a buffer with one line " played_own root_playouts threads keep_looking @size " then a list of lines " coord playouts value " with absolute counts for children of the root node ( including contributions from other slaves ) . The last line must not end with \ n . If c is non - zero add this move with a large weight . This function is called only by the main thread but may be called while the tree is updated by the worker threads . Keep this code in sync with distributed / distributed . c : select_best_move () .
static char *
report_stats(struct uct *u, struct board *b, coord_t c,
	     bool keep_looking, int bin_size)
{
	static char reply[10240];
	char *r = reply;
	char *end = reply + sizeof(reply);
	struct tree_node *root = u->t->root;
	r += snprintf(r, end - r, "%d %d %d %d @%d", u->played_own, root->u.playouts,
		      u->threads, keep_looking, bin_size);
	int min_playouts = root->u.playouts / 100;
	if (min_playouts < GJ_MINGAMES)
		min_playouts = GJ_MINGAMES;
	int max_playouts = 1;
	for (struct tree_node *ni = root->children; ni; ni = ni->sibling) {
		if (is_pass(node_coord(ni))) continue;
		assert(node_coord(ni) > 0 && node_coord(ni) < board_size2(b));
		if (ni->u.playouts > max_playouts)
			max_playouts = ni->u.playouts;
		if (ni->u.playouts <= min_playouts || ni->hints & TREE_HINT_INVALID)
			continue;
		if (node_coord(ni) == c) continue;
		char buf[4];
		r += snprintf(r, end - r, "\n%s %d %.16f", coord2bstr(buf, node_coord(ni), b),
			      ni->u.playouts, ni->u.value);
	}
	if (c) {
		double resign_value = u->t->root_color == S_WHITE ? 0.0 : 1.0;
		double c_value = is_resign(c) ? resign_value : 1.0 - resign_value;
		r += snprintf(r, end - r, "\n%s %d %.1f", coord2sstr(c, b),
			      2 * max_playouts, c_value);
	}
	return reply;
}
static char * report_stats ( struct uct * u , struct board * b , coord_t c , bool keep_looking , int bin_size ) { static char reply [ 10240 ] ; char * r = reply ; char * end = reply + sizeof ( reply ) ; struct tree_node * root = u -> t -> root ; r += snprintf ( r , end - r , " " , u -> played_own , root -> u . playouts , u -> threads , keep_looking , bin_size ) ; int min_playouts = root -> u . playouts / 100 ; if ( min_playouts < GJ_MINGAMES ) min_playouts = GJ_MINGAMES ; int max_playouts = 1 ; for ( struct tree_node * ni = root -> children ; ni ; ni = ni -> sibling ) { if ( is_pass ( node_coord ( ni ) ) ) continue ; assert ( node_coord ( ni ) > 0 && node_coord ( ni ) < board_size2 ( b ) ) ; if ( ni -> u . playouts > max_playouts ) max_playouts = ni -> u . playouts ; if ( ni -> u . playouts <= min_playouts || ni -> hints & TREE_HINT_INVALID ) continue ; if ( node_coord ( ni ) == c ) continue ; char buf [ 4 ] ; r += snprintf ( r , end - r , " \n " , coord2bstr ( buf , node_coord ( ni ) , b ) , ni -> u . playouts , ni -> u . value ) ; } if ( c ) { double resign_value = u -> t -> root_color == S_WHITE ? 0.0 : 1.0 ; double c_value = is_resign ( c ) ? resign_value : 1.0 - resign_value ; r += snprintf ( r , end - r , " \n " , coord2sstr ( c , b ) , 2 * max_playouts , c_value ) ; } return reply ; }
Get stats for the distributed engine.
Get stats for the distributed engine .
/* We rely on the fact that root->children is set only
	 * after all children are created. */ /* A book move is only added at the end: */ /* We return the values as stored in the tree, so from black's view. */ /* Give a large but not infinite weight to pass, resign or book move, to avoid
	 * forcing resign if other slaves don't like it. */