gochatai/pachi_py/pachi/uct/walk.c
/* Display best moves' winrates in GoGui.
 * gfx commands printed on stderr are for live gfx,
 * and the last run is kept in a buffer in case we need a gtp reply.
 */
Display best moves' winrates in GoGui.
gfx commands printed on stderr are for live gfx,
and the last run is kept in a buffer in case we need a gtp reply.
Display best moves ' winrates in GoGui . gfx commands printed on stderr are for live gfx and the last run is kept in a buffer in case we need a gtp reply .
static void
uct_progress_gogui_winrates(struct uct *u, struct tree *t, enum stone color, int playouts)
{
	struct tree_node *best = t->root->children;
	int cans = GOGUI_CANDIDATES;
	struct tree_node *can[cans];
	memset(can, 0, sizeof(can));
	while (best) {
		int c = 0;
		while ((!can[c] || best->u.playouts > can[c]->u.playouts) && ++c < cans);
		for (int d = 0; d < c; d++) can[d] = can[d + 1];
		if (c > 0) can[c - 1] = best;
		best = best->sibling;
	}
	fprintf(stderr, "gogui-gfx:\n");
	char *buf = gogui_gfx_buf;
	if (--cans >= 0)
		if (can[cans]) {
			sprintf(buf, "VAR %s %s\n", 
				(color == S_WHITE ? "w" : "b"),
				coord2sstr(node_coord(can[cans]), t->board) );
			fprintf(stderr, "%s", buf);
			buf += strlen(buf);
		}
	cans++;
	while (--cans >= 0)
		if (can[cans]) {
			sprintf(buf, "LABEL %s .%02u\n", 
				coord2sstr(node_coord(can[cans]), t->board),
				(unsigned)(tree_node_get_value(t, 1, can[cans]->u.value) * 1000));
			fprintf(stderr, "%s", buf);
			buf += strlen(buf);
		}
	fprintf(stderr, "\n");	
}
static void uct_progress_gogui_winrates ( struct uct * u , struct tree * t , enum stone color , int playouts ) { struct tree_node * best = t -> root -> children ; int cans = GOGUI_CANDIDATES ; struct tree_node * can [ cans ] ; memset ( can , 0 , sizeof ( can ) ) ; while ( best ) { int c = 0 ; while ( ( ! can [ c ] || best -> u . playouts > can [ c ] -> u . playouts ) && ++ c < cans ) ; for ( int d = 0 ; d < c ; d ++ ) can [ d ] = can [ d + 1 ] ; if ( c > 0 ) can [ c - 1 ] = best ; best = best -> sibling ; } fprintf ( stderr , " \n " ) ; char * buf = gogui_gfx_buf ; if ( -- cans >= 0 ) if ( can [ cans ] ) { sprintf ( buf , " \n " , ( color == S_WHITE ? " " : " " ) , coord2sstr ( node_coord ( can [ cans ] ) , t -> board ) ) ; fprintf ( stderr , " " , buf ) ; buf += strlen ( buf ) ; } cans ++ ; while ( -- cans >= 0 ) if ( can [ cans ] ) { sprintf ( buf , " \n " , coord2sstr ( node_coord ( can [ cans ] ) , t -> board ) , ( unsigned ) ( tree_node_get_value ( t , 1 , can [ cans ] -> u . value ) * 1000 ) ) ; fprintf ( stderr , " " , buf ) ; buf += strlen ( buf ) ; } fprintf ( stderr , " \n " ) ; }
Display best moves' winrates in GoGui.
Display best moves ' winrates in GoGui .