I am currently trying to make a good AI for Othello, and have done so using the Minimax algorithm. However, when I tried to make a deeper search using alpha-beta pruning, it seemed like the algorithm was playing terribly. I checked it with other sources like Wiki and Berkely.edu , and I think I have implemented it correctly, but I still can't find the problem.
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