了解minmax伪代码

狂奔87

我正在自学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,以较小者为准

由于这是伪代码,因此我们可以假定您将使用用于实现它的任何语言来提供函数maxmin如果没有,您可以自己轻松实现它们。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章