From 700e744bb24dad5d032e8099b895fa182fc17fee Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sat, 11 Dec 2010 20:43:16 +0100 Subject: [PATCH] UCT significant node: Make per-color, drop redundant color info --- uct/internal.h | 6 +++--- uct/walk.c | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 4290f18..be23bcb 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -119,9 +119,9 @@ struct uct_descent { * - without exploration factor), from black's perspective. */ struct move_stats value; /* The last "significant" node along the descent (i.e. node - * with higher than configured number of playouts). */ - struct tree_node *significant; - enum stone significant_color; // color of the significant node + * with higher than configured number of playouts). For black + * and white. */ + struct tree_node *significant[2]; }; diff --git a/uct/walk.c b/uct/walk.c index a2a87df..2432175 100644 --- a/uct/walk.c +++ b/uct/walk.c @@ -334,7 +334,7 @@ uct_playout(struct uct *u, struct board *b, enum stone player_color, struct tree #define DLEN 512 struct uct_descent descent[DLEN]; descent[0].node = n; descent[0].lnode = NULL; - descent[0].significant = NULL; + descent[0].significant[0] = descent[0].significant[1] = NULL; int dlen = 1; /* Total value of the sequence. */ struct move_stats seq_value = { .playouts = 0 }; @@ -379,8 +379,7 @@ uct_playout(struct uct *u, struct board *b, enum stone player_color, struct tree /*** Perform the descent: */ if (descent[dlen].node->u.playouts >= u->significant_threshold) { - descent[dlen].significant = n; - descent[dlen].significant_color = node_color; + descent[dlen].significant[node_color - 1] = n; } seq_value.playouts += descent[dlen].value.playouts; @@ -453,7 +452,7 @@ uct_playout(struct uct *u, struct board *b, enum stone player_color, struct tree } else { // assert(tree_leaf_node(n)); /* In case of parallel tree search, the assertion might * not hold if two threads chew on the same node. */ - result = uct_leaf_node(u, &b2, player_color, amaf, t, n, node_color, spaces); + result = uct_leaf_node(u, &b2, player_color, amaf, &descent[dlen - 1], t, n, node_color, spaces); } if (amaf && u->playout_amaf_cutoff) { -- 2.11.4.GIT