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

Method expand

core/ctree/cnode.cpp:51–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 CNode::~CNode(){}
50
51 void CNode::expand(int to_play, int hidden_state_index_x, int hidden_state_index_y, float value_prefix, const std::vector<float> &policy_logits){
52 this->to_play = to_play;
53 this->hidden_state_index_x = hidden_state_index_x;
54 this->hidden_state_index_y = hidden_state_index_y;
55 this->value_prefix = value_prefix;
56
57 int action_num = this->action_num;
58 float temp_policy;
59 float policy_sum = 0.0;
60 float policy[action_num];
61 float policy_max = FLOAT_MIN;
62 for(int a = 0; a < action_num; ++a){
63 if(policy_max < policy_logits[a]){
64 policy_max = policy_logits[a];
65 }
66 }
67
68 for(int a = 0; a < action_num; ++a){
69 temp_policy = exp(policy_logits[a] - policy_max);
70 policy_sum += temp_policy;
71 policy[a] = temp_policy;
72 }
73
74 float prior;
75 std::vector<CNode>* ptr_node_pool = this->ptr_node_pool;
76 for(int a = 0; a < action_num; ++a){
77 prior = policy[a] / policy_sum;
78 int index = ptr_node_pool->size();
79 this->children_index.push_back(index);
80
81 ptr_node_pool->push_back(CNode(prior, action_num, ptr_node_pool));
82 }
83 }
84
85 void CNode::add_exploration_noise(float exploration_fraction, const std::vector<float> &noises){
86 float noise, prior;

Callers 3

prepareMethod · 0.80
prepare_no_noiseMethod · 0.80
cbatch_back_propagateFunction · 0.80

Calls 2

CNodeClass · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected