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

Function cbatch_traverse

core/ctree/cnode.cpp:380–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
382 timeval t1;
383 gettimeofday(&t1, NULL);
384 srand(t1.tv_usec);
385
386 int last_action = -1;
387 float parent_q = 0.0;
388 results.search_lens = std::vector<int>();
389 for(int i = 0; i < results.num; ++i){
390 CNode *node = &(roots->roots[i]);
391 int is_root = 1;
392 int search_len = 0;
393 results.search_paths[i].push_back(node);
394
395 while(node->expanded()){
396 float mean_q = node->get_mean_q(is_root, parent_q, discount);
397 is_root = 0;
398 parent_q = mean_q;
399
400 int action = cselect_child(node, min_max_stats_lst->stats_lst[i], pb_c_base, pb_c_init, discount, mean_q);
401 node->best_action = action;
402 // next
403 node = node->get_child(action);
404 last_action = action;
405 results.search_paths[i].push_back(node);
406 search_len += 1;
407 }
408
409 CNode* parent = results.search_paths[i][results.search_paths[i].size() - 2];
410
411 results.hidden_state_index_x_lst.push_back(parent->hidden_state_index_x);
412 results.hidden_state_index_y_lst.push_back(parent->hidden_state_index_y);
413
414 results.last_actions.push_back(last_action);
415 results.search_lens.push_back(search_len);
416 results.nodes.push_back(node);
417 }
418 }
419
420}

Callers

nothing calls this directly

Calls 5

cselect_childFunction · 0.85
expandedMethod · 0.80
get_mean_qMethod · 0.80
get_childMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected