Skip to content

Commit 45b215d

Browse files
committed
Let AddVirtualLoss returns playout count
1 parent c7d0a94 commit 45b215d

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/UctSearch.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ ClearEvalQueue()
209209
////////////
210210

211211
// Virtual Lossを加算
212-
static void AddVirtualLoss( child_node_t *child, int current );
212+
static int AddVirtualLoss( child_node_t *child, int current );
213213

214214
// 次のプレイアウト回数の設定
215215
static void CalculateNextPlayouts( game_info_t *game, int color, double best_wp, double finish_time );
@@ -1573,7 +1573,7 @@ UctSearch(game_info_t *game, int color, mt19937_64 *mt, LGR& lgrf, LGRContext& l
15731573
path.push_back(current);
15741574

15751575
// Virtual Lossを加算
1576-
AddVirtualLoss(&uct_child[next_index], current);
1576+
int n = AddVirtualLoss(&uct_child[next_index], current);
15771577

15781578
memcpy(game->seki, uct_node[current].seki, sizeof(bool) * BOARD_MAX);
15791579

@@ -1672,16 +1672,12 @@ UctSearch(game_info_t *game, int color, mt19937_64 *mt, LGR& lgrf, LGRContext& l
16721672
//////////////////////////
16731673
// Virtual Lossの加算 //
16741674
//////////////////////////
1675-
static void
1675+
static int
16761676
AddVirtualLoss(child_node_t *child, int current)
16771677
{
1678-
#if defined CPP11
16791678
atomic_fetch_add(&uct_node[current].move_count, VIRTUAL_LOSS);
1680-
atomic_fetch_add(&child->move_count, VIRTUAL_LOSS);
1681-
#else
1682-
uct_node[current].move_count += VIRTUAL_LOSS;
1683-
child->move_count += VIRTUAL_LOSS;
1684-
#endif
1679+
int org = atomic_fetch_add(&child->move_count, VIRTUAL_LOSS);
1680+
return org;
16851681
}
16861682

16871683

0 commit comments

Comments
 (0)