@@ -55,7 +55,6 @@ class Node {
5555 Node* GetParent () const { return parent_; }
5656
5757 // Gets first child
58-
5958 Node* GetFirstChild () const { return child_; }
6059
6160 // Returns whether a node has children.
@@ -80,26 +79,40 @@ class Node {
8079 // Returns Q if number of visits is more than 0,
8180 float GetQ (float default_q) const { return n_ ? q_ : default_q; }
8281 // Returns U / (Puct * N[parent])
83- float GetU () const { return p_/ (1 + n_ + n_in_flight_); }
82+ float GetU () const { return p_ / (1 + n_ + n_in_flight_); }
8483 // Returns value of Value Head returned from the neural net.
8584 float GetV () const { return v_; }
85+ // Returns the avg. of children branches (not expanded grandchildren)
86+ float GetCB () const { return avg_child_branches_; }
8687 // Returns value of Move probabilityreturned from the neural net.
8788 // (but can be changed by adding Dirichlet noise).
8889 float GetP () const { return p_; }
90+ // returns branches of this node (number of childs)
91+ float GetB () const {return b_;}
92+ // Returns population variance of q.
93+ float GetSigma2 (float default_m) const { return n_>2 ? m_/(n_-1 ):default_m; }
8994 // Returns whether the node is known to be draw/lose/win.
9095 bool IsTerminal () const { return is_terminal_; }
9196 // Returns whether the node is known to have a certain score
9297 bool IsCertain () const { return is_certain_; }
93-
94-
95- uint16_t GetFullDepth () const { return full_depth_; }
96- uint16_t GetMaxDepth () const { return max_depth_; }
98+ uint16_t GetFullDepth () const { return full_depth_; }
99+ uint16_t GetMaxDepth () const { return max_depth_; }
97100 // makes node uncertain again (used to make root uncertain when search is initialized
98101 void UnCertain ();
102+ // Sets node avg of all childrens branches
103+ void SetCB (float val) { avg_child_branches_ = val; }
99104 // Sets node own value (from neural net or win/draw/lose adjudication).
100105 void SetV (float val) { v_ = val; }
101106 // Sets move probability.
102107 void SetP (float val) { p_ = val; }
108+ // Sets Q
109+ void SetQ (float val) { q_ = val; }
110+ // Sets branches (number of childs)
111+ void SetB (float val) { b_ = val; }
112+ // Sets n_ for terminal nodes that are
113+ // found when creating children in
114+ // expand node
115+ void SetN1 () { n_ = 1 ; }
103116 // Makes the node terminal and sets it's score.
104117 void MakeTerminal (GameResult result);
105118 // Makes the node certain and sets it's score
@@ -117,9 +130,11 @@ class Node {
117130 // Updates:
118131 // * N (+=1)
119132 // * N-in-flight (-=1)
120- // * W (+= v)
121- // * Q (=w/n)
122- // Backpropagete and Autoextend modes are currently passed as parameters
133+ // * W (+= v) obsolete
134+ // * Q (+= q + (v - q) (n_+1))
135+ // * M Sum of Squares of Differences
136+ // kBackpropagate (not used currently) and Autoextend modes are
137+ // currently passed as parameters
123138 // will either be removed if changes become permanent, or replaced
124139 // by a weight parameter.
125140 void FinalizeScoreUpdate (float v, float kBackpropagate , int kAutoextend );
@@ -171,6 +186,11 @@ class Node {
171186 // Probabality that this move will be made. From policy head of the neural
172187 // network.
173188 float p_;
189+ // Sum of Squares of Differences from current mean
190+ float m_;
191+ // branch data for tree shaping
192+ float b_;
193+ float avg_child_branches_;
174194 // How many completed visits this node had.
175195 uint32_t n_;
176196 // (aka virtual loss). How many threads currently process this node (started
0 commit comments