| 254 | //********************************************************* |
| 255 | |
| 256 | void update_tree_q(CNode* root, tools::CMinMaxStats &min_max_stats, float discount){ |
| 257 | std::stack<CNode*> node_stack; |
| 258 | node_stack.push(root); |
| 259 | float parent_value_prefix = 0.0; |
| 260 | int is_reset = 0; |
| 261 | while(node_stack.size() > 0){ |
| 262 | CNode* node = node_stack.top(); |
| 263 | node_stack.pop(); |
| 264 | |
| 265 | if(node != root){ |
| 266 | float true_reward = node->value_prefix - parent_value_prefix; |
| 267 | if(is_reset == 1){ |
| 268 | true_reward = node->value_prefix; |
| 269 | } |
| 270 | float qsa = true_reward + discount * node->value(); |
| 271 | min_max_stats.update(qsa); |
| 272 | } |
| 273 | |
| 274 | for(int a = 0; a < node->action_num; ++a){ |
| 275 | CNode* child = node->get_child(a); |
| 276 | if(child->expanded()){ |
| 277 | node_stack.push(child); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | parent_value_prefix = node->value_prefix; |
| 282 | is_reset = node->is_reset; |
| 283 | } |
| 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; |