| 352 | } |
| 353 | |
| 354 | float cucb_score(CNode *child, tools::CMinMaxStats &min_max_stats, float parent_mean_q, int is_reset, float total_children_visit_counts, float parent_value_prefix, float pb_c_base, float pb_c_init, float discount){ |
| 355 | float pb_c = 0.0, prior_score = 0.0, value_score = 0.0; |
| 356 | pb_c = log((total_children_visit_counts + pb_c_base + 1) / pb_c_base) + pb_c_init; |
| 357 | pb_c *= (sqrt(total_children_visit_counts) / (child->visit_count + 1)); |
| 358 | |
| 359 | prior_score = pb_c * child->prior; |
| 360 | if (child->visit_count == 0){ |
| 361 | value_score = parent_mean_q; |
| 362 | } |
| 363 | else { |
| 364 | float true_reward = child->value_prefix - parent_value_prefix; |
| 365 | if(is_reset == 1){ |
| 366 | true_reward = child->value_prefix; |
| 367 | } |
| 368 | value_score = true_reward + discount * child->value(); |
| 369 | } |
| 370 | |
| 371 | value_score = min_max_stats.normalize(value_score); |
| 372 | |
| 373 | if (value_score < 0) value_score = 0; |
| 374 | if (value_score > 1) value_score = 1; |
| 375 | |
| 376 | float ucb_value = prior_score + value_score; |
| 377 | return ucb_value; |
| 378 | } |
| 379 | |
| 380 | void cbatch_traverse(CRoots *roots, int pb_c_base, float pb_c_init, float discount, tools::CMinMaxStatsList *min_max_stats_lst, CSearchResults &results){ |
| 381 | // set seed |
no test coverage detected