Пример #1
0
def MinMax(board, depth):  #black turn
    if depth == 0: return [static(board), board, board]
    inv = game.getInverse(board)
    positions = game.generateAdd(inv)
    if not positions:
        return (static(board), board, board)
    else:
        v = [float('inf'), None, None]
        for pos in positions:
            v = min(v, MaxMin(pos, depth - 1)[:-1] + [pos], key=lambda x: x[0])
        return v
Пример #2
0
def MaxMin(board, depth):  #white turn
    game.change(board)
    if depth == 0: return [static(board), board, board]
    positions = game.generateAdd(board)
    if not positions:
        return (static(board), board, board)
    else:
        v = [-float('inf'), None, None]
        for pos in positions:
            v = max(v, MinMax(pos, depth - 1)[:-1] + [pos], key=lambda x: x[0])
        return v