Ai Unit 2 Notes
Ai Unit 2 Notes
Unit
State x, successor – FN (x) returns a set of < action, successor> ordered pairs, where each
action is a legal action in a state x and each successor is a state that can be reached from x by
applying that action.
State Space
The set of all possible states reachable from the initial state by any sequence of actions. The
initial state and successor function defines the state space. The state space forms a graph in
which nodes are state and axis between the nodes are action.
Path
A path in the state space is a sequence of state connected by a sequence of actions.
Example: In chess, the goal is to reach a state called ―checkmate‖ where the opponent‘s
king is under attack and can‘t escape.
Step cost of taking an action ‗a‘to go from one state ‗x‘to state ‗y‘is denoted by C(x,a,y)
C-Cost , x,y- states , Action , Step costs are non-negative
These 4 elements are gathered into a data structure that is given as input to problem solving
algorithm. A solution quality is measured by path cost function. An optimal solution has lowest path
cost among all solutions.
There are 2 kinds of search, based on whether they use information about the goal.
Uninformed or blind search strategies uses only the information available in the problem
definition
These search algorithms do not have additional info about states beyond problem definition.
No information is used to determine preference of one child over other, This means that it does not
use any information that helps it to reach the goal, like closeness or location of the goal. This form
of search, ignores where they are going until they find a goal and report success.
Look at the above tree with nodes starting from root node, R at the first level, A and B at
the second level and C, D, E and F at the third level. If we want to search for node E then BFS will
search level by level. First it will check if E exists at the root. Then it will check nodes at the second
level. Finally it will find E a the third level.
Advantages:
Problem Solving Methods 2.9
• DFS consumes very less memory space.
• It will reach at the goal node in a less time period than BFS if it traverses in a right path.
• It may find a solution without examining much of search because we may get the desired
solution in the very first go.
Disadvantages:
• It is possible that many states keep reoccurring. There is no guarantee of finding the
goal node.
• Sometimes the states may also enter into infinite loops.
• In the worst case that goal will be in the shallowest level in the search tree resulting in
generating all tree nodes which are O(bm).
• With branching factor b and maximum depth m, DFS requires storage of only bm + 1
nodes which are O(bm) compared to the O(bd+1) of the BFS.
◦ Time Complexity - O(bd)
◦ Space Complexity - O(bd+1)
Space Complexity:
The space complexity is O(bC/e) as the time complexity of UCS.
The basic idea is not allowing expansion after certain depth. This problem is most useful if
one is aware of the maximum depth of the solution.
Algorithm:
1) Set the depth limit to the maxdepth of search
2) Initial node = current node
If initial node = goal, return
3) If depth(initial node) > depth limit
return
else
expand (initial node)
save (successors) using stack
go to step2
The search method is not optimal, there is no guarantee that the search will give a solution
that is optimal, since if finds the solution that is within the limits.
One can view DFS as a special case of the depth DLS, that DFS is DLS with l = infinity.
DLS is not optimal even if l > d. (d – depth)
IDS works by looking for the best search depth d, thus starting with depth limit 0 and make
a BFS and if the search failed it increase the depth limit by 1 and try a BFS again with depth 1 and
so on – first d = 0, then 1 then 2 and so on – until a depth d is reached where a goal is found.
Algorithm: IDS
Problem Solving Methods 2.11
1) Set depth-limit < -- 0
2) Do
a) Solution =DLS(depth-limit, initial node)
b) If (solution = goal state) then return
else
depth-limit=depth-limit + 1
Continue
Major issue with this algorithm is regeneration of tree for every depth searched. In cases
where depth factor is unknown IDS is preferred. It is complete and optimal, its time complexity is
O(bd) and space complexity is O(bd).
Algorithm:
1) Generate a possible solution, which can be a node in the problem space or it can be a
path from start node.
2) Test if the possible solution is real, ie, compare with the goal state
3) Check solution, if true, return the solution, else go to step 1.
Evaluation of which path to be considered is done by heuristic function.
Generator
Possible Solution
Correct Solution
Tester Stop
Incorrect Solution
Example:
Step 1:
Consider the node A as our root node. So the first element of the queue is A whish is not our
goal node, so remove it from the queue and find its neighbour that are to inserted in ascending
order.
2.14 Artificial Intelligence
Problem Solving Methods 2.15
Advantage:
• It is more efficient than that of BFS and DFS.
• Time complexity of Best first search is much less than Breadth first search.
• The Best first search allows us to switch between paths by gaining the benefits of both
breadth first and depth first search. Because, depth first is good because a solution can
be found without computing all nodes and Breadth first search is good because it does
not get trapped in dead ends.
Disadvantages:
• Sometimes, it covers more distance than our consideration.
Branch and Bound is an algorithmic technique which finds the optimal solution by keeping
the best solution found so far. If partial solution can’t improve on the best it is abandoned, by this
method the number of nodes which are explored can also be reduced. It also deals with the
optimization problems over a search that can be presented as the leaves of the search tree. The usual
technique for eliminating the sub trees from the search tree is called pruning. For Branch and Bound
algorithm we will use stack data structure.
Concept:
Step 1: Traverse the root node.
Step 2: Traverse any neighbour of the root node that is maintaining least distance from the
root node.
Step 3: Traverse any neighbour of the neighbour of the root node that is maintaining
least distance from the root node.
Step 4: This process will continue until we are getting the goal node.
2.16 Artificial Intelligence
Algorithm:
Step 1: PUSH the root node into the stack.
Step 2: If stack is empty, then stop and return failure.
Step 3: If the top node of the stack is a goal node, then stop and return success.
Step 4: Else POP the node from the stack. Process it and find all its successors. Find out
the path containing all its successors as well as predecessors and then PUSH
the successors which are belonging to the minimum or shortest path.
Step 5: Go to step 5.
Step 6: Exit.
Let us take the following example for implementing the Branch and Bound algorithm.
Problem Solving Methods 2.17
Step 2:
Step 3:
Step 4:
Disadvantages:
• The load balancing aspects for Branch and Bound algorithm make it parallelization
difficult.
• The Branch and Bound algorithm is limited to small size network. In the problem of
large networks, where the solution search space grows exponentially with the scale of
the network, the approach becomes relatively prohibitive.
OR Graph
Here a graph is used that is named as an OR - graph, since each of its branches represents
alternative problem solving path. The Best First Search, selects the most promising of the nodes
that has been generated so far. This can be achieved by applying appropriate Heuristic function to
each of them.
Heuristic function:
f(n) = h(n) where, h(n) - estimated straight line distance from node n to goal
To implement the graph search procedure , two list of nodes are used.
OPEN- nodes that have been generated but have not been visited yet
Closed - nodes that have been already visited
Algorithm:
1) The 1st step is to define the OPEN list with a single node, the starting node.
2) The 2nd step is to check whether or not OPEN is empty. If it is empty, then the algorithm
returns failure and exits.
3) The 3rd step is to remove the node with the best score, n, from OPEN and place it in
CLOSED.
4) The 4th step “expands” the node n, where expansion is the identification of successor
nodes of n.
5) The 5th step then checks each of the successor nodes to see whether or not one of them
is the goal node. If any successor is the goal node, the algorithm returns success and the
solution, which consists of a path traced backwards from the goal to the start node.
Otherwise, proceeds to the sixth step.
6) In 6th step, for every successor node, the algorithm applies the evaluation function, f, to
it, then checks to see if the node has been in either OPEN or CLOSED. If the node has
not been in either, it gets added to OPEN.
Problem Solving Methods 2.19
7) Finally, the 7th step establishes a looping structure by sending the algorithm back to the
2nd step. This loop will only be broken if the algorithm returns success in step 5 or
failure in step 2.
Consider the following graph as an example,
A* Search
• A* is an informed search algorithm. The best first search is a simplified version of A*
algorithm. This is the widely used approach for pathfinding.
• Evaluation Function f(n) represents the total cost.
• f(n) = g(n) + h(n), where g(n) = cost incurred so far to reach n, h(n) = estimated cost
from n to goal state.
Algorithm
1) Begin with open list containing only the initial state.
◦ Let g(n) =0 and h(n) = value whatever is
◦ So, f(n) = h(n) as g(n)=0
2) Do
If no nodes exists in open list, return failure to goal achieved
Else
a) Select and remove node from open list with low f value
b) Let this be current node ’c’
c) Put c on the closed list
d) Check if c= goal state, return solution.
e) If not generate successor for c and for every successor,
(i) Save path from successor to C
(ii) Calculate g(successor)g(c) + cost of reaching to successor from c
3) End
This algorithm will be successful when the following three cases are verified.
• Check if the successor is on open list
• Check if the successor is on only closed list.
• Check if the successor is neither on the open list nor on the closed list.
Admissible A*
The heuristic function h (n) is called admissible if h(n) is never larger than h*(n), namely
h(n) is always less or equal to true cheapest cost from n to the goal.
Problem Solving Methods 2.21
A* is admissible if it uses an admissible heuristic, and h (goal) = 0.
If the heuristic function, h always underestimates the true cost (h (n) is smaller than h*(n)),
then A* is guaranteed to find an optimal solution.
Advantages:
• It is complete and optimal.
• It is the best one from other techniques. It is used to solve very complex problems.
• It is optimally efficient, i.e. there is no other optimal algorithm guaranteed to expand
fewer nodes than A*.
Disadvantages:
• This algorithm is complete if the branching factor is finite and every action has fixed
cost.
• The speed execution of A* search is highly dependant on the accuracy of the heuristic
algorithm that is used to compute h (n).
• It has complexity problems.
Aspects of problem states are evaluated, and the weights given to individual aspects are
chosen in a way that the value of the heuristic function at a given node in the search process gives
as good an estimate as possible of whether that node is on the desired path to a solution.
Heuristic functions can play an important part in efficiently guiding a search process.
Heuristic functions provide a good estimate of a path. The below fig shows the heuristic functions
for a few problems.
Tic-Tac-Toe
I for each row in which we could win and in which we already
have one piece plus 2 for each such row in which we have two
pieces
Sometimes a high value of the heuristic function indicates a good position, low value
indicates an advantageous situation. No matter the way function is stated. The program uses the
values of the function attempt to minimize it or to maximize it as appropriate.
2.22 Artificial Intelligence
• The Heuristic function (HF) guide the search process in the most profitable direction by
suggesting which path to follow first when more than one is available.
• H.F estimates the true merits of each node in the search tree, the more direct the solution
process.
• H.F is so good that definitely no search would be required.
• For many problems, the cost of computing the value of such a function would outweigh
the effort in the search process.
• Compute a perfect Heuristic function by doing a complete search from the node in
question and determining whether it leads to a good solution.
• Trade – off (Balance) between the cost of evaluating a heuristic function and the savings
in search time that the function provides.
• Some heuristics used to define the control structure that guides the application of rules
in the search process.
Test function provides an estimate of how close a given state is to a goal state.
The generate procedure that often the computation of the heuristic function is done at
almost no cost at the same time that the test for a solution is being performed.
Example:
Suppose we are in an unfamiliar city without a map and want to get downtown. Our Aim is
for the tall buildings.
Heuristic Function is distance between the current location and the location of the tall
buildings and desirable states are those in which this distance is minimized. For this problem,
hill climbing can terminate whenever a goal state is reached.
• Absolution solution exist whenever it is possible to recognize a goal state just by
examining it.
• Relative solution exist, for maximization problems, such as T S P , there is no a prior
goal state.
2.6.2 Simple Hill climbing
Algorithm: Simple Hill climbing
1) Evaluate the initial state. If it is also a goal state, then return it and quit. Otherwise,
continue with the initial state as the current state.
Problem Solving Methods 2.23
2) Loop until a solution is found or until there are no new operators left to be applied in
the current state:
a) Select an operator that has not yet been applied to the current state and apply it to
produce a new state.
b) Evaluate the new state.
(i) If it is a goal state, then return it and quit.
(ii) If it is not a goal state but it is better than the current state, then make it the
current state.
(iii) If it is not better than the current state, then continue in the loop.
Algorithm terminate by not finding a goal state but by getting to a state from which no better
states can be generated. (i.e.) if the program has reached either a local maximum, a plateau or a
ridge.
A local maximum is better than all its neighbors but not better than far away states. All
moves appear to make things worse. Local maxima occur within sight of a solution. They are called
foothills at this point.
A Plateau is a flat area in which a whole set of neighboring states have the same value. It
is not possible to determine the best direction in which to move by making local comparisons,.
A ridge is a kind of local maximum. It is higher than surrounding areas and that itself has a
slope. But the orientation of the high region, Compared to the set of available moves and directions
they move, makes it impossible to traverse a ridge by single moves.
A H
H G
G F
F E
E D
D C
C B
B A
Initial state Final state
Local:
Add one point for every block that is resting on the thing it is supposed to be resting on.
Subtract one point for every block that is sitting on the wrong thing.
• Using this function, the goal state has a score of 8.
• The initial state has a score of 4.
• There is only one move from the initial state, namely to move block A to the table that
produces a state with a score of 6.
• The hill – climbing procedure accept the move.
2.26 Artificial Intelligence
• From the new state, there are 3 possible moves, leading to the three states show in below
fig
A
H
G G G
F F F
E E E
D D D
C H C C
B A B A H B
(a) (b) (c)
Fig – shows the Three possible Moves
• These above states have the scores: ( c ) 4, (d) 4, (e) 4.
• Hill climbing will halt because all these states have lower scores than the current state.
• The process has reached a local maximum that is not the global maximum.
• The problem is that by purely local examination of support structures, the current state
appears to be better than any of its successors because more blocks rest on the correct
objects.
• To solve this problem, necessary to disassemble a good local structure because it is in
the wrong global context.
Hill climbing is blamed for this failure to look far enough ahead to find a solution. But we
could also blame the heuristic function and modify it. The following heuristic function in place of
the first one:
Global:
For each block that has the correct support structure, add one point for every block in the
support structure. For each block that has an incorrect support structure, subtract one point for
every block in the existing support structure.
• Using this function the goal state has the score 28.
• The initial state has the score-2.8 moving A to the table yields a state with a score of 21
since A no longer has seven wrong blocks under it
• The three states that can be produced next have the following scores: (c) – 28 (d) – 16,
and (e) – 15.
• This time, steepest – ascent hill climbing will choose move (e), which is the correct one.
Problem Solving Methods 2.27
• This new heuristic function captures the two key aspects of this problem: incorrect
structures are bad and should be taken apart – and correct structures are good and should
be built up.
• Hill climbing procedure fails with the earlier heuristic function works perfectly now.
Example:
Problem of driving down own. The perfect heuristic function need to have knowledge about
one way and deal – end streets, which in case of a strange city is not always available. Sometimes
even perfect knowledge available but not usable.
Example:
Imagine a heuristic function that computes a value for a state by invoking its own problem-
solving procedure to look ahead from the state it is given to find a solution. It knows the exact cost
of finding solution and return cost’s as it’s value. A heuristic function that converts the local hill –
climbing procedure in to a global method by embedding a global method. So far hill climbing is
very inefficient in a large problem space.
Two changes:
(i) The objects function is used in place of the term heuristic function.
(ii) Minimize rather than maximize the value of the objective function. We describe a
process of valley descending rather than hill climbing.
Stimulated annealing, a process is patterned after the physical process of annealing, physical
substances such as metals are melted and then cooled until some solid state is reached. The goal of
this process is to produce a minimal energy final state. This process is one of valley descending in
which the objects function is the energy level. Physical substances move from high to low, so the
valley descending occurs. There is some probability that a translation to a higher energy state will
occur. This probability is given by the function:
P = e-ΔE/kT
Where, At is the positive change, in the energy level T is the temperature and K is
Boltzmann’s constant.
Valley descending that occurs during annealing the probability of a large uphill move is
lower than the probability of a small one.
Probability that an uphill move decrease as the temperature decreases. These moves possible
during the beginning of the process when the temperature is high, and they become less at the end
as the temperature becomes lower. Downhill moves allowed anytime. Large upward moves occur
2.28 Artificial Intelligence
but as the process progresses, only small upward moves are allowed finally the process converges
to a local minimum configuration.
• The rate at which the system is cooled is called the annealing schedule.
• Physical Annealing process are sensitive to the annealing schedule.
• If cooling occurs too rapidly, stable regions of high energy will form or else a local but
not global minimum is reached.
• At high temperatures, random motion is allowed.
• At lower temperature, a lot of time wasted after the final structure has been formed.
The different between stimulated annealing and the simple hill – climbing procedure are
given below:
a) The annealing schedule must be maintained.
b) Moves to worse states may to accepted.
c) It is a good idea to maintain the current state, best state found so far. If the final state is
worse than that earlier state the earlier state is still available.
Implementation of Algorithm”
• Select Annealing schedule, which has three components.
a) The first is the initial value user for temperature.
b) The second is the criteria will be used to decide when the temperature of the system
should be reduced.
1) The third is the amount by which the temperature will be reduced each time it
is changed.
2) Fourth component of the schedule, when to quit.
• Simulated Annealing solve the problems where number of moves from a given state is
very large.
• For such problems, it makes no sense to try all possible moves.
• The Best annealing schedule should be observed in a way that the effect on both the
quality of the solution that is found and the rate at which the process converges.
(i) T approaches zero, the probability of accepting a move to a worse state goes to zero
and simulated annealing becomes identical to simple hill climbing.
(ii) Computing the probability of accepting a move is the ratio E/ T. Thus it’s
important that values of T be scaled so this ratio is meaningful.
Example:
cyptarithmatic puzzles.
Example:
Assume we start with one constraint, N = E + 1. If we added the constraint N= 3, we
propagate that to get a stronger constraint on E namely.
that E= 2. Constraint propagation arises from the presence of inference rules that allows
additional constraints to be inferred from the ones.
Example:
Cryptarithmetic problem, guessing a particular value for some letter.
Constraint propagation can begin from this new state. Solution is reported. If more guesses
are necessary, then it can proceed.
• If a contradiction is detected, then backtracking used to try a different guess and
proceed.
Algorithm: constraint satisfaction:
1) Propagate available constraints. To do this, first set OPEN to the set of all objects that
must have values assigned to them in a complete solution. Then do until an
inconsistency is detected or until OPEN is empty:
a) Select an object OB from OPEN. Strengthen as much as possible the set of
constraints that apply to OB.
b) If this set is different from the set that was assigned the last time OB was examined
or if this is the first time OB has been examined, then add to OPEN all objects that
share any constraints with OB.
c) Remove OB from OPEN.
2.32 Artificial Intelligence
2) If the union of the constraints discovered above defines a solution, then quit and report
the solution.
3) If the union of the constraints discovered above defines a contradiction, then return
failure.
4) If neither of the above occurs, then it is necessary to make a guess at something in order
to proceed. To do this, loop until a solution is found or all possible solutions have been
eliminated:
a) Select an object whose value is not yet determined and select a way of strengthening
the constraints on that object.
b) Recursively invoke constraint satisfaction with the current set of constraints
augmented by the strengthening constraint just selected.
Algorithm application – Two rules:
(i) Rules that define the way constraints validly be propagated.
(ii) Rules that suggest guesses when guesses are necessary. In some problems, guesses are
not required.
Algorithm – Working:
Consider the crypt arithmetic problem shown in the below fig
Problem:
SEND
+MORE
………
MONEY
Initial state:
No two letters have the same value. The sums
of the digits must be as shown in the problem.
First step:
It does not matter what order the propagation is done since all available propagations will
be performed before the step ends.
Problem Solving Methods 2.33
Second steps:
Though in which order the guesses are tried have a substantial impact on the degree of
search that is necessary.
a) A heuristics help to select the best guess to try first.
b) Example:
c) If there is a letter that has only two possible values and another with six values, there is
better chance of guessing right on the first than on the second.
d) Heuristic explains if there is a letter that participates in many constraints then it is a
good idea to prefer it to a letter that participates in a few.
e) A guess on a highly constrained letter lead to a contradiction or to the generation of
additional constraints.
f) A guess on a less constrained letter, provides less information.
g) The result of the few cycles of processing this example is shown in below fig
Initial state: SEND
+MORE
M=1 ………
S=8 or 9 MONEY
O=0 or 1 O=0
N=E or E+1 N=E+1
C2=1
N+R>8
E< >9
E=2
N=3
R=8 or 9
2+D=Y or 2+D = 10+Y
C1=0 C1=1
2+D=Y 2+D=10+Y
N+R=10+E D=8+Y
R=9 D=8 or 9
S=8 D=9
D=8
Y=0 Y=1
Conflict Conflict
C1,C2, C3 and C4 indicate the carry bits out of the columns, numbering from the right.
Suppose C1 is chosen to guess a value for 1, then we reach dead end as shown in the fig –
1.11 ( b), when this happens, the process will backtrack and C1 = 0
Example:
Reasons through to the result that C1 equals 0. We can process by observing that for C1 to
be 1, it should held:
2+D = 10+Y. For this to be the case, D would have to be 8 or 9. Both S and R must be either
8 or 9 and three letters can’t share two values. So C1 can’t be 1. Some search could be avoided.
Search route takes more or less actual time than does the constraint propagation route depends on
how long it takes to perform the reasoning required for constraint propagation.
Problem Solving Methods 2.35
Second thing to notice:
There are two kinds of constraints:
(i) First kind is simple, list values for a single objects.
(ii) Second kind is complex, describe relationship between or among objects.
Both kinds of constraints play the same role in the constraint satisfaction process and in the
cryptarithmetic example they were treated identically.
• Backward chaining in which operators are selected and then sub goals are setup to
establish the pre-conditions of the operators is called operator sub goaling.
• If the operator doesn’t produce the exact goal state then the second sub problem of
getting from the state it does produce a goal.
• If the difference chosen correctly and if operator is effective at reducing the difference,
then the two sub problems should be easier to solve than the original problem.
• General problem solver (GPS) , people use this GPS to solve problem.
• GPS provide fuzziness of the boundary between building programs that simulate what
people do and building programs that solve a problem.
• Mean – ends Analysis relies on a set of rules that transform one problem state into
another.
• Rules are represented as a left side that describes the conditions that must be met for the
rule to be applicable and a right side describes aspects of the problem state that will be
changed by the application of the rule.
• A separate data structure called a difference table indexes the rules by the differences
that they can be used to reduce.
More operator reduce a different and a given operator able to reduce more than one
difference.
Working of Robot:
• Robot job is to moving a desk with two things on it from one room to another.
• The objects on top must be moved.
• Difference between the start state and the goal state is location of the desk.
• To reduce the difference, either PUSH or CARRY could be chosen.
• If CARRY chosen, its preconditions met.
• It Result in two more differences that must be reduced, the location of robot and size of
desk.
• Location of robot by applying WALK. But no operator change the size of on object.
• This path leads to dead – end.
• We attempt to apply PUSH.
Below fig shows the problem solver’s progress.
A B C D
Push
Start Goal
• Since the desk is already large, and the robot’s arm is empty, those two preconditions
can be ignored.
• The robot can be brought to the correct location by using WALK.
• Surface of the desk can be cleared by two uses of PICKUP.
• After one PICKUP, an attempt to do the second results in another difference the arm
must be empty.
• PUTDOWN used to reduce that difference.
• ONE PUSH is performed, the problem state is close to the goal state.
• The objects placed back on the desk.
• PLACE will put them there.
• Difference is eliminated.
• Robot holding the object.
• The progress of the problem solver shown below fig.
A B C E
D
c) If
To put it simple: Game playing shows several sides of intelligence, particularly the ability
to plan and ability to learn.
Game – Definition:
• A game is an activity or sport usually involving skill, knowledge, or chance, in
which you follow fixed rules and try to win against an opponent or to solve a puzzle.
• A game is an activity among two or more self-regulating decision-makers looking
for to achieve their goals in some limiting environment.
• A game is a form of play with goals and structure.
• When you strip away the category differences and the technical difficulties, all
games share four defining characters: a goal, rules, a feedback system, and voluntary
participation.
Basically heuristic procedure is generate and test procedure, where testing is performed after
the generator has done its part.
The procedure uses the test strategies that will identify and explore the best moves in first
place.
Possible-move generator, only small number of moves are generated. Heuristic is applied
to only some kind of promise. In this generator, the test procedure spend more time evaluating each
of the moves which produce a trustworthy result.
Conclusion - Include heuristic (exploratory) knowledge into both the generator and the
tester, the performance of the overall system will be improved.
Game theory is a set of ideas and techniques for analyzing conflict situations between two
or more parties. The outcomes are determined by their decisions.
Different approaches have given rise to different classes. They are as follows:
• Symmetric Game: This game strategy depends on other techniques that are in practice.
• Zero-sum Game: In this game the loss or gain of winner is balanced by the gain or loss
of other participants.
• Non-Zero sum Game: This game provides situations in which participants may lose or
gain simultaneously.
• Perfect Information Game: A game where, if all moves taken till any point in the game
by all players are known to all players. Example – chess
• Simultaneous Game: Here the actions/moves taken by a player is independent of the
moves/actions of other players.
• Sequential Game: One player takes the first move thus making other players get some
information of the first player’s choice. Example – Combinatorial games.
• Repeated Game: This is also called stage game. Its two-player game. The effects of the
moves of any players affects the future moves.
• Signaling Game: Two players namely transmitter and receiver. In these type of games
incomplete information exists, often one player is more informed than the other.
• Large Poisson Game: Random number of players play such games, where every player
has his own strategy to win. Example – Voting system
• Non-transitive Game: The games where multiple strategies generate loops fall in this
category.
• Global Game: If a game is with incomplete information then it can be categorized as
Global, which is associated with some probabilities and signaling about the
environment.
2.42 Artificial Intelligence
2.9.1.2 Game Strategies
Strategy is a complete approach for playing a game, while move is an action taken by a
player at some point during the course of the game.
• Dominant Strategies: One strategy is better than another for the same player,
irrespective of other player’s game.
• Pure Strategies: It’s the complete approach of a player’s game plan.
• Mixed Strategy: Randomly the player can choose a strategy based on probability
assigned for any strategy.
• Tit for Tat: Starts with co-operative players, but as soon as a player betrays, opponent
in the next cycle betrays.
• Collusion: Illegal and back door agreement between multiple players to impose
restriction with regard to the use of its rights.
• Backward Induction: Optimal actions are executed by backward reasoning.
Nash Equilibrium
In Nash Equilibrium multiple players are involved along with the following rules.
1) The participants in the game are aware of the equilibrium of the other players.
2) None of the participants can gain by selecting or changing the strategy in such a way
that it affects only one player.
3) If a player changes or selects a strategy then none of the other players can get any gain
whether they change or don’t change their strategy.
The above rules along with set of strategy choices and their gains(payoffs) forms the Nash
Equilibrium.
Procedure
Minimax is a procedure used for minimizing the possible loss while maximizing the
potential gain. Originally formulated for two player game. In simple way minimax is Considered as
two player game, the players are referred as MAX(player) and MIN(the opponent). MAX is trying
to maximize its score and MIN is trying to minimize MAX’s score.
Assumption:
• Let us consider two players MAX and MIN
• The game proceeds with the assuming ahead – opponent’s best move.
• Task is to find “best” move for MAX
• The game starts with MAX making the first move and then MIN.
• Type of payoff’s could be Win, Lose or Draw.
Principle:
• Each move has a value (Evaluation number) associated with it.
• Higher the number greater the opportunity for player, lower the number opportunity is
high for opponent.
• Basic principle – the player assume the opponent will choose the minimizing move next
after player made his move first.
2.44 Artificial Intelligence
• Best moves are made under assumption.
• The fixed evaluation function returns large values to indicate good situation for us.
Goal:
To maximize the value of the static evaluation function of the next board position.
Minimax Algorithm:
1) DEEP-ENOUGH(Position, Depth), then return the structure
VALUE=STATIC (Position, Player);
PATH=nil
This indicates that there is no path from this node and that its value is that determined
by the static evaluation function.
2) Otherwise, generate one more play of the tree by calling the function MOVE-GEN
(Position, Player) and setting SUCCESSORS to the list it returns.
3) If SUCCESSORS is empty, then there are no moves to be made, so return the same
structure that would have been returned if DEEP-ENOUGH had returned true.
Problem Solving Methods 2.45
4) If SUCCESSORS is not empty, then examine each element in turn and keep track of the
best one. This is done as follows;
Initialize BEST-SCORE to the minimum value that STATIC can return. It will be
updated to reflect the best score that can be achieved by an element of SUCCESSORS.
For each element SUCC of SUCCESSORS, do the following:
a) Set RESULT-SUCC to
MINIMAX(SUCC, Depth+1, OPPOSITE(Player))ᶟ
This recursive call to MINIMAX will actually carry out the exploration of SUCC.
b) Set NEW-VALUE to –VALUE (RESULT-SUCC). This will cause it to reflect the
merits of the position from the opposite perspective from that of the next lower level.
c) If NEW-VALUE>BEST-SCORE, then we have found a successor that is better than
any that have been examined so far. Record this by doing the following:
i) Set BEST-SCORE to NEW-VALUE.
ii) The best known path is now from CURRENT to SUCC and then on to the
appropriate path down from SUCC as determined by the recursive call to
MINIMAX. So set BEST-PATH to the result of attaching SUCC to the front of
PATH(RESULT-SUCC).
5) Now that all the successors have been examined, we know the value of Position as well
as which path to take from it. So return the structure
VALUE=BEST-SCORE
PATH=BEST-PATH
When the initial call to MINIMAX returns, the best move from CURRENT is the first
element on PATH.
Example:
Assume a static evaluation function that returns values ranging from -10 to 10, with 10
indicating a win for us, -10 a win for the opponent and 0 an even match. Since our goal is to
maximize the value of the heuristic function, we choose to move to B. Backing B’s value up to A,
we can conclude that A’.
2.46 Artificial Intelligence
Step 1:
Step 2:
Problem Solving Methods 2.47
Step 3:
Step 4:
These are also called MAX nodes. The goal at a MAX node is to maximize the
value of the subtree rooted at that node. To do this, a MAX node chooses the
child with the greatest value, and that becomes the value of the MAX node.
Nodes representing the opponent's moves are generally drawn as circles (or possibly as
downward pointing triangles):
These are also called MIN nodes. The goal at a MIN node is to minimize the
value of the subtree rooted at that node. To do this, a MIN node chooses the
child with the least (smallest) value, and that becomes the value of the MIN
node.
Alpha-beta pruning gets its name from two bounds that are passed along during the
calculation, which restrict the set of possible solutions based on the portion of the search tree that
has already been seen. Specifically, β - Beta is the minimum upper bound of possible solutions, α -
Alpha is the maximum lower bound of possible solutions
Thus, when any new node is being considered as a possible path to the solution, it can only
work if: α≤N≤β where N is the current estimate of the value of the node.
Problem Solving Methods 2.49
Example:
2.50 Artificial Intelligence
Problem Solving Methods 2.51