Artificial intelligence 连接4中的Alpha beta

Artificial intelligence 连接4中的Alpha beta,artificial-intelligence,minimax,alpha-beta-pruning,Artificial Intelligence,Minimax,Alpha Beta Pruning,在我将alpha-beta修剪应用于Connect-Four游戏之后,我的minimax算法返回了非常糟糕的移动选择 def get_next_move(board, player, depth, alpha, beta) : score = get_score(board, depth) if score is not None : return score, board if depth == 0 : return 0, board

在我将alpha-beta修剪应用于Connect-Four游戏之后,我的minimax算法返回了非常糟糕的移动选择

def get_next_move(board, player, depth, alpha, beta) :
    score = get_score(board, depth)
    if score is not None :
        return score, board
    if depth == 0 :
        return 0, board

    if player is AI :
        best = LOSS
        best_move = None
        possible_moves = get_possible_moves(board, player)

        for move in possible_moves :
            move_score = get_next_move(move, PLAYER, depth-1, alpha, beta)[0]
            if move_score >= best :
                best = move_score
                best_move = move
                alpha = max(alpha, best)
            if alpha >= beta :
                break
        return best, best_move
    else :
        best = WIN
        best_move = None
        possible_moves = get_possible_moves(board, player)

        for move in possible_moves :
            move_score = get_next_move(move, AI, depth-1, alpha, beta)[0]
            if move_score <= best :
                best = move_score
                best_move = move
                beta = min(best, beta)

            if beta <= alpha :
                break
        return best, best_move
def下一步行动(棋盘、玩家、深度、阿尔法、贝塔):
得分=得分(板、深度)
如果分数不是零:
回击得分
如果深度=0:
返回0,板
如果玩家是AI:
最佳=损失
最佳移动=无
可能的移动=获得可能的移动(棋盘、玩家)
对于可能的移动,请执行以下操作:
移动分数=获得下一个移动(移动,玩家,深度1,阿尔法,贝塔)[0]
如果移动得分>=最佳:
最佳=移动分数
最佳移动=移动
阿尔法=最大值(阿尔法,最佳值)
如果α>=β:
打破
返回最佳,最佳移动
其他:
最佳=胜利
最佳移动=无
可能的移动=获得可能的移动(棋盘、玩家)
对于可能的移动,请执行以下操作:
移动分数=获得下一步移动(移动,人工智能,深度1,阿尔法,贝塔)[0]

如果移动分数,您需要向我们展示
get\u score
get\u mably\u moves
功能。您的alpha-beta算法的实现似乎没有任何问题,因此您的启发式可能是问题所在。您需要向我们展示
get_score
get_mable_moves
函数。您的alpha-beta算法的实现似乎没有任何问题,因此您的启发式可能是问题所在。