我正在自学minimax算法,我只是想问几个问题,希望有人能回答。
首先在05行-这:=
是什么意思?
同样在08/14行,我注意到该方法max
或被min
两个参数调用,该方法将返回什么?它会返回到目前为止找到的最大值还是最小值?是否有一个伪代码示例,还是我误会了?
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
bestValue := −∞
:将负无穷大(可能的最低数字)分配给 bestValue
max(bestValue, v)
返回bestValue
或 v
,以较大者为准min(bestValue, v)
返回bestValue
或 v
,以较小者为准由于这是伪代码,因此我们可以假定您将使用用于实现它的任何语言来提供函数max
和min
。如果没有,您可以自己轻松实现它们。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句