Professional Documents
Culture Documents
AI Unit-3
AI Unit-3
Dr. Anand M
Assistant Professor
Department of Data Science and Business Systems
SRM Institute of Science and Technology
Adversarial Search
Game Playing
Games
• Multi agent environments : any given agent will need to consider the actions of
other agents and how they affect its own welfare.
• The unpredictability of these other agents can introduce many possible
contingencies
• AI games are a specialized kind - deterministic, turn taking, two-player, zero sum games of perfect
information
• a zero-sum game is a mathematical representation of a situation in which a participant's gain (or loss) of
utility is exactly balanced by the losses (or gains) of the utility of other participant(s)
• In our terminology – deterministic, fully observable environments with two agents whose actions
alternate and the utility values at the end of the game are always equal and opposite (+1 and –1)
• If a player wins a game of chess (+1), the other player necessarily loses (-1)
• * Environments with very many agents are best viewed as economies rather than games
Deterministic Games
• Many possible formalizations, one is:
• States: S (start at s0)
• Players: P={1...N} (usually take turns)
• Actions: A (may depend on player / state)
• Transi on Func on: SxA →S
• Terminal Test: S → {t,f}
• Terminal U li es: SxP → R
• Plan of attack:
• Computer considers possible lines of play (Babbage, 1846)
• Algorithm for perfect play (Zermelo, 1912; Von Neumann, 1944)
• Finite horizon, approximate evaluation (Zuse, 1945; Wiener, 1948; Shannon, 1950)
• First chess program (Turing, 1951)
• Machine learning to improve evaluation accuracy (Samuel, 1952-57)
• Pruning to allow deeper search (McCarthy, 1956)
Deterministic Single-Player?
• Deterministic, single player, perfect information:
• Know the rules
• Know what actions do
• Know when you win
• E.g. Freecell, 8-Puzzle, Rubik’s cube
• … it’s just search!
• Slight reinterpretation:
• Each node stores a value: the best outcome it can
reach
• This is the maximal outcome of its children (the max
value)
• Note that we don’t have path sums as before
(utilities at end)
• After search, can pick move that leads to best node
Deterministic Two-Player
• E.g. tic-tac-toe, chess, checkers
• Zero-sum games
• One player maximizes result
• The other minimizes result
• Minimax search
• A state-space search tree
• Players alternate
• Each layer, or ply, consists of a round of moves
• Choose move to position with highest minimax value
= best achievable utility against best play
Searching for the next move
• Complexity: many games have a huge search space
• Chess: b = 35, m=100 nodes = 35 100
• if each node takes about 1 ns to explore then each move will take about 1050 millennia to
calculate.
• Resource (e.g., time, memory) limit: optimal solution not feasible/possible, thus
must approximate
• 1. Pruning: makes the search more efficient by discarding portions of the search
tree that cannot improve quality result.
• Algorithm:
1. Generate game tree completely
2. Determine utility of each terminal state
3. Propagate the utility values upward in the three by applying MIN and MAX operators on the
nodes in the current level
4. At the root node use minimax decision to select the move with the max (of the min) utility
value
• Steps 2 and 3 in the algorithm assume that the opponent will play perfectly.
Generate Game Tree
Minimax Example
Minimax value
• Given a game tree, the optimal strategy can be determined by
examining the minimax value of each node (MINIMAX-VALUE(n))
Key issues:
1- Representation of knowledge
What form? Meaning / semantics?
2- Reasoning and inference processes
Efficiency.
Knowledge-base Agents
• Key issues:
• Representation of knowledge knowledge base
• Reasoning processes inference/reasoning
•
Knowledge base = set of sentences in a formal language representing facts about the world(*)
Both tasks may involve inference – i.e. how to derive new sentences from old sentences
Logical agents – inference must obey the fundamental requirement that when one asks a
question to the knowledge base, the answer should follow from what has been told to the
knowledge base previously. (In other words the inference process should not “make
things” up…)
A simple knowledge-based agent
Knowledge-based alternative:
The “symbol grounding problem.”
Representations and Mappings
• To solve complex problems encountered in artificial intelligence, one
needs both a large amount of knowledge and some mechanism for
manipulating that knowledge to create solutions.
• Knowledge and Representation are two distinct entities. They play
central but distinguishable roles in intelligent system.
• Knowledge is a description of the world. It determines a system’s
competence by what it knows.
• Representation is the way knowledge is encoded. It defines a system’s
performance in doing something.
Representations and Mappings
• The knowledge Representation models/mechanisms are often based on:
• Logic
• Rules
• Frames
• Semantic Net
• Knowledge is categorized into two major types.
• A variety of ways of representing knowledge have been exploited in AI
programs.
• There are two different kinds of entities, we are dealing with.
• Facts: Truth in some relevant world. Things we want to represent.
• Representation of facts in some chosen formalism. Things we will actually be able to
manipulate.
Representations and Mappings
• These entities are structured at two levels:
• The knowledge level, at which facts are described.
• The symbol level, at which representation of objects are defined in terms of
symbols that can be manipulated by programs.
Note: KB defines exactly the set of worlds we are interested
in.
• Forward chaining
• Given P, , to infer Q
• P, match L.H.S of PQ
• Assert Q from R.H.S
• Backward chaining
• Q, Match R.H.S of
PQ
• assert P
• Check if P exists
• Resolution – Refutation
• Negate goal
• Convert all pieces of knowledge into clausal form (disjunction of literals)
• See if contradiction indicated by null clause can be derived
Terminology
• Pair of clauses being resolved is called the Resolvents.
The resulting clause is called the Resolute.
• Choosing the correct pair of resolvents is a matter of
search.
Forward & Backward Chaining
•Rule : man(x) mortal(x)
•Data : man(Shakespeare)
To prove : mortal(Shakespeare)
•Forward Chaining:
man(Shakespeare) matches LHS of Rule.
X = Shakespeare
mortal( Shakespeare) added
-Forward Chaining used by design expert systems
• shakespeare is a man
man(shakespeare)
• man(x) → mortal(x)
• Goal mortal(shakespeare)
• x = shakespeare
• Travel back over and hit the fact asserted
• man(shakespeare)
Resolution - Refutation
• man(x) → mortal(x)
• Convert to clausal form
• ~man(shakespeare) mortal(x)
• Clauses in the knowledge base
• ~man(shakespeare) mortal(x)
• man(shakespeare)
• mortal(shakespeare)
Resolution – Refutation contd
Re solvent1 Re solvent 2
Re solute
Search in resolution
• Heuristics for Resolution Search
• Goal Supported Strategy
• Always start with the negated goal
• Set of support strategy
• Always one of the resolvents is the most recently produced resolute
Natural Deduction
Natural Deduction
• Proof system for first-order logic
• Designed to mimic the natural reasoning process
• Process:
• Make assumptions (“A” is true)
• Letters like “A” can represent larger propositional phrases
• The set of assumptions being relied on at a given step is called the context.
• Use rules to draw conclusions.
• Discharge assumptions as they become no longer necessary.
Natural Deduction
• Natural deduction is done in step by step:
• Rule
• Premises
• Conclusion
• …
Logical Connectives
Truth Tables for Logical Connectives
Making Conclusions
• The rules used to draw conclusions consist mostly of the introduction
(I) and elimination (E) of these connectives.
• Several of the rules serve to discharge earlier assumptions.
• The result does not rely on the assumption being true.
• If the assumption is used by itself again somewhere else, it must be
discharged again in a step that follows.
Introduction and Elimination
• Introduction builds the conclusion out of the logical connective and
the premises.
• Elimination eliminates the logical connective from a premise.
Rules: AND/OR
• Rule “ I” requires that “a” does not occur in S(x) or any premise on
which S(a) may depend.
Rules: exists ( )
94
Logic Programming