def find_children(self, node): # possible_moves is a set of tuples. The first value of each tuple is the index of the source stack and the # second value is the index of the target stack. Indices reference to the list returned by # tree_node.all_stacks() possible_moves = node.find_possible_moves() for move in possible_moves: new_node = TreeNode(copy.deepcopy(node.base_stacks), copy.deepcopy(node.foundations), copy.deepcopy(node.freecells), node.depth + 1, node.moves_logger) if new_node.depth > self.max_depth: self.max_node = new_node self.max_depth = new_node.depth # Debugging. Used as a kind of progress indicator # print("Current maximum depth: %d" % self.max_depth) other_stack = new_node.all_stacks()[move[1]] current_stack = new_node.all_stacks()[move[0]] move_message = other_stack.move(current_stack) new_node.log_move(move_message) if new_node not in self.visited: self.add_to_frontier(new_node) self.visited.add(new_node) # Deletes node from memory (according to stackoverflow; did not fully test it) new_node = None return None