CSE 380 – Computer Game Programming Pathfinding AI

Slides:



Advertisements
Similar presentations
Artificial Intelligence in Game Design
Advertisements

Problem solving with graph search
AI Pathfinding Representing the Search Space
Topological Sort Topological sort is the list of vertices in the reverse order of their finishing times (post-order) of the depth-first search. Topological.
Pathfinding Basic Methods.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
CS171 Introduction to Computer Science II Graphs Strike Back.
Generated Waypoint Efficiency: The efficiency considered here is defined as follows: As can be seen from the graph, for the obstruction radius values (200,
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Graphs.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Pathfinding Algorithms Josh Palmer Rachael Beers.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Using Search in Problem Solving
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Route Planning Vehicle navigation systems, Dijkstra’s algorithm, bidirectional search, transit-node routing.
Routing 2 Outline –Maze Routing –Line Probe Routing –Channel Routing Goal –Understand maze routing –Understand line probe routing.
Backtracking.
A* Pathfinding Algorithm Game Design Experience Professor Jim Whitehead February 20, 2009 Creative Commons Attribution 3.0 (Except A* algorithm images)
Chapter 5.4 Artificial Intelligence: Pathfinding.
Introduction to Routing. The Routing Problem Apply after placement Input: –Netlist –Timing budget for, typically, critical nets –Locations of blocks and.
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
Chapter 5.4 Artificial Intelligence: Pathfinding.
1 Game AI Path Finding. A Common Situation of Game AI A Common Situation of Game AI Path Planning Path Planning –From a start position to a destination.
Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
© Peter Andreae CS4HS Algorithms Searching for an item in a list Sorting a list Searching for a word in text Analysing Networks.
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience 2D Movement Pathfinding.
1 State Space of a Problem Lecture 03 ITS033 – Programming & Algorithms Asst. Prof.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
WAES 3308 Numerical Methods for AI
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
1 CO Games Development 1 Week 11 Search Methods Gareth Bellaby.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
InterConnection Network Topologies to Minimize graph diameter: Low Diameter Regular graphs and Physical Wire Length Constrained networks Nilesh Choudhury.
Lecture 3: Uninformed Search
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
L3-Network Algorithms L3 – Network Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov by Abdulghani.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Ricochet Robots Mitch Powell Daniel Tilgner. Abstract Ricochet robots is a board game created in Germany in A player is given 30 seconds to find.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Artificial Intelligence in Game Design Influence Maps and Decision Making.
CSCE 552 Spring 2010 AI (III) By Jijun Tang. A* Pathfinding Directed search algorithm used for finding an optimal path through the game world Used knowledge.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
CSCE 552 Fall 2012 AI By Jijun Tang. Homework 3 List of AI techniques in games you have played; Select one game and discuss how AI enhances its game play.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Beard & McLain, “Small Unmanned Aircraft,” Princeton University Press, 2012, Chapter 12: Slide 1 Chapter 12 Path Planning.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
Chapter 5.4 Artificial Intelligence: Pathfinding
Randomized Min-Cut Algorithm
Shortest Path from G to C Using Dijkstra’s Algorithm
i206: Lecture 14: Heaps, Graphs intro.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Unit 4: Dynamic Programming
Networks Kruskal’s Algorithm
Graphs.
Graphs.
Graphs.
Graphs.
Graphs.
Special Graphs: Modeling and Algorithms
Presentation transcript:

CSE 380 – Computer Game Programming Pathfinding AI Dig Dug, by Namco

Computation and execution of a path from point p1 to p2 Pathfinding Computation and execution of a path from point p1 to p2 Perhaps most common AI problem in games Can be very frustrating to implement well Algorithms must be tailored to fit games For an object at point p1, suggest an algorithm to get to point p2

Simple 2D Vectoring Solution Determine vector v to head towards p2 v.x = p2.x – p1.x v.y = p2.y – p1.y Now, scale v according to speed (use simple geometry) What’s the problem? we are assuming there are no obstacles

For simple obstacles that aren’t large Algorithm: Simple Trial and Error For simple obstacles that aren’t large Algorithm: Go towards target destination When you hit an obstacle: Back it up Randomly turn it right or left 45-90 degrees Move it forward again for some random amount in a range Go back to step 1 Easy & fast Not good for fixed obstacles of any size

Contour Tracing Algorithm: Go towards target destination If you hit an obstacle: trace the contour of the obstacle blocking the path move such that you are a uniform distance from edge periodically test if a line to your destination intersects the obstacle anymore if yes, stop tracing and head towards destination if no, go back to tracing

Real Time Pathfinding Modern strategy games use lots of units simultaneously Dynamically computing paths can be expensive Solution: precompute

Setup a network of paths Waypoint Pathfinding Setup a network of paths connect all points of interest in the game via a connected network of nodes each node represents a waypoint edges in the network represent: vector direction vector length

Key for precomputed paths Paths should avoid obstacles

What are precomputed paths? Nodes: locations on map (x, y) Edges direct paths to other nodes (x, y) distance Vectors computed from node to node along path Options: pre-compute and store entire paths (only viable for small data sets) dynamically calculate paths from pre-computed graph data

How do we improve finding a path Game objects don’t necessarily start at nodes they shouldn’t have to go to nodes to pick up a path either Made easier by path coverage making sure that everywhere on the board can reach a path quickly

Dynamic Pathfinding Algorithms using Graphs Breadth-first search Depth-first search Dijkstra’s algorithm A* Premise: you have a graph of nodes you are at one node & you want to get to another What combination of edges will get you there?

Fan out in all directions at the same time Breadth-first search Fan out in all directions at the same time visit each node one unit away then two units away then three etc. Like a growing circle What’s bi-directional breadth-first search?

Searches one way all the way until: Depth-first search Searches one way all the way until: it finds the goal OR it runs out of space

Similar to minimum spanning tree algorithm Dijkstra’s Algorithm Similar to minimum spanning tree algorithm O(V2), where V is the # of vertices Premise: find the shortest path from starting node to other nodes along the way use those shortest path to determine your ultimate shortest path A nice Dijkstra’s Applet: http://carbon.cudenver.edu/~hgreenbe/sessions/dijkstra/DijkstraApplet.html

Solves shortest path problem for a directed graph A* Algorithm Solves shortest path problem for a directed graph All nodes have a G & H value G: min distance from origin node (A) to the given node H: estimated distance to goal Key to determining which nodes to use: Minimize G + H

How does it work Place origin node A in open list Look at all adjacent nodes for A Add them to open list with A as parent Remove A from open list & add to closed list Which node (B) is the minimum distance (G + H)? Remove minimum from open list and add to closed list Look at all adjacent nodes for B not on the closed list Add them to open list with B as parent Which node (C) is the minimum distance (G + H)? Is that node (C) already on the open list? If yes, just ignore B in path Continue in this manner until destination is reached

Strategy games are typically played on grids A* and Grids Strategy games are typically played on grids A grid can be easily divided into large nodes store the center of the node nodes must not include impassible terrain (e.g. water) The smaller the nodes, the more processing Example assumptions: horizontal/vertical movements cost 10 diagonal movements cost 14 no diagonal movements through obstacles

A* Grid Example

A* Grid Example

A* Grid Example

A* Grid Example

A* Grid Example

A* Grid Example

A* Pathfinding for beginners References A* Pathfinding for beginners http://www.policyalmanac.org/games/aStarTutorial.htm