



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Madam Amrita Ahuja distributed this handout in class of Artificial Intelligence course at Central University of Jammu and Kashmir. This handout explains important concepts including: Games, Csp, Search, Function, Depth, Max-Value, Sv-Vector, Alpha, Beta, Pruning, Bounds, Progressive, Deepening
Typology: Exercises
1 / 6
This page cannot be seen from the preview
Don't miss anything!




A) General Minimax search:
function max-value(state, depth)
function min-value(state, depth)
SV (state) returns the static value of the game state. These are the numbers we give you as the leaf nodes in the game search tree. They are generally in the perspective of the current player.
At the very top level your max-value function should return the best move (as well as the best value), so a slight modification is needed here:
function top-level-max-value(state, depth)
For example, calling top-level-max-value(start-state, 10) will search the tree up to depth of
B) Minimax Search As One Function:
The functions max-value and min-value in minimax search can be expressed as a single function;
The single function version works for zero-sum games, which assumes that:
SV(A, state) = -SV(B, state)
You can find the static value of a particular game board from A's perspective by negating the static value from B's perspective.
function minimax(state, depth, player)
Here player = {0, 1} (A or B) next(player) returns the next player to play; so next(0) = 1 and next(1) = 0.
C) General N-player Minimax:
For a game with N-players taking turns in sequential order A, B, C, D...n : You can use a general version of the one-function minimax to search for the best move.
function n-player-minimax(state, depth, player)
The leaves of the n-player game tree now have a vector of static value scores:
SV-vector(state) => (SV(player_1), SV(player_2), SV(player_n))
vector-max[player] is a function that will find the max vector wrt to the player-th element in the vectors.
Example:
vector-max[0]( ( 1 , 2, 3), ( 2 , 3, 1) ) returns (2, 3, 1) since wrt to the 0th element 2 > 1 vector-max[2]( (1, 2, 3 ), (2, 3, 1 ) ) returns (1, 2, 3) since wrt to the 2nd element 3 > 1
Ties are broken with preference for the left most vector (or the one found earlier.)
D) Minimax with Alpha Beta Pruning:
function max-value(state, depth, alpha, beta):
function tree-rotation-optimizer: From level in [1 ... n] if level is MAX then sort nodes at this level from smallest to largest else if level is MIN then sort nodes at this level from largest to smallest
NOTE: On Quizzes we usually ask you to fill in the static values at inner nodes by running minimax from the leaf up to root.
G: alpha-beta-search + progressive deepening + tree-rotation-optimizer
Here is a rough sketch implementation of how these 3 elements work together as a speed up for game search.
Step 1. Run alpha-beta-search up to depth d. This will yield some static values for (un-pruned) leaf nodes at depth d.
Step 2. Using these computed static values compute the values associated with intermediate nodes by running minimax from leaf up to root.
Step 3. Run the tree-rotation-optimizer on this (possibly-pruned) tree.
Step 4. Record at each node, the ordering of its children.
Step 5. Run alpha beta search at depth d + 1. But when computing the next-moves for any node, lookup the node-ordering from step 4. Evaluate alpha beta with nodes sorted using this ordering. NOTE: Any nodes not in the ordering will automatically receive the lowest priority; such nodes come from having been pruned in alpha beta search.
Note: The results of the tree rotation optimizer only influences alpha beta search evaluation order. It will not actually guarantee maximum pruning at every stage. This is because:
Constraint Types โ Unary Constraints - constraint on single variables (often used to reduce the initial domain) โ Binary Constraints - constraints on two variables C(X, Y) โ n-ary Constraints constraints involving n variables. Any n-ary variables n > 2 m Can always be expressed in terms of Binary constraints + Auxiliary variables
Search Algorithm types:
You can replace DFS with Best-first Search or Beam-search if variable assignments have "scores", or if you are interested in the best assignment.
Variable domain (VD) table - book keeping for what values are allowed for each variable.
Variable Selection Strategies:
Forward Checking Pseudo Code:
Assume all constraints are Binary on variables X, and Y. constraint.get_X gives the X variable constraint.get_Y gives the Y variable X.domain gives the current domain of variable X.
forward_checking( state )
function check_and_reduce(state, X=x)
forward_checking_with_prop_thru_singletons( state )