Esempio n. 1
0
def create_tree(node, depth, flag):
    if flag:
        # pos_w = game.MovesOpening(node.value)
        if depth > 0:
            pos_w = game.MovesOpening(node.value)
            for child_w in pos_w:
                node.children.append(create_tree(Node(child_w), depth-1, False))
    else:
        # pos_b = game.MoveGenerator(node.value, 'Opening')
        if depth > 0:
            pos_b = game.MoveGenerator(node.value, 'Opening')
            for child_b in pos_b:
                node.children.append(create_tree(Node(child_b), depth-1, True))
    return node
Esempio n. 2
0
def create_tree(position, depth, flag):
    children = []
    if flag:
        pos_w = game.MovesOpening(position)
        if depth > 0:
            for i in range(len(pos_w)):
                child = Node(pos_w[i], create_tree(pos_w[i], depth-1, not flag))
                children.append(child)
        else:
            for i in range(len(pos_w)):
                child = Node(pos_w[i], '')
                children.append(child)
    else:
        pos_b = game.MoveGenerator(position, 'Opening')
        if depth > 0:
            for i in range(len(pos_b)):
                child = Node(pos_b[i], create_tree(pos_b[i], depth-1, not flag))
                children.append(child)
        else:
            for i in range(len(pos_b)):
                child = Node(pos_b[i], '')
                children.append(child)
    return children