小编Bru*_*uno的帖子

python 国际象棋引擎的换位表

这是我上一篇文章的后续内容。该代码运行时没有任何错误,并且可以计算下一个最佳移动。我一直在研究如何将换位表和移动排序合并到我的 negamax 函数中,以使其运行得更快、更准确,但对于像我这样的初学者来说,这似乎有些困难和先进。

你可以在这里找到我的代码。

在研究国际象棋编程维基时,我发现了一些换位表的示例代码:

def negamax(node, depth, alpha, beta, color):
alphaOrig = alpha

## Transposition Table Lookup; node is the lookup key for ttEntry
ttEntry = transpositionTableLookup(node)
if ttEntry.is_valid is True and ttEntry.depth >= depth:
    if ttEntry.flag == EXACT :
        return ttEntry.value
    if ttEntry.flag == LOWERBOUND:
        alpha = max(alpha, ttEntry.value)
    if ttEntry.flag == UPPERBOUND:
        beta = min(beta, ttEntry.value)

    if alpha >= beta:
        return ttEntry.value

if depth == 0 or node is terminal_node:
    return color* heuristic_value_of_node

childNodes = …
Run Code Online (Sandbox Code Playgroud)

python chess alpha-beta-pruning negamax

6
推荐指数
1
解决办法
1895
查看次数

标签 统计

alpha-beta-pruning ×1

chess ×1

negamax ×1

python ×1