Route planning / Search Movement Group behavior Decision making

Similar documents
Informed search methods

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

DFS. Depth-limited Search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

CAP 4630 Artificial Intelligence

CSE 473. Chapter 4 Informed Search. CSE AI Faculty. Last Time. Blind Search BFS UC-BFS DFS DLS Iterative Deepening Bidirectional Search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

Artificial Intelligence

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

Informed Search and Exploration

Informed Search Methods

Informed Search and Exploration

Problem solving and search

Ar#ficial)Intelligence!!

CS 771 Artificial Intelligence. Informed Search

CS486/686 Lecture Slides (c) 2015 P.Poupart

Outline for today s lecture. Informed Search I. One issue: How to search backwards? Very briefly: Bidirectional search. Outline for today s lecture

CS486/686 Lecture Slides (c) 2014 P.Poupart

Informed search strategies (Section ) Source: Fotolia

Artificial Intelligence

Introduction to Artificial Intelligence. Informed Search

Artificial Intelligence

Solving Problems by Searching

Artificial Intelligence. Informed search methods

CS 520: Introduction to Artificial Intelligence. Lectures on Search

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

CPS 170: Artificial Intelligence Search

ITCS 6150 Intelligent Systems. Lecture 5 Informed Searches

HW#1 due today. HW#2 due Monday, 9/09/13, in class Continue reading Chapter 3

S A E RC R H C I H NG N G IN N S T S A T T A E E G R G A R PH P S

Informed search algorithms

Problem Solving and Search

Lecture 4: Search 3. Victor R. Lesser. CMPSCI 683 Fall 2010

Informed (heuristic) search (cont). Constraint-satisfaction search.

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2: Search. Problem Solving Agents

Robot Programming with Lisp

Informed search algorithms. Chapter 4, Sections 1 2 1

CS 4700: Foundations of Artificial Intelligence. Bart Selman. Search Techniques R&N: Chapter 3

Outline. Best-first search

AGENTS AND ENVIRONMENTS. What is AI in reality?

INTRODUCTION TO HEURISTIC SEARCH

Artificial Intelligence

Informed Search CS457 David Kauchak Fall 2011

Informed Search Lecture 5

AGENTS AND ENVIRONMENTS. What is AI in reality?

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 19 January, 2018

Search. CS 3793/5233 Artificial Intelligence Search 1

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2. Problem Solving Agents. Problem Solving Agents: Assumptions

mywbut.com Informed Search Strategies-I

CSE 40171: Artificial Intelligence. Informed Search: A* Search

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Basic Search. Fall Xin Yao. Artificial Intelligence: Basic Search

Lecture 4: Informed/Heuristic Search

Informed Search and Exploration

Informed Search (Ch )

Informed search. Soleymani. CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2016

CS:4420 Artificial Intelligence

Chapter 3 Solving Problems by Searching Informed (heuristic) search strategies More on heuristics

Informed search algorithms

COMP219: Artificial Intelligence. Lecture 7: Search Strategies

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Notes. Video Game AI: Lecture 5 Planning for Pathfinding. Lecture Overview. Knowledge vs Search. Jonathan Schaeffer this Friday

Informed Search Algorithms

Chapter 3: Informed Search and Exploration. Dr. Daisy Tang

Artificial Intelligence

CSS 343 Data Structures, Algorithms, and Discrete Math II. Graphs II. Yusuf Pisan

Informed search algorithms Michal Pěchouček, Milan Rollo. Department of Cybernetics Czech Technical University in Prague

Informed search algorithms

Set 2: State-spaces and Uninformed Search. ICS 271 Fall 2015 Kalev Kask

Wissensverarbeitung. - Search - Alexander Felfernig und Gerald Steinbauer Institut für Softwaretechnologie Inffeldgasse 16b/2 A-8010 Graz Austria

Informed Search. Notes about the assignment. Outline. Tree search: Reminder. Heuristics. Best-first search. Russell and Norvig chap.

Outline. Best-first search

Downloaded from ioenotes.edu.np

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

CS-E4800 Artificial Intelligence

Informed search algorithms

Informed search algorithms

Informed Search and Exploration

Problem solving and search

Foundations of AI. 4. Informed Search Methods. Heuristics, Local Search Methods, Genetic Algorithms

CS 4700: Foundations of Artificial Intelligence

Uninformed Search Methods

Informed Search A* Algorithm

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Foundations of AI. 4. Informed Search Methods. Heuristics, Local Search Methods, Genetic Algorithms. Wolfram Burgard & Bernhard Nebel

Chapter 3: Solving Problems by Searching

Informed/Heuristic Search

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 23 January, 2018

Solving problems by searching

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.

CS 331: Artificial Intelligence Informed Search. Informed Search

521495A: Artificial Intelligence

Planning, Execution & Learning 1. Heuristic Search Planning

Lecture Plan. Best-first search Greedy search A* search Designing heuristics. Hill-climbing. 1 Informed search strategies. Informed strategies

CS 331: Artificial Intelligence Informed Search. Informed Search

TDT4136 Logic and Reasoning Systems

CS 4700: Foundations of Artificial Intelligence

CS414-Artificial Intelligence

Transcription:

Game AI

Where is the AI Route planning / Search Movement Group behavior Decision making

