小编Tr3*_*ger的帖子

如何为connect 4实现换位表?

我在 python 中创建了一个连接 4 AI,我为此使用了带迭代深化和 alpha beta 修剪的 minimax。对于更大的深度,它仍然很慢,所以我想实现一个换位表。在阅读它之后,我想我得到了一般的想法,但我还没有完全让它发挥作用。这是我的代码的一部分:(minimax 的最大化部分):

    if(isMaximizing):
    maxEval = -99999999999
    bestMove = None
    # cache.get(hash(board)) Here's where i'd check to see if the hash is already in the table 
    # if so i searched for the best move that was given to that board before.

    # loop through possible moves
    for move in [3,2,4,1,5,0,6]:
        if moves[move] > -1:
            # check if time limit has been reached for iterative deepening
            if startTime - time.time() <= -10:
                timeout …
Run Code Online (Sandbox Code Playgroud)

python artificial-intelligence hashtable iterative-deepening minimax

5
推荐指数
1
解决办法
575
查看次数