2016-03-01 73 views
1

我在教自己的minimax算法,我只是有几个问题,我希望有人可以回答。了解minmax伪代码

首先在行05 - :=是什么意思?

也在线08/14我注意到方法maxmin被调用两个参数,该方法返回什么?它会返回到目前为止发现的最大值或最小值吗?有没有这个伪代码的例子还是我误解?

01 function minimax(node, depth, maximizingPlayer) 
02  if depth = 0 or node is a terminal node 
03   return the heuristic value of node 

04  if maximizingPlayer 
05   bestValue := −∞ 
06   for each child of node 
07    v := minimax(child, depth − 1, FALSE) 
08    bestValue := max(bestValue, v) 
09   return bestValue 

10  else (* minimizing player *) 
11   bestValue := +∞ 
12   for each child of node 
13    v := minimax(child, depth − 1, TRUE) 
14    bestValue := min(bestValue, v) 
15   return bestValue 
+1

:=是一项任务。 – Maroun

回答

1
  • bestValue := −∞:分配是负面的无穷大(最低可能的数目)来bestValue
  • max(bestValue, v)返回bestValuev,取其较大
  • min(bestValue, v)返回bestValuev,取其是

由于这是伪代码,我们可以假设,任何语言,你会使用来实现它提供的功能maxmin。如果不是,您可以轻松地自行实施。