Pathfinding Basic Methods.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Knowledge Representation
Advertisements

Artificial Intelligence in Game Design
Wall Building for RTS Games Patrick Schmid. Age of Empires.
Heuristic Search techniques
AI Pathfinding Representing the Search Space
Pathfinding AI John See 29 Nov, 13 Dec 2010.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Data Structures and Algorithms (60-254)
Creation of the Boundary Path Jonathan Misurda Math 1110 February 11, 2002.
CSE 380 – Computer Game Programming Pathfinding AI
CSC 423 ARTIFICIAL INTELLIGENCE
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Multiagent Probabilistic Smart Terrain Dr. John R. Sullins Youngstown State University.
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Planning under Uncertainty
1 AI for Computer Game Developers Finite state machines Path finding and waypoints A-Star path finding.
Path-Finding with Motion Constraints Amongst Obstacles in Real Time Strategies By Jeremiah J. Shepherd Committee: Jijun Tang Roger Dougal Jason O’Kane.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 5.4 Artificial Intelligence: Pathfinding.
State-Space Searches.
Chapter 5.4 Artificial Intelligence: Pathfinding.
Lab 3 How’d it go?.
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.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
Artificial Intelligence Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
ZOMBIE MADNESS! Jack Smith Steve Mander-Jones OUTLINE > GAME OVERVIEW > IMPLEMENTATION > AI FEATURES > CONCLUSION.
Developing the Game Functionality Lesson 6. Exam Objective Matrix Skills/ConceptsMTA Exam Objectives Programming the Components Understand Components.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
WAES 3308 Numerical Methods for AI
Distance. Euclidean Distance Minimum distance from a source (Value NoData) Input grid must have at least one source cell with the rest of the grid.
Path Planning Part I: Search Space Representation Part II: Table Lookup Path Finder Path III: Convincing Hunting Ref: AIWisdom 2.
Representing and Using Graphs
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Z-Town Technical Details Ben Trivett, Drew Switzer, Cameron Jett, Ryan Southard Department of Computer Science and Engineering The Ohio State University.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Chapter 1 Introduction to Game AI April 11,
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
Dijkstra’s Algorithm Supervisor: Dr.Franek Ritu Kamboj
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Chasing, Evading, Intercepting, Pattern Movements
WORLD NAVIGATION Don’t Fall Asleep Through These Topics  Tile Graphs  Points of Visibility  NavMesh  Path Smoothing  Hierarchical Pathfinding.
Toward More Realistic Pathfinding Authored by: Marco Pinter Presentation Date: 11/17/03 Presented by: Ricky Uy.
Computational theory techniques in interactive video games.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
Modifying A* Pathfinding for Video Games By: David Gelhardt.
Ch22.Branch and Bound.
Artificial Intelligence in Game Design Influence Maps and Decision Making.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Search in State Spaces Problem solving as search Search consists of –state space –operators –start state –goal states A Search Tree is an efficient way.
CSCI 4310 Lecture 4: Search 2 – Including A*. Book Winston Chapters 4,5,6.
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.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean Logic.
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.
Chapter 5.4 Artificial Intelligence: Pathfinding
Schedule for next 2 weeks
Problem Solving by Searching
Decision Maths Dijkstra’s Algorithm.
CSCE 552 Spring 2009 AI (III) By Jijun Tang.
Presentation transcript:

Pathfinding Basic Methods

Pathfinding Different types of pathfinding problems exist  No one solution appropriate to every problem! Qs: Is the destination moving or stationary? Are there obstacles? What is the terrain like? Is the shortest solution always the best solution? Is it required to reach a specific destination or just a partial route will do? What map representation is used?

Pathfinding You have heard of the A* Algorithm, the most popular & famous pathfinding algorithm But we will first look at some basic pathfinding methods (that are not as complex as A*and more suitable than A* in various situations)… A* will be covered in the next lesson

Basic Pathfinding The most simple, easiest and fastest solution to pathfinding is to re-use the Chase movement…but “chase” a destination position! if(positionX > destinationX) positionX--; else if(positionX < destinationX) positionX++; if(positionY > destinationY) positionY--; else if(positionY < destinationY) positionY++; Probably produces the most unnatural-looking path

Basic Pathfinding OK, the better approach would be to use the Line-of-Sight Chase to get a more natural path (using line-drawing algorithm on TBE and steering forces on CE) However, these methods are not suitable for certain scenarios. Can you figure out?

Obstacles? Problems with obstacles Random Movement Obstacle Avoidance Simple and effective method Works well in environments with relative few obstacles if Player In Line of Sight Follow Path to Player else Move in Random Direction

Tracing Around Obstacles Another simple method – Tracing Around Obstacles When encounter obstacle, switch to “tracing” state Tracing  follows the edge of the obstacle to work way around it

Tracing Around Obstacles Another simple method – Tracing Around Obstacles When encounter obstacle, switch to “tracing” state Tracing  follows the edge of the obstacle to work way around it Basic Tracing Movement:

Tracing Around Obstacles We need to decide WHEN to STOP tracing! One easy way: Calculate a line from the point the tracing starts to the desired destination Continue Tracing until that line is crossed, then revert back to L-o-S pathfinding Improved Tracing:

