Graph and A* Analysis

Size: px
Start display at page:

Download "Graph and A* Analysis"

Transcription

1 Graph and A* Analysis Kyle Ray Entertainment Arts and Engineering University of Utah Salt Lake City, Ut Abstract: Pathfinding in video games is an essential tool to have for both the player and the AI in order to reach a destination in the most efficient way. A* is the best way to find the shortest path. This paper will talk about implementing the graph to represent spacial points and the pathfinding algorithm to traverse the graph with their performance on significantly large graphs and ways to improve upon performance of the graph and pathfinder. I. Introduction Representing spacial distance is essential in video games and finding the quickest path from one space to the next needs to be done in a timely matter. But generally, the path needs to be found in a quick matter so that there is minimal waiting for the program in which each millisecond counts. Real time games such as Starcraft II demands paths to be found almost instantly; where a lost millisecond could be the difference between a successful attack and a failed one. This normally wouldn't be a problem on smaller graphs, but usually the smallest a grid will be is the size of monitor and usually greater than 1000 x 1000 grid sizes. We will test the efficiency of A* and large graphs with varying resolutions. This will be a much more simplified version of a map and nowhere near the complexity of a AAA game. If the algorithm is too slow for a simplified version, then it will be even slower in AAA game; and if its fast enough, then it can easily be scaled up to meet the demands of a AAA game. The map will be a simple grid of n x m that is subdivided into a certain cell size, with 1 being the size of a pixel. The current algorithms that are used for the graph and pathfinding are more naive approaches and suffer considerably when the grid size reaches 1000 x II. Graph The graph is designed for a rectangular grid of n x m size with variable cell size. Each vertex in it represents a spacial state in the grid and is stored using an adjacency list. Although the graph itself is undirected, the architecture of the adjacency list is designed so that the graph is directed in which two vertices that are connected to each other each have an edge that points to the other. This creates more space than what is needed. Each Vertex stores an x, y point that specifies its spacial location on the grid and is used to identify it to the graph. The other property that a Vertex has is a list of Vertices that it is connected to and

2 the weight associated to traverse the spacial distance. In this example all horizontal and vertical movement have the same weight (W) while weight of diagonal movement is W2=W 2. This uniformity makes it easier to auto generate a graph of n x m size without dealing with random weights to have reliable heuristics. A next step would to add different weights that would signify different terrain and slopes. III. A* A* was developed in 1968 by Peter Hart, Nils Nilsson, and Bertram Raphael as a general case of Edgar Dijkstra's algorithm which he developed in Dijkstra s algorithm was developed to find the shortest path on a weighted graph. It used the cost to get from the starting vertex to the current vertex (G cost) in a priority queue to determine which vertex to explore next. When a vertex comes out of the priority queue, then it is fully explored and cannot have a better G cost. Since Dijkstra s only looks at G cost, it explores radially from the tree and can be expensive to find the shortest path if the destination vertex is known. Dijkstras(Graph, source): for each v in Graph: dist[v] := infinity prev[v] := v visited[v] := False dist[source] := 0 pq := priority queue pq.insertorupdate(source, 0) while pq is not empty: current := pq.pop() visited[current] := True for each v in current.neighbors: if visited[v] == True: continue endif endwhile distance := dist[current] + distance_between(current, v) if distance < dist[v]: dist[v] = distance previous[v] = current pq.insertorupdate(v, distance) endif return (dist, prev) //dist is used to show the distance from the source to any vertex, //and prev can be used to retrace the path from the source to any vertex. Endfunction

3 A* is a general purpose algorithm that adds heuristics to Dijkstra s algorithm. The heuristic cost estimates the cost from the current vertex to the destination. While calculating the h cost can be anything depending on the graph, there are 3 ways to estimate spacial difference: Manhattan Distance This is used to estimate the cost if horizontal and vertical movements are possible, but no other kind (diagonal). The formula is: W ( x 2 x 1 + y 2 y 1 ) where W is the expected weight in order to better estimate the cost. Diagonal Distance This is used to estimate the cost if horizontal, vertical, and diagonal movements are possible, but not any angle in between. The formula for this is: dx= x 2 x 1 dy= y 2 y 1 W (dx+dy)+(w2 2 W ) min(dx,dy). W is the expected weight of going horizontal and vertical while W2 is the expected cost of going diagonal. Euclidean Distance This is used to estimate the cost if any 360 degree direction is allowed where a straight line from the source to the destination would accurate. The formula for this is: W (x 2 x 1 ) 2 +( y 2 y 1 ) 2 where W is the expected weight of going in any direction. These estimations do not take into account variable weights or vertices that are impassable which would make these estimations underestimate and could affect performance if there is an impassable terrain in which the shortest path would not be the one that seemed obvious. This wasted computation has devolved the pathfinding algorithm to a simple greedy algorithm. The other thing that is added to A* is the notion of a closed and open set. The open set is the priority queue from Dijkstra s algorithm which gives us vertices to evaluate and the closed set is just a set where all vertices that go there have been fully evaluated. The algorithm also makes use of lambdas for the user to decide what heuristic they should use and make the algorithm more abstract. If the user wants to use Djikstra s instead of using a heuristic, then h_cost just needs to be 0 for all vertices so that the priority queue only uses the g cost. function A*(Graph, source, destination, heuristic): closedset := an empty set openset := an empty priority queue for each v in Graph: g_cost[v] := infinity previous[v] := v openset.insertorupdate(source, 0) g_cost[source] = 0 while openset is not empty: current := openset.pop() closedset.insert(current) if current is the destination: break

