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

Function cback_propagate

core/ctree/cnode.cpp:286–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284 }
285
286 void cback_propagate(std::vector<CNode*> &search_path, tools::CMinMaxStats &min_max_stats, int to_play, float value, float discount){
287 float bootstrap_value = value;
288 int path_len = search_path.size();
289 for(int i = path_len - 1; i >= 0; --i){
290 CNode* node = search_path[i];
291 node->value_sum += bootstrap_value;
292 node->visit_count += 1;
293
294 float parent_value_prefix = 0.0;
295 int is_reset = 0;
296 if(i >= 1){
297 CNode* parent = search_path[i - 1];
298 parent_value_prefix = parent->value_prefix;
299 is_reset = parent->is_reset;
300// float qsa = (node->value_prefix - parent_value_prefix) + discount * node->value();
301// min_max_stats.update(qsa);
302 }
303
304 float true_reward = node->value_prefix - parent_value_prefix;
305 if(is_reset == 1){
306 // parent is reset
307 true_reward = node->value_prefix;
308 }
309
310 bootstrap_value = true_reward + discount * bootstrap_value;
311 }
312 min_max_stats.clear();
313 CNode* root = search_path[0];
314 update_tree_q(root, min_max_stats, discount);
315 }
316
317 void cbatch_back_propagate(int hidden_state_index_x, float discount, const std::vector<float> &value_prefixs, const std::vector<float> &values, const std::vector<std::vector<float>> &policies, tools::CMinMaxStatsList *min_max_stats_lst, CSearchResults &results, std::vector<int> is_reset_lst){
318 for(int i = 0; i < results.num; ++i){

Callers 1

cbatch_back_propagateFunction · 0.85

Calls 3

update_tree_qFunction · 0.85
sizeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected