예제 #1
0
def create_tree(node, depth, flag):
    if flag:
        if depth > 0 and not end_game(node):
            pos_w = game.MovesMidgameEndgame(node.value, game.board)
            for child_w in pos_w:
                node.children.append(create_tree(Node(child_w), depth-1, False))
    else:
        if depth > 0 and not end_game(node):
            pos_b = game.MoveGenerator(node.value, 'MidgameEndgame')
            for child_b in pos_b:
                node.children.append(create_tree(Node(child_b), depth-1, True))
    return node
예제 #2
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
예제 #3
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
예제 #4
0
def newStaticEstimation(position):
    # print('-- StaticEstimation --')
    global leaves_count
    game.leaves_count += 1
    w_count, b_count = 0, 0
    for loc in range(len(position)):
        if position[loc] == 'W':
            w_count += 1
        if position[loc] == 'B':
            b_count += 1
    move = len(game.MoveGenerator(position, 'MidgameEndgame'))
    if b_count <= 2:
        return 100000
    else:
        if w_count <= 2:
            return -100000
        else:
            if move == 0:
                return 100000
            else:
                return 1000 * (w_count -
                               b_count) - move + 4000 * diff_closeMill(
                                   position) + 1000 * blocked_piece(position)