4 endfunction IV: Timing endif endwhile for each v in current.getneighbors(): if v is in closedset: continue endif path := empty list h_cost := heuristic(v, destination) previous[v] := current g_cost[v] := g_cost[current] + distance_from(current, v) openset.insertorupdate(v, g_cost[v] + h_cost) current_vertex := destination while previous[current_vertex] is not current_vertex: path.insert(current_vertex) current_vertex := previous[current_vertex] endwhile return path //using this method, the path will be in reverse order by having the destination //being in index 0 and the source will not be in the path, but that shouldn t be a //be a problem since the source is already known. There are two parts of finding the shortest path. In order to get the path, the graph must be constructed and linked. Constructing a graph is simply making each vertex while linking the graph is creating each edge for each vertex. With the graph constructed, then the A* algorithm can be timed to see how long it takes to find the shortest path from the source to the destination. The timing algorithm checks for doubling behavior to get a sense of big O and asymptotic complexity. It will do that be creating an n x n grid that will start at 32 and double until it hits 1024 or While timing the linking and the pathfinding, it will run the simulation on repetition by starting out at 1 repetition and doubling it until the duration to run all repetitions exceeds a second. This is to get a better sense of the true time over a greater average and to compensate for the time it takes to load external libraries on the first few times the algorithm is ran. After the overall time is taken, then it will run the timing algorithm without the actual algorithm in order to account for loop overhead. This overhead is then subtracted from the overall time to get a true time to run the algorithm. The timing algorithm will time how long it takes to link the graph and find the shortest path from

5 one end of the graph to the other end with varying resolutions where cell sizes are 10, 5, and 1. for i = [32, 1028] where i *= 2: repetitions := 1.0D do: elapsed := 0 start := get current time V: Results for t in [0, repetitions) where t++: //run the algorithm end := get current time total_time := end start start := get current time for t in [0, repetitons) where t++ //this will get the loop overhead end := get current time overhead_time := end start elapsed := total_time overhead_time in milliseconds / repetitions repetitions *= 2 while(repetitions * elapsed < DURATION) end do while Fig. 1 Time in milliseconds to link an n x n graph of cell size 10.

6 Fig. 2 Time in milliseconds to find the shortest path in an n x n graph of cell size 10. The two graphs in Figure 1 and Figure 2 shows that the bottleneck of the program is linking together the graph. Finding a path is relatively quickly as it gets to 20 milliseconds to find a path in a graph that has approximately 12,000 vertices. Fig. 3 The time in milliseconds to link a graph of cell size 5

7 Fig. 4 The time in milliseconds to find the path in a graph of cell size 5 A graph with finer resolution yields the same pattern as the graph will cell size 10. The time it takes to find a path has increased since the number of vertices has increased to approximately 48,000. The time it does take to link each vertex is far too long since the longest it would take is nearly 280 seconds, over 4 minutes, for a sufficiently large graph. Fig 5 Time in milliseconds to link a graph of cell size 1

8 Fig 6 Time in milliseconds to find a path in a graph of cell size 1 This is the first break from the pattern established in the larger cell sizes which suggests that even though linking the graph may take longer in the short run, the time it takes to find a path will overtake and outrun the linking asymptotically. With both finding a path and linking the graph, it takes up to 30 minutes just to find a path on with little short of 100,000 vertices and 10 minutes just to link it. This is obviously unacceptable and doing a basic A* algorithm won t be able to cut it as graph sizes will be much larger than the graph sizes used in this testing and the weights won t be as uniform adding to the cost. VI: Conclusion Even with relatively smaller size graphs, the bottleneck presented by either linking the graph or finding an actual path is not acceptable in terms of performance and finding an optimal solution in a fast time. There are many optimizations that could potentially increase the performance of the pathfinding algorithm. One thing to change is the architecture of the graph. The current graph uses an adjacency list with each vertex being directed. This results in the linking algorithm to go through each vertex and linking it to up to eight other vertices with an algorithm that finds a vertex in the graph. The first step is could be to switch the list to a matrix which would allow finding each adjacent to only take constant time instead of linear. Also since the graph is undirected, the matrix would be symmetrical allowing the algorithm to store only one half of it to save space in memory and potentially increase what we cache. Since the introduction of A* in 1968, there have been many papers that have improved and optimized it such as ANA*, HPA*, Anytime A*, Weighted A*, and many others. Any of these could provide the optimization that is needed, but HPA* would be best for this particular algorithm since it would abstract the graph into larger cell sizes to find the general shortest path and recurse into each cell and find the shortest path with a smaller grid size. Another way would be to build and link the graph at the same time as finding the path up to a certain point such as 150 vertices or more;

9 while this would limit their movement, it would increase the performance of the algorithm. There are clever ways to get about the limited movement, such as you can only move where you can see. There are many ways to improve performance and many of those ways are based on what the graph and pathfinding algorithm will be used for.

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CSE 100 Minimum Spanning Trees Prim s and Kruskal CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:

More information

Pathfinding Algorithms and Implementations on Grid Map

Pathfinding Algorithms and Implementations on Grid Map Pathfinding Algorithms and Implementations on Grid Map Steven Andrew / 13509061 Program Studi Teknik Informatika Sekolah Teknik Elektro dan Informatika Institut Teknologi Bandung, Jl. Ganesha 10 Bandung

More information

Implementation of Parallel Path Finding in a Shared Memory Architecture

Implementation of Parallel Path Finding in a Shared Memory Architecture Implementation of Parallel Path Finding in a Shared Memory Architecture David Cohen and Matthew Dallas Department of Computer Science Rensselaer Polytechnic Institute Troy, NY 12180 Email: {cohend4, dallam}

More information

Course Outline. Video Game AI: Lecture 7 Heuristics & Smoothing. Finding the best location out of several. Variable size units / special movement?

Course Outline. Video Game AI: Lecture 7 Heuristics & Smoothing. Finding the best location out of several. Variable size units / special movement? Course Outline Video Game AI: Lecture 7 Heuristics & Smoothing Nathan Sturtevant COMP 3705 http://aigamedev.com/ now has free interviews! Miscellaneous details Heuristics How better heuristics can be built

More information

the gamedesigninitiative at cornell university Lecture 20 Pathfinding

the gamedesigninitiative at cornell university Lecture 20 Pathfinding Lecture 20 Take way for Today What are primary goals for pathfinding? Identify advantages/disadvantages of * In what situations does * fail (or look bad)? What can we do to fix se problems? Why combine

More information

Search and Games. Adi Botea. ANU Summer Schools in Logic and Learning February, 2009

Search and Games. Adi Botea. ANU Summer Schools in Logic and Learning February, 2009 Search and Games Adi Botea ANU Summer Schools in Logic and Learning February, 2009 Outline 1 Introduction 2 Problem Representation 3 Uninformed Search 4 Informed Search 5 Hierarchical Abstraction Outline

More information

CMPUT 396 Sliding Tile Puzzle

CMPUT 396 Sliding Tile Puzzle CMPUT 396 Sliding Tile Puzzle Sliding Tile Puzzle 2x2 Sliding Tile States Exactly half of the states are solvable, the other half are not. In the case of 2x2 puzzles, I can solve it if I start with a configuration

More information

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

Notes. Video Game AI: Lecture 5 Planning for Pathfinding. Lecture Overview. Knowledge vs Search. Jonathan Schaeffer this Friday Notes Video Game AI: Lecture 5 Planning for Pathfinding Nathan Sturtevant COMP 3705 Jonathan Schaeffer this Friday Planning vs localization We cover planning today Localization is just mapping a real-valued

More information

Moving On. 10. Single-agent Search. Applications. Why Alpha-Beta First?

Moving On. 10. Single-agent Search. Applications. Why Alpha-Beta First? Moving On 10. Single-agent Search Jonathan Schaeffer jonathan@cs.ualberta.ca www.cs.ualberta.ca/~jonathan Two-player adversary search is nice, but not all interesting problems can be mapped to games Large

More information

Basic Motion Planning Algorithms

Basic Motion Planning Algorithms Basic Motion Planning Algorithms Sohaib Younis Intelligent Robotics 7 January, 2013 1 Outline Introduction Environment Map Dijkstra's algorithm A* algorithm Summary 2 Introduction Definition: Motion Planning

More information

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD UNIT 3 Greedy Method GENERAL METHOD Greedy is the most straight forward design technique. Most of the problems have n inputs and require us to obtain a subset that satisfies some constraints. Any subset

More information

CSC Intro to Intelligent Robotics, Spring Graphs

CSC Intro to Intelligent Robotics, Spring Graphs CSC 445 - Intro to Intelligent Robotics, Spring 2018 Graphs Graphs Definition: A graph G = (V, E) consists of a nonempty set V of vertices (or nodes) and a set E of edges. Each edge has either one or two

More information

Pathfinding. Advaith Siddharthan

Pathfinding. Advaith Siddharthan Pathfinding Advaith Siddharthan Context What is Intelligence? Rational? Search Optimisation Reasoning Impulsive? Quicker response Less predictable Personality/Emotions: Angry/Bored/Curious Overview The

