Negamax通常如下所示:
function negamax(node, depth, α, β, color) is
if depth = 0 or node is a terminal node then
return color × the heuristic value of node
childNodes := generateMoves(node)
childNodes := orderMoves(childNodes)
value := −∞
foreach child in childNodes do
value := max(value, −negamax(child, depth − 1, −β, −α, −color))
α := max(α, value)
if α ≥ β then
break (* cut-off *)
return value最初的调用是negamax(rootNode, depth, −∞, +∞, 1),如果最大化玩家调用它。
我以最大化玩家调用Negamax的方式实现了Negamax,但是每个rootNode都是最大化玩家的移动方式之一:
function negamaxHandler() is
bestValue := −∞
bestNode := null
childNodes := generateMoves(currentGameState)
foreach child in childNodes do
value := negamax(child, depth-1, ???, ???, ???)
if value > bestValue then
bestValue := value
bestNode := child
return bestNode因为Negamax返回一个值,所以我想要一个board状态(move)。因此,我手动完成了Negamax的第一级操作,这样我就可以解析出最佳的移动位置。但是,我应该在哪些值上调用negamax呢?为了更具有声明性,如果最大化玩家名为negamaxHandler,negamaxHandler应该调用:
negamax(child, depth-1, −∞, +∞, 1)
-negamax(child, depth-1, −∞, +∞, 1)
negamax(child, depth-1, +∞, −∞, -1)
-negamax(child, depth-1, +∞, −∞, -1)还是别的什么?澄清:
negamaxHandler
negamaxHandler中的negamax应该最小化发布于 2019-12-27 08:33:43
正确的函数调用最终为-negamax(child, depth-1, −∞, +∞, -1),尽管需要更改negamaxHandler函数:
function negamaxHandler(α, β, color) is
bestValue := −∞
bestNode := null
childNodes := generateMoves(currentGameState)
foreach child in childNodes do
value := -negamax(child, depth-1, -β, -α, -color)
if value > bestValue then
bestValue := value
bestNode := child
α := max(bestValue, α)
if α ≥ β then
break
return bestNodenegamaxHandler被称为negamaxHandler(−∞, +∞, 1)。
https://stackoverflow.com/questions/59438037
复制相似问题