<p>我目前正在尝试为奥赛罗做一个好的人工智能,并且已经使用了极大极小算法。然而,当我试图使用alpha-beta剪枝进行更深入的搜索时,这个算法似乎玩得很糟糕。我查了其他来源,比如Wiki和伯克利.edu,我想我已经正确地执行了它,但是我仍然找不到问题。在</p>
<pre><code>def alphabeta(board, player, a, b, lev):
h = heur(board, player)
if lev == 0:
return h, None
poss = get_legal_moves(board, player)
if len(poss) == 0:
return h, None
move = 0
for x in poss:
cpboard = board[:]
cpboard[x] = player
bracket(cpboard, player, x)
a1, q = alphabeta(cpboard, opponent_color(player), a, b, lev-1)
if player is me:
if a1 > a:
a, move = a1, x
else:
if a1 < b:
b, move = a1, x
if b <= a:
break
if player is me:
return a, move
else:
return b, move
</code></pre>