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

Method get_mean_q

core/ctree/cnode.cpp:96–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 }
95
96 float CNode::get_mean_q(int isRoot, float parent_q, float discount){
97 float total_unsigned_q = 0.0;
98 int total_visits = 0;
99 float parent_value_prefix = this->value_prefix;
100 for(int a = 0; a < this->action_num; ++a){
101 CNode* child = this->get_child(a);
102 if(child->visit_count > 0){
103 float true_reward = child->value_prefix - parent_value_prefix;
104 if(this->is_reset == 1){
105 true_reward = child->value_prefix;
106 }
107 float qsa = true_reward + discount * child->value();
108 total_unsigned_q += qsa;
109 total_visits += 1;
110 }
111 }
112
113 float mean_q = 0.0;
114 if(isRoot && total_visits > 0){
115 mean_q = (total_unsigned_q) / (total_visits);
116 }
117 else{
118 mean_q = (parent_q + total_unsigned_q) / (total_visits + 1);
119 }
120 return mean_q;
121 }
122
123 void CNode::print_out(){
124 return;

Callers 1

cbatch_traverseFunction · 0.80

Calls 2

get_childMethod · 0.95
valueMethod · 0.45

Tested by

no test coverage detected