More information

CS 354R: Computer Game Technology

CS 354R: Computer Game Technology CS 354R: Computer Game Technology A* Heuristics Fall 2018 A* Search f(n): The current best estimate for the best path through a node: f(n)=g(n)+h(n) g(n): current known best cost for getting to a node

More information

Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-4004) Subject Notes

Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-4004) Subject Notes Page no: Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-00) Subject Notes Unit- Greedy Technique. Introduction: Greedy is the most straight forward design technique.

More information

EE365 Homework 8. (a) A key step in Dijkstra s algorithm is computing the neighbors of a vertex x:

EE365 Homework 8. (a) A key step in Dijkstra s algorithm is computing the neighbors of a vertex x: EE365, Spring 2013-14 Professor S. Lall EE365 Homework 8 1. Dijkstra s Algorithm. In this problem, you will write an implementation of Dijkstra s algorithm, and use it to find the shortest path in a social

More information

Graphs & Digraphs Tuesday, November 06, 2007

Graphs & Digraphs Tuesday, November 06, 2007 Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements

More information

Java II Graph Algorithms II

Java II Graph Algorithms II Java II Graph Algorithms II Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Heuristic Search Pictures from http://www-cs-students.stanford.edu/~amitp/gameprog.html

More information

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front

More information

CS Algorithms and Complexity

CS Algorithms and Complexity CS 350 - Algorithms and Complexity Graph Theory, Midterm Review Sean Anderson 2/6/18 Portland State University Table of contents 1. Graph Theory 2. Graph Problems 3. Uninformed Exhaustive Search 4. Informed

More information

The big picture: from Perception to Planning to Control

The big picture: from Perception to Planning to Control The big picture: from Perception to Planning to Control Perception Location, Map Signals: video, inertial, range Sensors Real World 1 Planning vs Control 0. In control we go from to A to B in free space

More information

Automated Route Finding on Digital Terrains

Automated Route Finding on Digital Terrains Automated Route Finding on Digital Terrains D. R. Wichmann and B. C. Wünsche Graphics Group, Dept. of Computer Science, University of Auckland, Private Bag 92019, Auckland, New Zealand. daniel.wichmann@gmail.com,

More information

The Shortest Path Problem

The Shortest Path Problem The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring

More information

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS 2 Graphs: Example A directed graph V5 V = { V = E = { E Path: 3 Graphs: Definitions A directed graph V5 V6 A graph G = (V,E) consists of a set of vertices V and a set of edges

More information

CS 106X, Lecture 23 Dijkstra and A* Search

CS 106X, Lecture 23 Dijkstra and A* Search CS 106X, Lecture 23 Dijkstra and A* Search reading: Programming Abstractions in C++, Chapter 18 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

Section 08: Solutions

Section 08: Solutions Section 08: Solutions 1. Limitations and properties of shortest path algorithms (a) Draw an example of a directed graph where (a) there exists a path between two vertices s and t but (b) there is no shortest

More information

Senior Computer Team Lectures : Shortest Path Just use variables that mean something!! - G. Galperin. by Gary Sivek

Senior Computer Team Lectures : Shortest Path Just use variables that mean something!! - G. Galperin. by Gary Sivek Senior Computer Team Lectures 2000-2001: Shortest Path Just use variables that mean something!! - G. Galperin by Gary Sivek In Euclidean geometry, the shortest path between two points is a straight line.

More information

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS Dijkstra s Algorithm: Questions Initialize the graph: Give all vertices a dist of INFINITY, set all done flags to false Start at s; give s dist = 0 and set prev field to -1 Enqueue

More information

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open) Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open) circuit : vertices my repeat, edges cannot repeat (closed) path

More information

Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp

Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp Charles Lin Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp Adjacency Matrix bool way[100][100]; cin >> i >> j; way[i][j] = true;

More information

EE266 Homework 8 Solutions

EE266 Homework 8 Solutions EE266, Spring 2014-15 Professor S. Lall EE266 Homework 8 Solutions 1. Dijkstra s Algorithm. In this problem, you will write an implementation of Dijkstra s algorithm, and use it to find the shortest path

More information

SELF-BALANCING SEARCH TREES. Chapter 11

SELF-BALANCING SEARCH TREES. Chapter 11 SELF-BALANCING SEARCH TREES Chapter 11 Tree Balance and Rotation Section 11.1 Algorithm for Rotation BTNode root = left right = data = 10 BTNode = left right = data = 20 BTNode NULL = left right = NULL

More information

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018 CS 4 Section # Shortest Paths and MSTs //08 Shortest Paths There are types of shortest paths problems: Single source single destination Single source to all destinations All pairs shortest path In today

More information

CS 460/560 Introduction to Computational Robotics Fall 2017, Rutgers University. Lecture 08 Extras. A* In More Detail. Instructor: Jingjin Yu

