您的位置:首页 > 其它

Artificial Intelligence Minimax and Alpha Beta Pruning code

2012-05-18 18:37 405 查看
function alphabeta(node, depth, α, β, Player)

if depth = 0 or node is a terminal node

return the heuristic value of node

if Player = MaxPlayer

for each child of node

α := max(α, alphabeta(child, depth-1, α, β, not(Player) ))

if β ≤ α

break (* Beta cut-off *)

return α

else

for each child of node

β := min(β, alphabeta(child, depth-1, α, β, not(Player) ))

if β ≤ α

break (* Alpha cut-off *)

return β

(* Initial call *)

alphabeta(origin, depth, -infinity, +infinity, MaxPlayer)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: