Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence A Modern Approach

Similar presentations


Presentation on theme: "Artificial Intelligence A Modern Approach"— Presentation transcript:

1 Artificial Intelligence A Modern Approach

2 Introduction to Artificial Intelligence
Course overview: Foundations of symbolic intelligent systems. Agents, search, problem solving, logic, representation, reasoning, symbolic programming, and robotics. Prerequisites: Programming principles, discrete mathematics for computing, software design and software engineering concepts. Some knowledge of C/C++ for some programming assignments.

3 Why study AI? Search engines Science Medicine/ Diagnosis Labor Appliances What else?

4 Honda Humanoid Robot Walk Turn Stairs

5 Sony AIBO

6 Natural Language Question Answering

7 Robot Teams USC robotics Lab

8 What is AI?

9 Acting Humanly: The Turing Test
Alan Turing's 1950 article Computing Machinery and Intelligence discussed conditions for considering a machine to be intelligent “Can machines think?”  “Can machines behave intelligently?” The Turing test (The Imitation Game): Operational definition of intelligence. Computer needs to posses:Natural language processing, Knowledge representation, Automated reasoning, and Machine learning Are there any problems/limitations to the Turing Test?

10 What tasks require AI? What tasks require AI?
“AI is the science and engineering of making intelligent machines which can perform tasks that require intelligence when performed by humans …” What tasks require AI?

11 What tasks require AI? “AI is the science and engineering of making intelligent machines which can perform tasks that require intelligence when performed by humans …” Tasks that require AI: Solving a differential equation Brain surgery Inventing stuff Playing Jeopardy Playing Wheel of Fortune What about walking? What about grabbing stuff? What about pulling your hand away from fire? What about watching TV? What about day dreaming?

12 Acting Humanly: The Full Turing Test
Alan Turing's 1950 article Computing Machinery and Intelligence discussed conditions for considering a machine to be intelligent “Can machines think?”  “Can machines behave intelligently?” The Turing test (The Imitation Game): Operational definition of intelligence. Computer needs to posses:Natural language processing, Knowledge representation, Automated reasoning, and Machine learning Problem: 1) Turing test is not reproducible, constructive, and amenable to mathematic analysis. 2) What about physical interaction with interrogator and environment? Total Turing Test: Requires physical interaction and needs perception and actuation.

13 What would a computer need to pass the Turing test?
Natural language processing: to communicate with examiner. Knowledge representation: to store and retrieve information provided before or during interrogation. Automated reasoning: to use the stored information to answer questions and to draw new conclusions. Machine learning: to adapt to new circumstances and to detect and extrapolate patterns. Vision (for Total Turing test): to recognize the examiner’s actions and various objects presented by the examiner. Motor control (total test): to act upon objects as requested. Other senses (total test): such as audition, smell, touch, etc.

14 Thinking Humanly: Cognitive Science
1960 “Cognitive Revolution”: information-processing psychology replaced behaviorism Cognitive science brings together theories and experimental evidence to model internal activities of the brain What level of abstraction? “Knowledge” or “Circuits”? How to validate models? Predicting and testing behavior of human subjects (top-down) Direct identification from neurological data (bottom-up) Building computer/machine simulated models and reproduce results (simulation)

15 Thinking Rationally: Laws of Thought
Aristotle (~ 450 B.C.) attempted to codify “right thinking” What are correct arguments/thought processes? E.g., “Socrates is a man, all men are mortal; therefore Socrates is mortal” Several Greek schools developed various forms of logic: notation plus rules of derivation for thoughts. Problems: Uncertainty: Not all facts are certain (e.g., the flight might be delayed). Resource limitations: There is a difference between solving a problem in principle and solving it in practice under various resource limitations such as time, computation, accuracy etc. (e.g., purchasing a car)

16 Acting Rationally: The Rational Agent
Rational behavior: Doing the right thing! The right thing: That which is expected to maximize the expected return Provides the most general view of AI because it includes: Correct inference (“Laws of thought”) Uncertainty handling Resource limitation considerations (e.g., reflex vs. deliberation) Cognitive skills (NLP, AR, knowledge representation, ML, etc.) Advantages: More general Its goal of rationality is well defined

17 How to achieve AI? How is AI research done?
AI research has both theoretical and experimental sides. The experimental side has both basic and applied aspects. There are two main lines of research: One is biological, based on the idea that since humans are intelligent, AI should study humans and imitate their psychology or physiology. The other is phenomenal, based on studying and formalizing common sense facts about the world and the problems that the world presents to the achievement of goals. The two approaches interact to some extent, and both should eventually succeed. It is a race, but both racers seem to be walking. [John McCarthy]

18 Branches of AI Logical AI Search Natural language processing
pattern recognition Knowledge representation Inference From some facts, others can be inferred. Automated reasoning Learning from experience Planning To generate a strategy for achieving some goal Epistemology This is a study of the kinds of knowledge that are required for solving problems in the world. Ontology Ontology is the study of the kinds of things that exist. In AI, the programs and sentences deal with various kinds of objects, and we study what these kinds are and what their basic properties are. Genetic programming Emotions???

19 AI Prehistory

20 AI History

21 AI State of the art Have the following been achieved by AI?
World-class chess playing Playing table tennis Cross-country driving Solving mathematical problems Discover and prove mathematical theories Engage in a meaningful conversation Understand spoken language Observe and understand human emotions Express emotions

22 General Introduction Course Overview
01-Introduction. [AIMA Ch 1] Course Schedule. Home works, exams and grading. Course material. Why study AI? What is AI? The Turing test. Rationality. Branches of AI. Research disciplines connected to and at the foundation of AI. Brief history of AI. Challenges for the future. Overview of class syllabus. 02-Intelligent Agents. [AIMA Ch 2] What is an intelligent agent? Examples. Doing the right thing (rational action). Performance measure. Autonomy. Environment and agent design. Structure of agents. Agent types. Reflex agents. Reactive agents. Reflex agents with state. Goal-based agents. Utility-based agents. Mobile agents. Information agents.

23 Course Overview (cont.)
How can we solve complex problems? 03/04-Problem solving and search. [AIMA Ch 3] Example: measuring problem. Types of problems. More example problems. Basic idea behind search algorithms. Complexity. Combinatorial explosion and NP completeness. Polynomial hierarchy. 05-Uninformed search. [AIMA Ch 3] Depth-first. Breadth-first. Uniform-cost. Depth-limited. Iterative deepening. Examples. Properties. 06/07-Informed search. [AIMA Ch 4] Best-first. A* search. Heuristics. Hill climbing. Problem of local extrema. Simulated annealing.

24 Course Overview (cont.)
Practical applications of search. 08/09-Game playing. [AIMA Ch 5] The minimax algorithm. Resource limitations. Aplha-beta pruning. Elements of chance and non- deterministic games. tic-tac-toe

25 Course Overview (cont.)
10-Agents that reason logically 1. [AIMA Ch 6] Knowledge-based agents. Logic and representation. Propositional (boolean) logic. 11-Agents that reason logically 2. [AIMA Ch 6] Inference in propositional logic. Syntax. Semantics. Examples. Towards intelligent agents wumpus world

26 Course Overview (cont.)
Building knowledge-based agents: 1st Order Logic 12-First-order logic 1. [AIMA Ch 7] Syntax. Semantics. Atomic sentences. Complex sentences. Quantifiers. Examples. FOL knowledge base. Situation calculus. 13-First-order logic 2. [AIMA Ch 7] Describing actions. Planning. Action sequences.

27 Course Overview (cont.)
Representing and Organizing Knowledge 14/15-Building a knowledge base. [AIMA Ch 8] Knowledge bases. Vocabulary and rules. Ontologies. Organizing knowledge. An ontology for the sports domain Kahn & Mcleod, 2000

28 Course Overview (cont.)
Reasoning Logically 16/17/18-Inference in first-order logic. [AIMA Ch 9] Proofs. Unification. Generalized modus ponens. Forward and backward chaining. Example of backward chaining

29 Course Overview (cont.)
Examples of Logical Reasoning Systems 19-Logical reasoning systems. [AIMA Ch 10] Indexing, retrieval and unification. The Prolog language. Theorem provers. Frame systems and semantic networks. Semantic network used in an insight generator (Duke university)

30 Course Overview (cont.)
Logical Reasoning in the Presence of Uncertainty 20/21-Fuzzy logic. Introduction to fuzzy logic. Linguistic Hedges. Fuzzy inference. Examples. Center of largest area Center of gravity

31 Course Overview (cont.)
Systems that can Plan Future Behavior 22/23-Planning. [AIMA Ch 11] Definition and goals. Basic representations for planning. Situation space and plan space. Examples.

32 Course Overview (cont.)
Expert Systems 24-Expert systems 1. What are expert systems? Applications. Pitfalls and difficulties. Rule-based systems. Comparison to traditional programs. Building expert systems. Production rules. Antecedent matching. Execution. Control mechanisms. 25-Expert systems 2. Overview of modern rule-based expert systems. Introduction to CLIPS (C Language Integrated Production System). Rules. Wildcards. Pattern matching. Pattern network. Join network. CLIPS expert system shell

33 Course Overview (cont.)
What challenges remain? 26/27-Towards intelligent machines. [AIMA Ch 25] The challenge of robots: with what we have learned, what hard problems remain to be solved? Different types of robots. Tasks that robots are for. Parts of robots. Architectures. Configuration spaces. Navigation and motion planning. Towards highly-capable robots. 28-Overview and summary. [all of the above] What have we learned. Where do we go from here?

34 A driving example: Beobots
Goal: build robots that can operate in unconstrained environments and that can solve a wide variety of tasks.

35 Beowulf + robot = “Beobot”

36 A driving example: Beobots
Goal: build robots that can operate in unconstrained environments and that can solve a wide variety of tasks. We have: Lots of CPU power Prototype robotics platform Visual system to find interesting objects in the world Visual system to recognize/identify some of these objects Visual system to know the type of scenery the robot is in We need to: Build an internal representation of the world Understand what the user wants Act upon user requests / solve user problems

37 The basic components of vision
Original Downscaled Segmented + Riesenhuber & Poggio, Nat Neurosci, 1999 Scene Layout & Gist Localized Object Recognition Attention

38

39 Beowulf + Robot = “Beobot”

40 Main challenge: extract the “minimal subscene” (i.e., small
number of objects and actions) that is relevant to present behavior from the noisy attentional scanpaths. Achieve representation for it that is robust and stable against noise, world motion, and egomotion.

41 Prototype Stripped-down version of proposed
general system, for simplified goal: drive around USC olympic track, avoiding obstacles Operates at 30fps on quad-CPU Beobot; Layout & saliency very robust; Object recognition often confused by background clutter.

42 Major issues How to represent knowledge about the world?
How to react to new perceived events? How to integrate new percepts to past experience? How to understand the user? How to optimize balance between user goals & environment constraints? How to use reasoning to decide on the best course of action? How to communicate back with the user? How to plan ahead? How to learn from experience?

43 General architecture

44 Ontology Khan & McLeod, 2000

45 The task-relevance map
Scalar topographic map, with higher values at more relevant locations

46 More formally: how do we do it?
Use ontology to describe categories, objects and relationships: Either with unary predicates, e.g., Human(John), Or with reified categories, e.g., John  Humans, And with rules that express relationships or properties, e.g., x Human(x)  SinglePiece(x)  Mobile(x)  Deformable(x) Use ontology to expand concepts to related concepts: E.g., parsing question yields “LookFor(catching)” Assume a category HandActions and a taxonomy defined by catching  HandActions, grasping  HandActions, etc. We can expand “LookFor(catching)” to looking for other actions in the category where catching belongs through a simple expansion rule: a,b,c a  c  b  c  LookFor(a)  LookFor(b)

47 End of Lecture AI is a very exciting area right now.
This course will teach you the foundations. In addition, we will use the Beobot example to reflect on how this foundation could be put to work in a large-scale, real system.

48 Last time: Problem-Solving
Goal formulation Problem formulation (states, operators) Search for solution Problem formulation: Initial state ? Problem types: single state: accessible and deterministic environment multiple state: ? contingency: ? exploration: ?

49 Last time: Problem-Solving
Goal formulation Problem formulation (states, operators) Search for solution Problem formulation: Initial state Operators Goal test Path cost Problem types: single state: accessible and deterministic environment multiple state: ? contingency: ? exploration: ?

50 Last time: Problem-Solving
Goal formulation Problem formulation (states, operators) Search for solution Problem formulation: Initial state Operators Goal test Path cost Problem types: single state: accessible and deterministic environment multiple state: inaccessible and deterministic environment contingency: inaccessible and nondeterministic environment exploration: unknown state-space

51 Last time: Finding a solution
Solution: is ??? Basic idea: offline, systematic exploration of simulated state-space by generating successors of explored states (expanding) Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end

52 Last time: Finding a solution
Solution: is a sequence of operators that bring you from current state to the goal state. Basic idea: offline, systematic exploration of simulated state-space by generating successors of explored states (expanding). Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end Strategy: The search strategy is determined by ???

53 Last time: Finding a solution
Solution: is a sequence of operators that bring you from current state to the goal state Basic idea: offline, systematic exploration of simulated state-space by generating successors of explored states (expanding) Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end Strategy: The search strategy is determined by the order in which the nodes are expanded.

54 A Clean Robust Algorithm
Function UniformCost-Search(problem, Queuing-Fn) returns a solution, or failure open  make-queue(make-node(initial-state[problem])) closed  [empty] loop do if open is empty then return failure currnode  Remove-Front(open) if Goal-Test[problem] applied to State(currnode) then return currnode children  Expand(currnode, Operators[problem]) while children not empty [… see next slide …] end closed  Insert(closed, currnode) open  Sort-By-PathCost(open)

55 A Clean Robust Algorithm
[… see previous slide …] children  Expand(currnode, Operators[problem]) while children not empty child  Remove-Front(children) if no node in open or closed has child’s state open  Queuing-Fn(open, child) else if there exists node in open that has child’s state if PathCost(child) < PathCost(node) open  Delete-Node(open, node) else if there exists node in closed that has child’s state closed  Delete-Node(closed, node) end

56 Last time: search strategies
Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited Iterative deepening Informed: Use heuristics to guide the search Best first A*

57 Evaluation of search strategies
Search algorithms are commonly evaluated according to the following four criteria: Completeness: does it always find a solution if one exists? Time complexity: how long does it take as a function of number of nodes? Space complexity: how much memory does it require? Optimality: does it guarantee the least-cost solution? Time and space complexity are measured in terms of: b – max branching factor of the search tree d – depth of the least-cost solution m – max depth of the search tree (may be infinity)

58 Last time: uninformed search strategies
Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited Iterative deepening

59 This time: informed search
Use heuristics to guide the search Best first A* Heuristics Hill-climbing Simulated annealing

60 Best-first search Idea:
use an evaluation function for each node; estimate of “desirability” expand most desirable unexpanded node. Implementation: QueueingFn = insert successors in decreasing order of desirability Special cases: greedy search A* search

61 Romania with step costs in km

62 Greedy search Estimation function:
h(n) = estimate of cost from n to goal (heuristic) For example: hSLD(n) = straight-line distance from n to Bucharest Greedy search expands first the node that appears to be closest to the goal, according to h(n).

63

64

65

66

67 Properties of Greedy Search
Complete? Time? Space? Optimal?

68 Properties of Greedy Search
Complete? No – can get stuck in loops e.g., Iasi > Neamt > Iasi > Neamt > … Complete in finite space with repeated-state checking. Time? O(b^m) but a good heuristic can give dramatic improvement Space? O(b^m) – keeps all nodes in memory Optimal? No.

69 A* search Idea: avoid expanding paths that are already expensive
evaluation function: f(n) = g(n) + h(n) with: g(n) – cost so far to reach n h(n) – estimated cost to goal from n f(n) – estimated total cost of path through n to goal A* search uses an admissible heuristic, that is, h(n)  h*(n) where h*(n) is the true cost from n. For example: hSLD(n) never overestimates actual road distance. Theorem: A* search is optimal

70

71

72

73

74

75

76 Optimality of A* (standard proof)
Suppose some suboptimal goal G2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G1.

77 Optimality of A* (more useful proof)

78 Properties of A* Complete? Time? Space? Optimal?

79 Properties of A* Complete? Yes, unless infinitely many nodes with f  f(G) Time? Exponential in [(relative error in h) x (length of solution)] Space? Keeps all nodes in memory Optimal? Yes – cannot expand fi+1 until fi is finished

80 Proof of lemma: pathmax

81 Admissible heuristics

82 Admissible heuristics

83 Relaxed Problem Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem. If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution. If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the shortest solution.

84 Next time Iterative improvement Hill climbing Simulated annealing

85 Last time: search strategies
Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited Iterative deepening Informed: Use heuristics to guide the search Best first: Greedy search – queue first nodes that maximize heuristic “desirability” based on estimated path cost from current node to goal; A* search – queue first nodes that maximize sum of path cost so far and estimated path cost to goal. Iterative improvement – keep no memory of path; work on a single current state and iteratively improve its “value.” Hill climbing – select as new current state the successor state which maximizes value. Simulated annealing – refinement on hill climbing by which “bad moves” are permitted, but with decreasing size and frequency. Will find global extremum.

86 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

87 Depth-first search Node queue: initialization
# state depth path cost parent # 1 A

88 Depth-first search Node queue: add successors to queue front; empty queue from top # state depth path cost parent # 2 B 3 C 4 D 1 A

89 Depth-first search Node queue: add successors to queue front; empty queue from top # state depth path cost parent # 5 E 6 F 7 G 8 H 2 B 3 C 4 D 1 A

90 Depth-first search Node queue: add successors to queue front; empty queue from top # state depth path cost parent # 5 E 6 F 7 G 8 H 2 B 3 C 4 D 1 A

91 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

92 Breadth-first search Node queue: initialization
# state depth path cost parent # 1 A

93 Breadth-first search Node queue: add successors to queue end; empty queue from top # state depth path cost parent # 1 A 2 B 3 C 4 D

94 Breadth-first search Node queue: add successors to queue end; empty queue from top # state depth path cost parent # 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H

95 Breadth-first search Node queue: add successors to queue end; empty queue from top # state depth path cost parent # 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H

96 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

97 Uniform-cost search Node queue: initialization
# state depth path cost parent # 1 A

98 Uniform-cost search Node queue: add successors to queue so that entire queue is sorted by path cost so far; empty queue from top # state depth path cost parent # 1 A 2 B 3 D 4 C

99 Uniform-cost search Node queue: add successors to queue so that entire queue is sorted by path cost so far; empty queue from top # state depth path cost parent # 1 A 2 B 3 D 5 E 6 F 7 G 8 H 4 C

100 Uniform-cost search Node queue: add successors to queue so that entire queue is sorted by path cost so far; empty queue from top # state depth path cost parent # 1 A 2 B 3 D 5 E 6 F 7 G 8 H 4 C

101 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

102 Greedy search Node queue: initialization
# state depth path cost total parent # cost to goal cost 1 A

103 Greedy search Node queue: Add successors to queue, sorted by cost to goal. # state depth path cost total parent # cost to goal cost 1 A 2 B 3 D 4 C Sort key

104 Greedy search Node queue: Add successors to queue, sorted by cost to goal. # state depth path cost total parent # cost to goal cost 1 A 2 B 5 G 7 E 6 H 8 F 3 D 4 C

105 Greedy search Node queue: Add successors to queue, sorted by cost to goal. # state depth path cost total parent # cost to goal cost 1 A 2 B 5 G 7 E 6 H 8 F 3 D 4 C

106 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

107 A* search Node queue: initialization
# state depth path cost total parent # cost to goal cost 1 A

108 A* search Node queue: Add successors to queue, sorted by total cost.
# state depth path cost total parent # cost to goal cost 1 A 2 B 3 D 4 C Sort key

109 A* search Node queue: Add successors to queue front, sorted by total cost. # state depth path cost total parent # cost to goal cost 1 A 2 B 5 G 6 E 7 H 3 D 8 F 4 C

110 A* search Node queue: Add successors to queue front, sorted by total cost. # state depth path cost total parent # cost to goal cost 1 A 2 B 5 G 6 E 7 H 3 D 8 F 4 C

111 Exercise: Search Algorithms
The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D A C 4 19 6 3 h=15 B F G E h=8 h=12 h=10 h=18 H h=20 h=14

112 Last time: Simulated annealing algorithm
Idea: Escape local extrema by allowing “bad moves,” but gradually decrease their size and frequency. Note: goal here is to maximize E. -

113 Last time: Simulated annealing algorithm
Idea: Escape local extrema by allowing “bad moves,” but gradually decrease their size and frequency. Algorithm when goal is to minimize E. - < -

114 This time: Outline Game playing The minimax algorithm
Resource limitations alpha-beta pruning Elements of chance

115 What kind of games? Abstraction: To describe a game we must capture every relevant aspect of the game. Such as: Chess Tic-tac-toe Accessible environments: Such games are characterized by perfect information Search: game-playing then consists of a search through possible game positions Unpredictable opponent: introduces uncertainty thus game-playing must deal with contingency problems

116 Searching for the next move
Complexity: many games have a huge search space Chess: b = 35, m=100  nodes = if each node takes about 1 ns to explore then each move will take about millennia to calculate. Resource (e.g., time, memory) limit: optimal solution not feasible/possible, thus must approximate Pruning: makes the search more efficient by discarding portions of the search tree that cannot improve quality result. Evaluation functions: heuristics to evaluate utility of a state without exhaustive search.

117 Two-player games A game formulated as a search problem:
Initial state: ? Operators: ? Terminal state: ? Utility function: ?

118 Two-player games A game formulated as a search problem:
Initial state: board position and turn Operators: definition of legal moves Terminal state: conditions for when game is over Utility function: a numeric value that describes the outcome of the game. E.g., -1, 0, 1 for loss, draw, win. (AKA payoff function)

119 Game vs. search problem

120 Example: Tic-Tac-Toe

121 Type of games

122 The minimax algorithm Perfect play for deterministic environments with perfect information Basic idea: choose move with highest minimax value = best achievable payoff against best play Algorithm: Generate game tree completely Determine utility of each terminal state Propagate the utility values upward in the three by applying MIN and MAX operators on the nodes in the current level 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.

123 minimax = maximum of the minimum
1st ply 2nd ply

124 Minimax: Recursive implementation
Complete: ? Optimal: ? Time complexity: ? Space complexity: ?

125 Minimax: Recursive implementation
Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(bm) Space complexity: O(bm) (= DFS Does not keep all nodes in memory.)

126 1. Move evaluation without complete search
Complete search is too complex and impractical Evaluation function: evaluates value of state using heuristics and cuts off search New MINIMAX: CUTOFF-TEST: cutoff test to replace the termination condition (e.g., deadline, depth-limit, etc.) EVAL: evaluation function to replace utility function (e.g., number of chess pieces taken)

127 Evaluation functions Weighted linear evaluation function: to combine n heuristics f = w1f1 + w2f2 + … + wnfn E.g, w’s could be the values of pieces (1 for prawn, 3 for bishop etc.) f’s could be the number of type of pieces on the board

128 Note: exact values do not matter

129 Minimax with cutoff: viable algorithm?
Assume we have 100 seconds, evaluate 104 nodes/s; can evaluate 106 nodes/move

130 2. - pruning: search cutoff
Pruning: eliminating a branch of the search tree from consideration without exhaustive examination of each node - pruning: the basic idea is to prune portions of the search tree that cannot improve the utility value of the max or min node, by just considering the values of nodes seen so far. Does it work? Yes, in roughly cuts the branching factor from b to b resulting in double as far look-ahead than pure minimax

