(self)
| 65 | self.expansion_evaluation_backpropagation(node) |
| 66 | |
| 67 | def selection(self) -> Optional[Type[MCTSNode]]: |
| 68 | node = self.root |
| 69 | # while node.has_children() or node.is_terminal: # for some purpose, but i forget it. |
| 70 | while node.has_children() and not node.is_terminal: # for mcts, it should be like this |
| 71 | next_node = self.select_child(node) # To encourage exploration, select from non-terminal children |
| 72 | if next_node is None: # if None,it mean all children are terminal |
| 73 | node.is_terminal = True |
| 74 | break |
| 75 | node = next_node |
| 76 | |
| 77 | return None if node.is_terminal else node |
| 78 | |
| 79 | def select_child(self, node: Type[MCTSNode]) -> Optional[Type[MCTSNode]]: |
| 80 | # TODO: implement multi-strategy |
no test coverage detected