CS 460/560 Introduction to Computational Robotics Fall 2017, Rutgers University. Lecture 08 Extras. A* In More Detail. Instructor: Jingjin Yu CS 460/560 Introduction to Computational Robotics Fall 2017, Rutgers University Lecture 08 Extras A* In More Detail Instructor: Jingjin Yu Outline A* in more detail Admissible and consistent heuristic

More information

Pathfinding. Prof. Dr. Taoufik Nouri

Pathfinding. Prof. Dr. Taoufik Nouri Pathfinding Prof. Dr. Taoufik Nouri Nouri@Nouri.ch 06-11-2014 Pathfinding Depth First Search Breadth First Search Dijkstra A* Pathfinding Pathfinding AI-Game Engine Navigation 1:Soccer Navigation 2: Raven

More information

CS 512: Comments on Graph Search 16:198:512 Instructor: Wes Cowan

CS 512: Comments on Graph Search 16:198:512 Instructor: Wes Cowan CS 512: Comments on Graph Search 16:198:512 Instructor: Wes Cowan 1 General Graph Search In general terms, the generic graph search algorithm looks like the following: def GenerateGraphSearchTree(G, root):

More information

Dynamic Programming Algorithms

Dynamic Programming Algorithms CSC 364S Notes University of Toronto, Fall 2003 Dynamic Programming Algorithms The setting is as follows. We wish to find a solution to a given problem which optimizes some quantity Q of interest; for

More information

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Floyd-Warshall algorithm in O(n 3 ) time. Neither of

More information

UNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.

UNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items. UNIT III TREES A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items. Tree: A tree is a finite set of one or more nodes such that, there

More information

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

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2. Problem Solving Agents. Problem Solving Agents: Assumptions Class Overview COMP 3501 / COMP 4704-4 Lecture 2 Prof. JGH 318 Problem Solving Agents Problem Solving Agents: Assumptions Requires a goal Assume world is: Requires actions Observable What actions? Discrete

More information

Description of The Algorithm

Description of The Algorithm Description of The Algorithm Dijkstra s algorithm works by solving the sub-problem k, which computes the shortest path from the source to vertices among the k closest vertices to the source. For the dijkstra

More information

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Algorithms (VII) Yijia Chen Shanghai Jiaotong University Algorithms (VII) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Depth-first search in undirected graphs Exploring graphs explore(g, v) Input: G = (V, E) is a graph; v V Output:

More information

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Algorithms (VII) Yijia Chen Shanghai Jiaotong University Algorithms (VII) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Depth-first search in undirected graphs Exploring graphs explore(g, v) Input: G = (V, E) is a graph; v V Output:

More information

CS 4349 Lecture October 23rd, 2017

CS 4349 Lecture October 23rd, 2017 CS 4349 Lecture October 23rd, 2017 Main topics for #lecture include #minimum_spanning_trees and #SSSP. Prelude Homework 7 due Wednesday, October 25th. Don t forget about the extra credit. Minimum Spanning

More information

Tower Defense with Augmented Reality

Tower Defense with Augmented Reality Tower Defense with Augmented Reality Bogdan-Mihai Păduraru Faculty of Computer Science, Alexandru Ion Cuza University of Iasi General Berthelot, No. 16 bogdan.paduraru@info.uaic.ro Adrian Iftene Faculty

More information

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018 CS Section # Shortest Paths and MSTs //08 Shortest Paths There are types of shortest paths problems: Single source single destination Single source to all destinations All pairs shortest path In today

More information

Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2

Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2 Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology 6.006 Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2 Quiz 2 Do not open this quiz booklet until directed to

More information

MST & Shortest Path -Prim s -Djikstra s

MST & Shortest Path -Prim s -Djikstra s MST & Shortest Path -Prim s -Djikstra s PRIM s - Minimum Spanning Tree - A spanning tree of a graph is a tree that has all the vertices of the graph connected by some edges. - A graph can have one or more

More information

Map Abstraction with Adjustable Time Bounds

Map Abstraction with Adjustable Time Bounds Map Abstraction with Adjustable Time Bounds Sourodeep Bhattacharjee and Scott D. Goodwin School of Computer Science, University of Windsor Windsor, N9B 3P4, Canada sourodeepbhattacharjee@gmail.com, sgoodwin@uwindsor.ca

More information

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

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 19 January, 2018 DIT411/TIN175, Artificial Intelligence Chapter 3: Classical search algorithms CHAPTER 3: CLASSICAL SEARCH ALGORITHMS DIT411/TIN175, Artificial Intelligence Peter Ljunglöf 19 January, 2018 1 DEADLINE FOR

More information

Beyond A*: Speeding up pathfinding through hierarchical abstraction. Daniel Harabor NICTA & The Australian National University

