MCPcopy Create free account
hub / github.com/YeWR/EfficientZero / cselect_child

Function cselect_child

core/ctree/cnode.cpp:327–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 }
326
327 int cselect_child(CNode* root, tools::CMinMaxStats &min_max_stats, int pb_c_base, float pb_c_init, float discount, float mean_q){
328 float max_score = FLOAT_MIN;
329 const float epsilon = 0.000001;
330 std::vector<int> max_index_lst;
331 for(int a = 0; a < root->action_num; ++a){
332 CNode* child = root->get_child(a);
333 float temp_score = cucb_score(child, min_max_stats, mean_q, root->is_reset, root->visit_count - 1, root->value_prefix, pb_c_base, pb_c_init, discount);
334
335 if(max_score < temp_score){
336 max_score = temp_score;
337
338 max_index_lst.clear();
339 max_index_lst.push_back(a);
340 }
341 else if(temp_score >= max_score - epsilon){
342 max_index_lst.push_back(a);
343 }
344 }
345
346 int action = 0;
347 if(max_index_lst.size() > 0){
348 int rand_index = rand() % max_index_lst.size();
349 action = max_index_lst[rand_index];
350 }
351 return action;
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;

Callers 1

cbatch_traverseFunction · 0.85

Calls 4

cucb_scoreFunction · 0.85
get_childMethod · 0.80
sizeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected