def extend(self, board, root): for leaf in root.get_leaves(): if not (leaf.parent != None and leaf.cell == self.root): links = [] if leaf.state == 0: links += strong_links(board,leaf.cell,2,leaf.value) if leaf.state == 1: links += weak_links(board,leaf.cell,leaf.value) links = list(set(links)) for cell in links: if not (leaf.parent != None and leaf.parent.cell == cell): child = Node(cell, leaf.value, (1,0)[leaf.state == 1]) leaf.add_child(child)
def extend(self, board, root): for leaf in root.get_leaves(): if len(leaf.cell.c) == 2 and not (leaf.value == root.value and leaf.state == 1 and len(visible_intersection(board,[leaf.cell,self.root])) > 0): if not (leaf.parent != None and leaf.cell == root.cell and leaf.value == root.value): if (leaf.parent == None or leaf.parent.cell != leaf.cell): bivalue = (leaf.cell.c - set([leaf.value])).pop() child = Node(leaf.cell, bivalue, (1,0)[leaf.state == 1]) leaf.add_child(child) else: links = [] if leaf.state == 0: links += strong_links(board, leaf.cell, 2, leaf.value) if leaf.state == 1: links += weak_links(board, leaf.cell, leaf.value) links = list(set([cell for cell in links if len(cell.c) == 2])) links = [cell for cell in links if root.value in cell.c]+[cell for cell in links if root.value not in cell.c] for cell in links: if not (leaf.parent != None and leaf.parent.cell == cell): child = Node(cell, leaf.value, (1,0)[leaf.state == 1]) leaf.add_child(child)