General Search Algorithm Design Keep a pair of set of states: One, the set of states to explore, called the open set or the frontier. The second, the set of states you have seen, called the closed set. Initially just put the start node in the open set While the open set is not empty Take a node from the open set. Add it to the closed set. If the node is a goal node you re done! if next is in closed then continue. Necessary? Not if we check if an item is in Open before adding Otherwise expand the node, generating all of the node s successors and add the ones we have not seen to the open list If finish the loop because the open set becomes empty, then failure. What if one of the successors was a goal node? Could we have just declared success right away? What order should we remove items to the open set? Is our algorithm complete? Is it optimal?

Basic Search Algorithms Depth First (DFS) Organize open set as a stack (LIFO) Breadth First (BFS) Organize open set as a queue (FIFO) Data structure for closed set? What are the operations? Add and check membership. Advantages? Complete? Optimal?

Breadth First Search (modified) Breadth first search can be made a little more efficient: If start is a goal then success! Add start to open While open set is not empty Take the next node off of open. If in closed set continue Generate its successors and for each successor If it is a goal state then done. Otherwise if not seen add to open. Where is the gain? Seeing if a state is the goal when we generate it.

Saving space BFS has a large frontier / open set. It grows exponentially. Can we reduce it? Bi directional Bounded DFS Iterative DFS

Bidirectional Apply a breadth first search from both start and from goal. When their frontiers intersect we have a solution. Benefit? Space reduced from O(bd) to O(bd/2)

Depth Limited If you know the solution can not be any deeper than depth k Then use DFS and cut off your search at depth k. May greatly speed up DFS. Ensures completeness. Optimal?

Iterative Deepening for (int level = 0; found?; ++level) depthlimited(level) Huh? We will be searching the beginning levels over and over! All our efforts will be thrown out! Yes, compared to BFS we are trading time for space. But it is optimal!

Uniform Cost What if the effort to go from one state to another is not always the same? E.g. Traveling on a diagonal in a grid might cost 1.4 times the cost of left/right/up/down. Or our steps might involve plane trips of different distances. Uniform cost means we want to expand our search so that we explore nodes uniformly in how much it costs to get to them. Same as Dijkstra s shortest path, but that is to all nodes, not just to a goal. Critical point in the algorithm: a state on the open set may change! Cannot use optimization that we used in BFS

From Sibiu to Bucharest From To Distance Sibiu Fagaras 99 Sibiu Rimnicu Vilcea 80 Fargaras Bucharest 211 Rimnicu Vilcea Pitesti 101 Pitesti Bucharest 101

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti Open: [S(0)]

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti Open: [R(80), F(99)]

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti Open: [F(99), P(181)]

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti Open: [P(181), B(310)]

Sibiu 99 Fargaras 211 Bucharest 80 101 101 Rimnicu Vilcea Pitesti Open: [B(282)]

Uninformed Search Uninformed? Means we don t know how far it is to the goal. Depth First Uses a stack to represent open list. Breadth First Uses a queue to represent open. Uniform Cost / Dijkstra (for a single goal) Add nodes based on current cost of reaching the node. i.e. use a priority queue. Similar to breadth first, but does not assume every step has the same cost. Variations Depth Limited Iterative Deepening Bidirectional

Informed Suppose we have some idea how far the goal is away from each node? The idea is known as a heuristic. It is not assumed to be accurate. We could always expand a node that promises to get us closest to the goal. That s called being greedy. Or we could also take into account the actual cost to get us as far as we have come. That s known as A* algorithm

A* Data Structures: start node target node successor function For each node: Path taken (e.g. pointer to prior) Cost from start: g(n) Estimated cost to goal: h(n), open list (ordered by cost function f(n) = g(n) + h(n) ) closed set

A* Add start node to open list While open list is not empty remove highest priority node (lowest estimated cost) if node is goal, then success: return its solution path. Else place node on closed list generate successors. For each successor: Compute cost: f(n) = g(n) + h(n) If successor is on open and new g(n) is better than old, update entry on open Else if successor is on closed and new g(n) is better than old, remove from closed and add to open with new f(n) Else if not previously seen add to open. If the queue becomes empty then there was no solution.

Admissibility A heuristic is called admissible if it is guaranteed to be an underestimate of the actual distance for all cases An admissible heuristic will result in A* being optimal.

A* in Problem Solving 15 Puzzle Heuristics Path finding Heuristics 1) How many tiles are out of position? 2) What is the total distance that tiles are out of place? 1) Crow flies distance 2) Manhattan distance.

Triangle Inequality Consistent (aka monotonic) A heuristic function h is consistent if Given nodes n1 and n2 And their heuristic costs h(n1) and h(n2) Together with the actual cost to go from n1 to n2, c(n1, n2) Then: h(n1) h(n2) + c(n1, n2) If a heuristic function is consistent then when a node is placed on the closed set, it never has to move back to the open set. Admissible functions are almost always consistent. But games like to use inadmissible functions.

Data Structures for Open Set Insert Membership Get/Remove Best Adjust Unsorted Array/List O(1) O(F) O(F) O(F) Sorted Array O(F) Binary search: O(log F) Keep at end: O(1) Find: O(log F) Change: O(F) Sorted Linked List Find: O(F) O(F) O(1) O(F) for find. O(1) to adjust Indexed Array O(1) O(1) O(N) O(1) Hash Table O(1) O(1) O(N) O(1) Heap O(log F) O(F) O(log F) O(F) for find O(log F) to adjust Heap + Indexed Array O(log F) O(1) O(log F) O(F)