Beyond A*: Speeding up pathfinding through hierarchical abstraction. Daniel Harabor NICTA & The Australian National University Beyond A*: Speeding up pathfinding through hierarchical abstraction Daniel Harabor NICTA & The Australian National University Motivation Myth: Pathfinding is a solved problem. Motivation Myth: Pathfinding

More information

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list UNIT-4 Graph: Terminology, Representation, Traversals Applications - spanning trees, shortest path and Transitive closure, Topological sort. Sets: Representation - Operations on sets Applications. 1. Name

More information

Game AI: The set of algorithms, representations, tools, and tricks that support the creation and management of real-time digital experiences

Game AI: The set of algorithms, representations, tools, and tricks that support the creation and management of real-time digital experiences Game AI: The set of algorithms, representations, tools, and tricks that support the creation and management of real-time digital experiences : A rule of thumb, simplification, or educated guess that reduces

More information

Platform Games Drawing Sprites & Detecting Collisions

Platform Games Drawing Sprites & Detecting Collisions Platform Games Drawing Sprites & Detecting Collisions Computer Games Development David Cairns Contents Drawing Sprites Collision Detection Animation Loop Introduction 1 Background Image - Parallax Scrolling

More information

Exam 3 Practice Problems

Exam 3 Practice Problems Exam 3 Practice Problems HONOR CODE: You are allowed to work in groups on these problems, and also to talk to the TAs (the TAs have not seen these problems before and they do not know the solutions but

More information

Wave front Method Based Path Planning Algorithm for Mobile Robots

Wave front Method Based Path Planning Algorithm for Mobile Robots Wave front Method Based Path Planning Algorithm for Mobile Robots Bhavya Ghai 1 and Anupam Shukla 2 ABV- Indian Institute of Information Technology and Management, Gwalior, India 1 bhavyaghai@gmail.com,

More information

Algorithms for Data Science

Algorithms for Data Science Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Shortest paths in weighted graphs (Bellman-Ford, Floyd-Warshall) Outline 1 Shortest paths in graphs with

More information

Bidirectional search and Goal-directed Dijkstra

Bidirectional search and Goal-directed Dijkstra Computing the shortest path Bidirectional search and Goal-directed Dijkstra Alexander Kozyntsev October 18, 2010 Abstract We study the problem of finding a shortest path between two vertices in a directed

More information

CS350: Data Structures Dijkstra s Shortest Path Alg.

CS350: Data Structures Dijkstra s Shortest Path Alg. Dijkstra s Shortest Path Alg. James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Shortest Path Algorithms Several different shortest path algorithms exist

More information

Graph Theory. Many problems are mapped to graphs. Problems. traffic VLSI circuits social network communication networks web pages relationship

Graph Theory. Many problems are mapped to graphs. Problems. traffic VLSI circuits social network communication networks web pages relationship Graph Graph Usage I want to visit all the known famous places starting from Seoul ending in Seoul Knowledge: distances, costs Find the optimal(distance or cost) path Graph Theory Many problems are mapped

More information

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD 1 DESIGN AND ANALYSIS OF ALGORITHMS UNIT II Objectives GREEDY METHOD Explain and detail about greedy method Explain the concept of knapsack problem and solve the problems in knapsack Discuss the applications

More information

A Game Map Complexity Measure Based on Hamming Distance Yan Li, Pan Su, and Wenliang Li

A Game Map Complexity Measure Based on Hamming Distance Yan Li, Pan Su, and Wenliang Li Physics Procedia 22 (2011) 634 640 2011 International Conference on Physics Science and Technology (ICPST 2011) A Game Map Complexity Measure Based on Hamming Distance Yan Li, Pan Su, and Wenliang Li Collage

More information

Algorithms and Data Structures 2014 Exercises and Solutions Week 9

Algorithms and Data Structures 2014 Exercises and Solutions Week 9 Algorithms and Data Structures 2014 Exercises and Solutions Week 9 November 26, 2014 1 Directed acyclic graphs We are given a sequence (array) of numbers, and we would like to find the longest increasing

More information

7 th Asia-Pacific Informatics Olympiad

7 th Asia-Pacific Informatics Olympiad 7 th Asia-Pacific Informatics Olympiad Hosted by National University of Singapore, Singapore Saturday, 11 May, 2013 Task name ROBOTS TOLL TASKSAUTHOR Time Limit 1.5s 2.5s Not Applicable Heap Size 128MB

More information

CS510 \ Lecture Ariel Stolerman

CS510 \ Lecture Ariel Stolerman CS510 \ Lecture02 2012-10-03 1 Ariel Stolerman Midterm Evan will email about that after the lecture, at least 2 lectures from now. The exam will be given in a regular PDF (not an online form). We will

More information

Welfare Navigation Using Genetic Algorithm

Welfare Navigation Using Genetic Algorithm Welfare Navigation Using Genetic Algorithm David Erukhimovich and Yoel Zeldes Hebrew University of Jerusalem AI course final project Abstract Using standard navigation algorithms and applications (such

More information

Shortest Path Algorithm

Shortest Path Algorithm Shortest Path Algorithm Shivani Sanan* 1, Leena jain 2, Bharti Kappor 3 *1 Assistant Professor, Faculty of Mathematics, Department of Applied Sciences 2 Associate Professor & Head- MCA 3 Assistant Professor,

More information

Load Balancing and Termination Detection

Load Balancing and Termination Detection Chapter 7 Load Balancing and Termination Detection 1 Load balancing used to distribute computations fairly across processors in order to obtain the highest possible execution speed. Termination detection

More information

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 7 Network Flow Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 * 7.13 Assignment Problem Assignment Problem Assignment problem. Input: weighted, complete bipartite

More information

An Analysis of Dimdal s 1 An Optimal Pathfinder for Vehicles in Real-World Terrain Maps

An Analysis of Dimdal s 1 An Optimal Pathfinder for Vehicles in Real-World Terrain Maps An Analysis of Dimdal s 1 An Optimal Pathfinder for Vehicles in Real-World Terrain Maps Submitted in partial fulfillment of the requirements for the Qualifying Exam for Ph.D. students in Computer Science

More information

Lecture 23 Representing Graphs

Lecture 23 Representing Graphs Lecture 23 Representing Graphs 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson, Iliano Cervesato In this lecture we introduce graphs.

More information

Introduction to Optimization

Introduction to Optimization Introduction to Optimization Dynamic Programming November, 0 École Centrale Paris, Châtenay-Malabry, France Dimo Brockhoff INRIA Lille Nord Europe Course Overview Dimo Brockhoff, INRIA Introduction to

More information

9/17/2015 7:56 AM. CSCE 625 Programing Assignment #1 due: Tues, Sep 22 (by start of class) Objective

9/17/2015 7:56 AM. CSCE 625 Programing Assignment #1 due: Tues, Sep 22 (by start of class) Objective CSCE 625 Programing Assignment #1 due: Tues, Sep 22 (by start of class) Objective The goal of this assignment is to implement and compare the performance of Breadth-first search (BFS), Depth-First Search

More information

(Refer Slide Time: 00:18)

(Refer Slide Time: 00:18) Programming, Data Structures and Algorithms Prof. N. S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 11 Lecture 58 Problem: single source shortest

More information

CMU-Q Lecture 2: Search problems Uninformed search. Teacher: Gianni A. Di Caro

CMU-Q Lecture 2: Search problems Uninformed search. Teacher: Gianni A. Di Caro CMU-Q 15-381 Lecture 2: Search problems Uninformed search Teacher: Gianni A. Di Caro RECAP: ACT RATIONALLY Think like people Think rationally Agent Sensors? Actuators Percepts Actions Environment Act like

More information

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes Lecture 10 Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes Reading: Weiss, Chapter 9 Page 1 of 24 Midterm exam

More information

Hierarchical Path-finding Theta*: Combining Hierarchical A* with Theta*

Hierarchical Path-finding Theta*: Combining Hierarchical A* with Theta* Hierarchical Path-finding Theta*: Combining Hierarchical A* with Theta* Linus van Elswijk 1st April 2011 1 Contents 1 Problem Statement 3 1.1 Research Question......................... 4 1.2 Subquestions............................

More information

The Algorithms of Prim and Dijkstra. Class 19

The Algorithms of Prim and Dijkstra. Class 19 The Algorithms of Prim and Dijkstra Class 19 MST Introduction you live in a county that has terrible roads a new county commissioner was elected based on her campaign promise to repave the roads she promised

More information

Route planning / Search Movement Group behavior Decision making

Route planning / Search Movement Group behavior Decision making 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

More information

CS2303 Systems Programming Concepts

CS2303 Systems Programming Concepts Program 5 64 Points Due: February 27, 2008 at 11:59 p.m. {modified February 15, 2008} A Simulation of MANET Source Routing in C++ Note: There is NO late period partial credit points for this assignment!!!

More information

Pathfinding. Artificial Intelligence for gaming

Pathfinding. Artificial Intelligence for gaming Pathfinding Artificial Intelligence for gaming Pathfinding Group AI Execution Management Strategy World Inter face Character AI Decision Making Movement Pathfinding Animation Physics Pathfinding Graphs

More information

Analysis of Algorithms, I

Analysis of Algorithms, I Analysis of Algorithms, I CSOR W4231.002 Eleni Drinea Computer Science Department Columbia University Thursday, March 8, 2016 Outline 1 Recap Single-source shortest paths in graphs with real edge weights:

More information

Time-sliced pathfinding on arbitrary polygon surfaces

Time-sliced pathfinding on arbitrary polygon surfaces Time-sliced pathfinding on arbitrary polygon surfaces Arvid Norberg supervisor: Michael Minock Abstract Real-time games need to maintain a smooth frame rate and cannot

More information

lecture29: Shortest Path Algorithms

lecture29: Shortest Path Algorithms lecture29: Shortest Path Algorithms Largely based on slides by Cinda Heeren CS 225 UIUC 30th July, 2013 Outline 1 Announcements 2 3 4 Announcements lab graphs due Thursday, 8/1 final exam this Friday (8/2),

More information

Weighted Graph Algorithms Presented by Jason Yuan

Weighted Graph Algorithms Presented by Jason Yuan Weighted Graph Algorithms Presented by Jason Yuan Slides: Zachary Friggstad Programming Club Meeting Weighted Graphs struct Edge { int u, v ; int w e i g h t ; // can be a double } ; Edge ( int uu = 0,

More information

CSE 332: Data Structures & Parallelism Lecture 19: Introduction to Graphs. Ruth Anderson Autumn 2018

CSE 332: Data Structures & Parallelism Lecture 19: Introduction to Graphs. Ruth Anderson Autumn 2018 SE 332: ata Structures & Parallelism Lecture 19: Introduction to Graphs Ruth nderson utumn 2018 Today Graphs Intro & efinitions 11/19/2018 2 Graphs graph is a formalism for representing relationships among

More information

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2 Breadth-First Search, Slides for CIS DPV Chapter Jim Royer EECS October, 00 Definition In an undirected graph, the distance between two vertices is the length of the shortest path between them. (If there

More information

Quiz 2 CS 3510 October 22, 2004

Quiz 2 CS 3510 October 22, 2004 Quiz 2 CS 3510 October 22, 2004 NAME : (Remember to fill in your name!) For grading purposes, please leave blank: (1) Short Answer (40 points) (2) Cycle Length (20 points) (3) Bottleneck (20 points) (4)

More information

TA: Jade Cheng ICS 241 Recitation Lecture Note #9 October 23, 2009

TA: Jade Cheng ICS 241 Recitation Lecture Note #9 October 23, 2009 TA: Jade Cheng ICS 241 Recitation Lecture Note #9 October 23, 2009 Recitation #9 Question: For each of these problems about a subway system, describe a weighted graph model that can be used to solve the

More information

Understand graph terminology Implement graphs using

Understand graph terminology Implement graphs using raphs Understand graph terminology Implement graphs using djacency lists and djacency matrices Perform graph searches Depth first search Breadth first search Perform shortest-path algorithms Disjkstra

More information

Intelligent Path Finding for Avatars in Massively Multiplayer Online Games

Intelligent Path Finding for Avatars in Massively Multiplayer Online Games Intelligent Path Finding for Avatars in Massively Multiplayer Online Games Dewan Tanvir Ahmed, Shervin Shirmohammadi Distributed and Collaborative Virtual Environments Research Laboratory School of Information

More information

Shortest path problems

Shortest path problems Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths

More information

CS 4700: Foundations of Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence CS 4700: Foundations of Artificial Intelligence Bart Selman selman@cs.cornell.edu Informed Search Readings R&N - Chapter 3: 3.5 and 3.6 Search Search strategies determined by choice of node (in queue)

More information

1. Graph and Representation

1. Graph and Representation Chapter Graphs Tree Root Direction: parent-child relationships No cycles Graph Vertices + Edges No tree restrictions Examples World Wide Web Maps. Graph and Representation A graph G: a pair (V, E) vertices

More information

OCR H446 A-Level Computer Science

OCR H446 A-Level Computer Science Name: Class Teacher: Date: OCR H446 A-Level Computer Science REVISION BOOKLET 2.2 PROBLEM SOLVING AND PROGRAMMING Content in H446 A-Level Computer Science: 1.1 The characteristics of contemporary processors,

More information

Reach for A : an Efficient Point-to-Point Shortest Path Algorithm

Reach for A : an Efficient Point-to-Point Shortest Path Algorithm Reach for A : an Efficient Point-to-Point Shortest Path Algorithm Andrew V. Goldberg Microsoft Research Silicon Valley www.research.microsoft.com/ goldberg/ Joint with Haim Kaplan and Renato Werneck Einstein

More information

CPSC 436D Video Game Programming

CPSC 436D Video Game Programming CPSC 436D Video Game Programming Strategy & Adversarial Strategy Strategy Given current state, determine BEST next move Short term: best among immediate options Long term: what brings something closest

More information

CSC 172 Data Structures and Algorithms. Lecture 24 Fall 2017

CSC 172 Data Structures and Algorithms. Lecture 24 Fall 2017 CSC 172 Data Structures and Algorithms Lecture 24 Fall 2017 ANALYSIS OF DIJKSTRA S ALGORITHM CSC 172, Fall 2017 Implementation and analysis The initialization requires Q( V ) memory and run time We iterate

More information

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1 Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely

More information

Shortest Path Problem

Shortest Path Problem Shortest Path Problem For weighted graphs it is often useful to find the shortest path between two vertices Here, the shortest path is the path that has the smallest sum of its edge weights Dijkstra s

More information