save_used_hash() The process performed by this function is to set a used flag for all expanded nodes below the node given as an argument.
#Leave the node in use
def save_used_hash(self, board, uct_node, index):
self.node_hash[index].flag = True
self.used += 1
current_node = uct_node[index]
child_index = current_node.child_index
child_move = current_node.child_move
child_num = current_node.child_num
for i in range(child_num):
if child_index[i] != NOT_EXPANDED and self.node_hash[child_index[i]].flag == False:
board.push(child_move[i])
self.save_used_hash(board, uct_node, child_index[i])
board.pop()
Set the used flag of the node given in the argument. Get information about child nodes.
Set the used flag of the child node. Get the information of the child node of the child node.
This is repeated. Then, finally, the used flags of all the expanded nodes under the parent node are set.
delete_old_hash() The process performed by this function is to set the used flag of all expanded nodes below the node of the phase given to the argument, and to flag the other nodes as unused.
Set the used flag to False (not used) for all node_hash.
Execute save_used_hash () for the current phase and set the used flags of all expanded nodes below the current phase node.
Recommended Posts