我为reversi游戏编写AI播放器,我决定用NegaMax或MiniMax。伪代码:
function negamax(node, depth, α, β, color)
if node is a terminal node or depth = 0
return color * the heuristic value of node
else
foreach child of node
val := -negamax(child, depth-1, -β, -α, -color)
{the following if statement constitutes alpha-beta pruning}
if val≥β
return val
if val≥α
α:=val
return α但是我需要发送node到这个函数,如何创建这个节点?像创建所有可能的状态移动的节点,然后为每个可能在节点中移动的人创建子节点?
如果你能在α,β值上提供帮助...
发布于 2012-12-05 04:00:00
节点很可能表示单个状态。在游戏中,这是棋盘的状态(对于奥赛罗来说,棋子的位置,它是谁的移动。等等)。通常,在使用alpha/beta剪枝的游戏中,可以生成所有后续状态,但不能生成所有可能位置的所有状态。
如果您使用的是Java语言,那么节点对象可能有一个getChildren()方法来从该状态生成所有可能的移动,即节点对象本身。
至于在Integer.MIN_VALUE和Integer.MAX_VALUE中初始化的α,β值
https://stackoverflow.com/questions/13710713
复制相似问题