patternMinor
About randomness and minmax algorithm with alpha beta pruning
Viewed 0 times
alphawithrandomnessalgorithmminmaxbetapruningaboutand
Problem
Will choosing the child of a node randomly in the alpha beta algorithm have a better chance to get a cut off than choosing them in order?
Here's the pseudocode with my addition marked with ***.
I ran a small sample with this on a connect four game and it does seem to run a little faster, but when I actually count the cutoffs with and without randomness, there are more cutoffs without randomness. That's a little odd.
Is it possible to prove that it's faster (or slower)?
Here's the pseudocode with my addition marked with ***.
function alphabeta(node, depth, α, β, maximizingPlayer)
if depth = 0 or node is a terminal node
return the heuristic value of node
arrange childs of node randomly ***
if maximizingPlayer
v := -∞
for each child of node
v := max(v, alphabeta(child, depth - 1, α, β, FALSE))
α := max(α, v)
if β ≤ α
break (* β cut-off*)
return v
else
v := ∞
for each child of node
v := min(v, alphabeta(child, depth - 1, α, β, TRUE))
β := min(β, v)
if β ≤ α
break (* α cut-off*)
return vI ran a small sample with this on a connect four game and it does seem to run a little faster, but when I actually count the cutoffs with and without randomness, there are more cutoffs without randomness. That's a little odd.
Is it possible to prove that it's faster (or slower)?
Solution
It's neither faster nor slower, since it depends on your order. Your order might be the best possible order, in which case randomness hurts; or it might be the worst possible order, in which case randomness helps.
If you want to guarantee not hitting a worst case behavior, you can use randomness. But it might be better to choose the order heuristically using less than full randomness.
If you want to guarantee not hitting a worst case behavior, you can use randomness. But it might be better to choose the order heuristically using less than full randomness.
Context
StackExchange Computer Science Q#56824, answer score: 4
Revisions (0)
No revisions yet.