【问题标题】:Understanding the minmax pseudocode理解 minmax 伪代码
【发布时间】:2016-06-13 19:05:51
【问题描述】:

我正在自学极小极大算法,我只是有几个问题希望有人能回答。

首先在第 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

【问题讨论】:

  • := 是一个作业。
  • 您所说的“是否有这样的伪代码示例还是我误解了?”是什么意思。它已经在伪代码中

标签: pseudocode minimax


【解决方案1】:
  • bestValue := −∞:将负无穷大(可能的最小数字)分配给bestValue
  • max(bestValue, v) 返回bestValue v,以较大者
  • min(bestValue, v) 返回bestValue v,以较小者

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 1970-01-01
    • 2012-07-20
    • 2016-02-28
    • 1970-01-01
    相关资源
    最近更新 更多