gochatai/pachi_py/pachi/uct/slave.c
/* Get incremental stats updates for the distributed engine.
 * Return a binary array of incr_stats structs in coordinate order
 * (increasing levels and increasing coordinates within a level).
 * 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/merge.c:merge_new_stats(). */
Get incremental stats updates for the distributed engine.
Return a binary array of incr_stats structs in coordinate order
(increasing levels and increasing coordinates within a level).
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/merge.c:merge_new_stats().
Get incremental stats updates for the distributed engine . Return a binary array of incr_stats structs in coordinate order ( increasing levels and increasing coordinates within a level ) . 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 / merge . c : merge_new_stats () .
static void *
report_incr_stats(struct uct *u, int *stats_size)
{
	double start_time = time_now();
	struct tree_node *root = u->t->root;
	struct board *b = u->t->board;
	int max_nodes = 3 * u->shared_nodes;
	static struct stats_candidate *stats_queue = NULL;
	if (!stats_queue) stats_queue = malloc2(max_nodes * sizeof(*stats_queue));
	memset(bucket_count, 0, sizeof(bucket_count));
	static int min_increment = 1;
	static int stats_count = 0;
	if (stats_count > 2 * u->shared_nodes) {
		min_increment++;
	} else if (stats_count < u->shared_nodes / 2 && min_increment > 1) {
		min_increment--;
	}
	stats_count = append_stats(stats_queue, root, 0, max_nodes, 0,
				   max_parent_path(u, b), min_increment, b);
	void *buf = select_best_stats(stats_queue, stats_count, u->shared_nodes, stats_size);
	if (DEBUGVV(2))
		fprintf(stderr,
			"min_incr %d games %d stats_queue %d/%d sending %d/%d in %.3fms\n",
			min_increment, root->u.playouts - root->pu.playouts, stats_count,
			max_nodes, *stats_size / (int)sizeof(struct incr_stats), u->shared_nodes,
			(time_now() - start_time)*1000);
	root->pu = root->u;
	return buf;
}
static void * report_incr_stats ( struct uct * u , int * stats_size ) { double start_time = time_now ( ) ; struct tree_node * root = u -> t -> root ; struct board * b = u -> t -> board ; int max_nodes = 3 * u -> shared_nodes ; static struct stats_candidate * stats_queue = NULL ; if ( ! stats_queue ) stats_queue = malloc2 ( max_nodes * sizeof ( * stats_queue ) ) ; memset ( bucket_count , 0 , sizeof ( bucket_count ) ) ; static int min_increment = 1 ; static int stats_count = 0 ; if ( stats_count > 2 * u -> shared_nodes ) { min_increment ++ ; } else if ( stats_count < u -> shared_nodes / 2 && min_increment > 1 ) { min_increment -- ; } stats_count = append_stats ( stats_queue , root , 0 , max_nodes , 0 , max_parent_path ( u , b ) , min_increment , b ) ; void * buf = select_best_stats ( stats_queue , stats_count , u -> shared_nodes , stats_size ) ; if ( DEBUGVV ( 2 ) ) fprintf ( stderr , " \n " , min_increment , root -> u . playouts - root -> pu . playouts , stats_count , max_nodes , * stats_size / ( int ) sizeof ( struct incr_stats ) , u -> shared_nodes , ( time_now ( ) - start_time ) * 1000 ) ; root -> pu = root -> u ; return buf ; }
Get incremental stats updates for the distributed engine.
Get incremental stats updates for the distributed engine .
/* The factor 3 below has experimentally been found to be
	 * sufficient. At worst if we fill stats_queue we will
	 * discard some stats updates but this is rare. */ /* Try to fill the output buffer with the most important
         * nodes (highest increments), while still traversing
	 * as little of the tree as possible. If we set min_increment
	 * too low we waste time. If we set it too high we can't
	 * fill the output buffer with the desired number of nodes.
	 * The best min_increment results in stats_count just above 
	 * shared_nodes. However perfect tuning is not necessary:
	 * if we send too few nodes we just send shorter buffers
	 * more frequently. */