【发布时间】:2015-10-12 21:20:55
【问题描述】:
我如何知道何时可以停止增加使用 negamax alpha beta 剪枝和转置表的迭代深化算法的深度?以下伪代码取自 wiki 页面:
function negamax(node, depth, α, β, color)
alphaOrig := α
// Transposition Table Lookup; node is the lookup key for ttEntry
ttEntry := TranspositionTableLookup( node )
if ttEntry is valid and ttEntry.depth ≥ depth
if ttEntry.Flag = EXACT
return ttEntry.Value
else if ttEntry.Flag = LOWERBOUND
α := max( α, ttEntry.Value)
else if ttEntry.Flag = UPPERBOUND
β := min( β, ttEntry.Value)
endif
if α ≥ β
return ttEntry.Value
endif
if depth = 0 or node is a terminal node
return color * the heuristic value of node
bestValue := -∞
childNodes := GenerateMoves(node)
childNodes := OrderMoves(childNodes)
foreach child in childNodes
val := -negamax(child, depth - 1, -β, -α, -color)
bestValue := max( bestValue, val )
α := max( α, val )
if α ≥ β
break
// Transposition Table Store; node is the lookup key for ttEntry
ttEntry.Value := bestValue
if bestValue ≤ alphaOrig
ttEntry.Flag := UPPERBOUND
else if bestValue ≥ β
ttEntry.Flag := LOWERBOUND
else
ttEntry.Flag := EXACT
endif
ttEntry.depth := depth
TranspositionTableStore( node, ttEntry )
return bestValue
这是迭代深化调用:
while(depth < ?)
{
depth++;
rootNegamaxValue := negamax( rootNode, depth, -∞, +∞, 1)
}
当然,当我知道游戏中的总步数时,我可以使用depth < numberOfMovesLeft 作为上限。但是如果没有给出这些信息,我什么时候知道另一个 negamax 调用并没有给出比上一次运行更好的结果?我需要对算法进行哪些更改?
【问题讨论】:
-
return color * the heuristic value of node可能就是通常所说的“评估函数”? -
是的,完全正确! (取决于玩家)
-
我的直觉是,当您增加深度并重新评估游戏树时,之前运行的限制应该会失效。这意味着转置表基本上毫无价值(因为它基于不同的(错误的)终端评估。(这被称为评估函数的“水平效应”,IIRC)
标签: algorithm artificial-intelligence alpha-beta-pruning