【发布时间】:2021-11-20 23:25:39
【问题描述】:
分析 Alpha-beta 剪枝算法在其 fail-hard 和 fail-soft 版本中,我找不到它的行为差异:
故障排除
function alphabeta(node, depth, α, β, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
if value ≥ β then
break (* β cutoff *)
α := max(α, value)
return value
else
value := +∞
for each child of node do
value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
if value ≤ α then
break (* α cutoff *)
β := min(β, value)
return value
软故障
function alphabeta(node, depth, α, β, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
α := max(α, value)
if value ≥ β then
break (* β cutoff *)
return value
else
value := +∞
for each child of node do
value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
β := min(β, value)
if value ≤ α then
break (* α cutoff *)
return value
我了解在 fail-soft 中,alpha 和 beta 都是在评估 break de for-loop(分支)之前确定的,但是:
- 如果必须结束分支中的分析,则确定的 alpha 和 beta 值不会影响将在其上方找到的其余其他分支中执行的分析。我没有正确理解伪代码吗?
非常感谢!
【问题讨论】:
标签: algorithm alpha-beta-pruning