Professional Documents
Culture Documents
Unit 5 AI
Unit 5 AI
Game playing:
Overview, The min-max search procedure, Min-Max algorithm, alpha
beta cut-offs, planning and its components, Goal stack planning.
Expert Systems.
Game playing
• Rich tradition of creating game-playing programs in AI
• Many similarities to search
• Most of the games studied
• have two players,
• are zero-sum: what one player wins, the other loses
• have perfect information: the entire state of the game is known to both
players at all times
• E.g., tic-tac-toe, checkers, chess, Go, backgammon, …
• Will focus on these for now
• Recently more interest in other games
• Esp. games without perfect information; e.g., poker
• Need probability theory, game theory for such games
Types of games
Overview
• Charles Babbage, the nineteenth-century computer architect thought about
programming his analytical engine to play chess and later of building a machine to play
tic-tac-toe.
• There are two reasons that games appeared to be a good domain.
1. They provide a structured task in which it is very easy to measure success or failure.
2. They are easily solvable by straightforward search from the starting state to a winning
position.
The first is true is for all games bust the second is not true for all, except simplest games.
• The performance of the overall system can improve by adding heuristic knowledge into
both the generator and the tester.
• Instead of the legal-move generator, we can use plausible-move generator in which only
some small numbers of promising moves generated.
• This is done using static evaluation function, which uses whatever information it has to
evaluate individual board position by estimating how likely they are to lead eventually to a
win.
MINIMAX Search Procedure
• The minimax search is a depth-first and depth limited procedure.
• The idea is to start at the current position and use the plausible-move generator to generate the set
of possible successor positions.
• Now we can apply the static evaluation function (utility)to those positions and simply choose the best
one.
• After doing so, we can back that value up to the starting position to represent our evolution of it.
• Here we assume that static evaluation function returns larger values to indicate good situations .
• So our goal is to maximize the value of the static evaluation function of the next board position.
• The opponents’ goal is to minimize the value of the static evaluation function.
• The alternation of maximizing and minimizing at alternate ply when evaluations are to be pushed
back up corresponds to the opposing strategies of the two players is called MINIMAX.
MINIMAX ALGORITHM
• It is the recursive procedure that depends on two procedures -
MOVEGEN(position, player)— The plausible-move generator, which returns a list of nodes representing the
moves that can make by Player in Position.
STATIC(position, player)– static evaluation function, which returns a number representing the goodness of
Position from the standpoint of Player.
• With any recursive program, we need to decide when recursive procedure should stop.
• There are the variety of factors that may influence the decision they are,
Has one side won? How many plies have we already explored? How much time is left? How stable is the
configuration?
• The DEEP-ENOUGH which assumed to evaluate all of these factors and to return TRUE if the search should be
stopped at the current level and FALSE otherwise. It takes two parameters, position, and depth, it will ignore
its position parameter and simply return TRUE if its depth parameter exceeds a constant cut off value.
We assume that MINIMAX returns a structure containing both results and we have two functions, VALUE and
PATH that extract the separate components.
Initially, It takes three parameters, a board position, the current depth of the search, and the player to move,
MINIMAX(current,0,player-one) If player –one is to move
MINIMAX(current,0,player-two) If player –two is to move
Do we need to see all the leaves?
• Do we need to see the values of the question marks here?
Player 1
0 1
Player 2 Player 2
0 1 1
0
0 1 0 1 0 1 0 1
-1 -2 ? ? -5 6 7 -8
Alpha-beta pruning
• Pruning = cutting off parts of the search tree (because you
realize you don’t need to look at them)
• When we considered A* we also pruned large parts of the search
tree
• Maintain alpha = value of the best option for player 1 along
the path so far
• Beta = value of the best option for player 2 along the path so
far
Alpha-beta pruning
• Alpha-beta pruning is a modified version of the minimax algorithm. It is
an optimization technique for the minimax algorithm.
• As we have seen in the minimax search algorithm that the number of
game states it has to examine are exponential in depth of the tree.
Since we cannot eliminate the exponent, but we can cut it to half.
Hence there is a technique by which without checking each node of the
game tree we can compute the correct minimax decision, and this
technique is called pruning.
• This involves two threshold parameter Alpha and beta for future
expansion, so it is called alpha-beta pruning. It is also called as Alpha-
Beta Algorithm.
• Alpha-beta pruning can be applied at any depth of a tree, and sometimes it
not only prune the tree leaves but also entire sub-tree.
• The two-parameter can be defined as:
• Alpha: The best (highest-value) choice we have found so far at any point along the
path of Maximizer. The initial value of alpha is -∞.
• Beta: The best (lowest-value) choice we have found so far at any point along the
path of Minimizer. The initial value of beta is +∞.
• The Alpha-beta pruning to a standard minimax algorithm returns the same
move as the standard algorithm does, but it removes all the nodes which
are not really affecting the final decision but making algorithm slow. Hence
by pruning these nodes, it makes the algorithm fast.
Key points about alpha-beta pruning
i. Start by pushing the original goal on the stack. Repeat this until
the stack becomes empty. If stack top is a compound goal, then
push its unsatisfied subgoals on the stack.
iii. If stack top is an action, pop it from the stack, execute it and
change the knowledge base by the effects of the action.
Backward Chaining
User Interface
User interface provides interaction between user and expert system.
It is generally Natural Language Processing so as to be used by the user who
is well-versed in the task domain.
The user of the ES need not be necessarily an expert in Artificial Intelligence.
Requirements of Efficient ES User Interface
• It should help users to accomplish their goals in shortest possible way.
• It should be designed to work for user’s existing or desired work practices.
• It should make efficient use of user input.
• Sends the user questions or answers and receives their responses.
Steps for Development of Expert Systems:
• The process of ES development is iterative. Steps in developing the ES include −
1) Identify Problem Domain –
The problem must be suitable for an expert system to solve it.
Find the experts in task domain for the ES project.
Establish cost-effectiveness of the system.
2) Design the System-
Identify the ES Technology
Know and establish the degree of integration with the other systems and databases.
Realize how the concepts can represent the domain knowledge best.
3) Develop the Prototype From Knowledge Base: The knowledge engineer works to −
Acquire domain knowledge from the expert.
Represent it in the form of If-THEN-ELSE rules.
Steps for Development of Expert Systems:
4) Test and Refine the Prototype
The knowledge engineer uses sample cases to test the prototype for any deficiencies in
performance.
End users test the prototypes of the ES.
5) Develop and Complete the ES
Test and ensure the interaction of the ES with all elements of its environment, including end
users, databases, and other information systems.
Document the ES project well.
Train the user to use ES.
6) Maintain the ES
Keep the knowledge base up-to-date by regular review and update.
Cater for new interfaces with other information systems, as those systems evolve.
Applications of Expert System
Examples of Expert System
1) DENDRIL
It is used in Organic chemistry.It detects unknown organic molecule.
2) MYCIN
It diagnose the blood clot disease.It recommends the antibiotics.
Expert Systems Limitations
• Difficult knowledge acquisition
• ES are difficult to maintain
• High development costs
End of Syllabus : 20CS540