Tracing Around Obstacles Incorporate line-of-sight with tracing method At each step of tracing state, utilize line-of-sight to determine if a straight line-of-sight path can be followed to reach destination immediately If a line-of-sight path is possible, switch back to line-of-sight pathfinding state Tracing with Line-of-Sight:

Breadcrumb Pathfinding Able to make NPCs appear intelligently, because the player is unknowingly creating the path for the NPC! Each time the player takes a step, he leaves an invisible marker or “breadcrumb” in the game world Breadcrumb trail:

Breadcrumb Pathfinding When the NPC encounters a breadcrumb, it simply begins to follow the trail until the end In a real game, the number of breadcrumbs dropped will depend on the game and how smart you want the NPCs to appear. The player never sees the breadcrumb trail!

Breadcrumb Pathfinding Implementation Begin by creating a trail row and column arrays and setting each element value to -1 Checks for the player’s direction key presses and records them down  “dropping a breadcrumb” Since there is a max trail length, the oldest position will be dropped so that a new position can be added

Following the breadcrumbs Example: Troll moves randomly (8 possible directions) Loop through the trail locations to determine if the troll has moved into a breadcrumb location If a breadcrumb is found, set the troll to use the path

Following the breadcrumbs Due to possibility that the player’s path overlap itself or adjacent to previous location in path Not Smart: NPC ends up taking exact footsteps of player Solution: Allow NPC to always look for adjacent tile containing the most recent breadcrumb, skipping over breadcrumbs

Path Following (in TBE) To confine a NPC to a certain terrain element such as road, we can use terrain labeling Example: Labeling road terrain tiles as 2s and other out-of- bounds terrain as 1s

Path Following (in TBE) We do NOT want to make it move randomly allow the road tiles  Unnatural From 8 possible directions to move, eliminate those that are not part of the road. Then, decide on which of the remaining directions to take Set neighboring road tiles to a big number and those out-of- bounds to 0. Tip: Keep the NPC moving in the same general direction, turn only when have to Tip: Assign a number to each direction

Path Following (in TBE) Weigh the directions so that priority will be given to maintaining previous direction Example: Current direction: 1 Traverse the direction array in search for the most highly weighted direction, move to that direction in the next step

Path Following (in TBE) How do we increase the robustness of this path following movement (to look more natural and intelligent)?

Wall Tracing Does not calculate path from a starting to ending point Most useful in game environments with many rooms or mazes Obstacle tracing (discussed earlier) can also be used to trace walls Random movement in such environments is commonly used to increase uncertainty but NPCs often get stuck in small rooms for long periods of time

Wall Tracing How to make the troll EXPLORE and move in a systematic way around this environment?

Wall Tracing Simple solution  Left-handed approach If the NPC always move to the left, it will do a thorough job exploring the environment Move LEFT WHENEVER POSSIBLE (Remember: Left of the NPC, not the player!) Example: NPC facing player’s right Direction 2 is the NPC’s LEFT If that is blocked try STRAIGHT, then try RIGHT If still blocked, choose to reverse BACK

Wall Tracing Implementation: 4 IF-ELSE blocks to check for the directions to take (8 if accommodating all 8 directions!) Should be able to traverse almost every room, but not guaranteed to work in all geometries!

Waypoint Navigation Pathfinding  Time-consuming, CPU-intensive operation To reduce this burden: Pre-calculate paths Waypoint Navigation – Carefully place nodes in the game environment, then use pre-calculated paths or other inexpensive methods to move between each node. Useful for both TBE and CE (plus point!) Example: Placing suitable nodes on a simple map with 7 rooms What can you observe from these 7 nodes???

Waypoint Navigation Every node is in the line-of-sight of at least ONE node! Setting up like this, a NPC is able to reach every single room in the world using simple line-of-sight algorithm Game AI just needs to know HOW the nodes are connected to one other

Waypoint Navigation Using node labels and links, we can now determine a path from any room to any room Example: Moving from room with node A to room with node E  Move following ABCE path

Waypoint Navigation Can these different paths between rooms be PRE-calculated beforehand? If NO, WHY? If YES, HOW?

Waypoint Navigation To move from node to node, determine the node that is nearest to the player’s location and in player’s line-of-sight Use a lookup table to store data of shortest paths between any two nodes Establish the connections between nodes Left side: Starting nodes Top side: Ending nodes Determine best path by looking at intersection on the table between starting and ending nodes

Waypoint Navigation We can discover the connections and fill in the table either 1) manually or 2) by simulated traversal of nodes Example: Moving from A to all other nodes resulted in B as the nearest node

Waypoint Navigation Continue doing this until the entire node connection table is completed

Waypoint Navigation Example: Determine path from node B (triangle) to node G (square) by repeatedly finding the intersection, starting with nodes B and G. Using the intersected nodes as the subsequent locations to move on

Waypoint Navigation – Post-mortem Question 1: What are some drawbacks of this method? Question 2: Are there ways to improve this current method of waypoint navigation

Next… A* Algorithm  An extremely popular pathfinding algorithm used widely in games Map Representations for A* Pathfinding (Grids, Polygonal Maps, Navigation Meshes, Hierarchical)