2012-12-04 70 views
0

negamax /極小節點我寫的AI球員黑白棋遊戲,我決定用NegaMax或極小做到這一點。 Pseodocode:創建爲黑白棋/奧賽羅遊戲

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 α 

但我需要發送節點到這個功能,我如何創造這個節點?如創建節點與所有候選條件爲移動狀態,然後在節點大家可能的移動創建子節點?

如果你可以幫助α,β值...

回答

1

節點可能意味着代表一個單一的狀態。在遊戲中,這是董事會的狀態(奧賽羅件的位置,他的舉動是,等)。一般遊戲使用的α/β剪枝,產生的所有未來狀態是可能的,但產生的所有狀態所有可能的位置是沒有的。

如果您使用的是Java,那麼Node對象可能有方法的getChildren()來生成從該狀態的所有可能的舉動,自己Node對象。

對於α,β值,這些都是在Integer.MIN_VALUE的和Integer.MAX_VALUE的

初始化
+0

所以我需要重寫Node.getChildren()方法來讓他回到新的董事會狀態? – JohnDow

+0

是,一套新的董事會狀態 – dfb