131 - pruning: example  6 MAX MIN 6 6 12 8

132 - pruning: example  6 MAX MIN 6  2 6 12 8 2

133 - pruning: example  6 MAX MIN 6  2  5 6 12 8 2 5

134 - pruning: example  6 MAX Selected move MIN 6  2  5 6 12 8 2 5

135 - pruning: general principle
Player m Opponent If  > v then MAX will chose m so prune tree under n Similar for  for MIN Player n Opponent v

136 Properties of -

137 The - algorithm

138 More on the - algorithm
Same basic idea as minimax, but prune (cut away) branches of the tree that we know will not contain the solution.

139 More on the - algorithm: start from Minimax

140 Remember: Minimax: Recursive implementation
Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(bm) Space complexity: O(bm) (= DFS Does not keep all nodes in memory.)

141 More on the - algorithm
Same basic idea as minimax, but prune (cut away) branches of the tree that we know will not contain the solution. Because minimax is depth-first, let’s consider nodes along a given path in the tree. Then, as we go along this path, we keep track of:  : Best choice so far for MAX  : Best choice so far for MIN

142 More on the - algorithm: start from Minimax
Note: These are both Local variables. At the Start of the algorithm, We initialize them to  = - and  = +

143 More on the - algorithm
In Min-Value: MAX  = -  = + Max-Value loops over these MIN Min-Value loops over these MAX  = -  = 5  = -  = 5  = -  = 5

144 More on the - algorithm
In Max-Value: MAX  = -  = +  = 5  = + Max-Value loops over these MIN MAX  = -  = 5  = -  = 5  = -  = 5

145 More on the - algorithm
In Min-Value: MAX  = -  = +  = 5  = + MIN Min-Value loops over these MAX  = -  = 5  = -  = 5  = 5  = 2  = -  = 5 End loop and return 5

146 More on the - algorithm
In Max-Value: MAX  = -  = +  = 5  = + Max-Value loops over these  = 5  = + MIN MAX  = -  = 5  = -  = 5  = 5  = 2  = -  = 5 End loop and return 5

147 Another way to understand the algorithm
For a given node N,  is the value of N to MAX  is the value of N to MIN

148 Example

149 - algorithm:

150 Solution NODE TYPE ALPHA BETA SCORE A Max -I +I B Min -I +I
C Max -I +I D Min -I +I E Max D Min -I 10 F Max D Min -I C Max I G Min I H Max G Min C Max I 10 B Min -I 10 J Max -I 10 K Min -I 10 L Max K Min -I NODE TYPE ALPHA BETA SCORE J Max B Min -I A Max I Q Min I R Max I S Min I T Max S Min V Min I W Max V Min R Max I 10 Q Min A Max

151 State-of-the-art for deterministic games

152 Nondeterministic games

153 Algorithm for nondeterministic games

154 Remember: Minimax algorithm

155 Nondeterministic games: the element of chance
expectimax and expectimin, expected values over all possible outcomes CHANCE ? 0.5 0.5 ? 3 ? 8 17 8

156 Nondeterministic games: the element of chance
4 = 0.5* *5 Expectimax CHANCE 0.5 0.5 5 3 5 Expectimin 8 17 8

157 Evaluation functions: Exact values DO matter
Order-preserving transformation do not necessarily behave the same!

158 State-of-the-art for nondeterministic games

159 Summary

160 Exercise: Game Playing
Consider the following game tree in which the evaluation function values are shown below each leaf node. Assume that the root node corresponds to the maximizing player. Assume the search always visits children left-to-right. (a) Compute the backed-up values computed by the minimax algorithm. Show your answer by writing values at the appropriate nodes in the above tree. (b) Compute the backed-up values computed by the alpha-beta algorithm. What nodes will not be examined by the alpha-beta pruning algorithm? (c) What move should Max choose once the values have been backed-up all the way? A B C D E F G H I J K L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 4 10 Max Min


Download ppt "Artificial Intelligence A Modern Approach"

Similar presentations


Ads by Google