问题描述
因此,当代码运行时,AI 会卡在生成移动上。我想知道可能是因为有太多的可能性需要计算而且花费的时间太长。有什么方法可以增加深度或其他任何东西来使 AI 更有效率?谢谢!
def minimax(board,depth,isMaximizing):
if (checkWhichMarkWon(bot)):
return 1
elif (checkWhichMarkWon(player)):
return -1
elif (checkDraw()):
return 0
if (isMaximizing):
bestscore = -800
for key in board.keys():
if (board[key] == ' '):
board[key] = bot
score = minimax(board,depth + 1,False)
board[key] = ' '
if (score > bestscore):
bestscore = score
return bestscore
else:
bestscore = 800
for key in board.keys():
if (board[key] == ' '):
board[key] = player
score = minimax(board,True)
board[key] = ' '
if (score < bestscore):
bestscore = score
return bestscore
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)