Minimax and Alpha-beta pruning Flashcards
What is a Game tree?
Directed graph that represents every possible outcome
What happens if the entire game tree cannot be generated?
Generate a partial tree
What type of search algorithm is the minimax algorithm?
DFS
How does the minmax Alg work?
alternate turns, 1st move/layer = max, next layer = min until leaf node is reached
What does the Max player try to do in minimax algorithm?
Maximize the minimum values at a position
What does the Min player try to do in minimax algorithm?
Minimize max values at position
Explanation of Minimax Alg
Repeat until entire tree is traversed{
if (limit is reached){ compute static value of current position relative to the appropriate player and report result }
else if (level is a minimising level){ use the minimax on the children of the current position. return min value of the results}
else{ if level is max level, use minimax on the children of the current position. return max of the results}
What is the advantages of Minimax?
Considers all possible moves = most optimal moves to be made = very accurate
What are the dis advantages of Minimax?
large branching factor for complex games = slow
What is the goal for Alpha Beta Pruning?
Remove branches that have no effect.
What does the alpha value store of AB Algorithm
best already explored option along a path to the root for the max layer.
Max score the Maximizer can receive (only maximizer can change this value)
What does beta store of AB Algorithm?
Best already explored option along the path to the root for minimizing layer
Min score the minimizer can receive (only minimizer can change this value)
When can we prune branches?
if A>=B (the min score is bigger or the same than the current max score)
Code for AB pruning + minimax
A = inf, B = -inf
if( node = leaf){ return value}
if(node = min node){
For( each of the children){ apply Minimax + ABP;
if (value returned < B) { B = value}
if(B <= A){ return B}
}
if(node = max node){
For( each of the children){ apply Minimax + ABP;
if(returned value > A){ A = value}
if(A >= B){return A}
}
return A;