SlideShare a Scribd company logo
Hi,
This is Adrian
I am here because I love to build games and also
to give presentations. Today’s is about...
Pathfinding
in games
Our goal
Reach a target as well as possible.
Artificial intelligence
Non-player character (FPS)
Armies of units (RTS)
Enemies (Tower Defense)
Use cases
Player exploration
Objective display
GPS (Racing)
RTS Starcraft 2
Racing Test Drive Unlimited 2
RPG Mass Effect 2
Get objec
positio
Basic repetitive procedure
Close object
to target
Estimate
distance
to target
Get object
positione object
o target
1.
Space representation
Data structures
Grid
Each cell is denoted by its row and column.
1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7
2, 1 2, 2 2, 3 2, 4 2, 5 2, 6 2, 7
3, 1 3, 2 3, 3 3, 4 3, 5 3, 6 3, 7
Graph
Node are connected through edges.
1
3
2
6
5
8
4
7
Convex polygons
Convex = all segments with extremities inside lie inside.
2.
Space manipulation
Algorithms
Random backstepping
Take one step in the direction of
the target. Avoid obstacles by
taking a step back.
Simple algorithms
Obstacle tracing
Similar to random
backstepping, calculates the
collision before it happens.
Advanced algorithms
◆ Breadth-first search (BFS)
◆ Depth-first search (DFS)
◆ Best-first search
◆ Dijkstra’s algorithm
◆ A* algorithm
BFS vs DFS
BFS is wide; DFS is deep.
Worst-case
space complexity
Worst-case
time complexity
Implementation
BFS vs DFS
Small: linear in the length
of the current path.
Large: linear in the area of
the explored surface, as it
explores useless paths.
By using a first-in,
first-out (FIFO) data
structure, e.g., a stack.
DFS
Large: linear in the
perimeter of the explored
surface.
Small: quadratic in the
length of the minimum
path.
By using a last-in, first out
(LIFO) data structure, e.g.,
a queue.
BFS
Dijkstra’s algorithm
◆ Solves the single-source shortest path problem.
◆ Invented by Edsger Dijkstra, Turing award winner.
◆ Used in many games for efficient pathfinding.
◆ More efficient than BFS and DFS in terms of time.
◆ More complex in implementation too.
Dijkstra pseudocode
◆ Start with two sets of graph nodes S and T.
◆ S contains the source node and T all others.
While the target node is not in S, do:
◆ Find the node in T that is closest to a node in S.
◆ Move that node from T to S.
◆ Relax the edges from the node to T.
Dijkstra efficiency
◆ To find the closest node, one can use an efficient data
structure, such as a simple heap, to answer queries for
the minimum in a totally-ordered set.
◆ Its operations take worst-case O(n) time, where n is the
number of nodes. With a simple heap, the worst-case
time complexity is O(m ⨉ log n), where m is the number of
edges.
◆ By using Fibonacci heaps, one can reduce the time
complexity down to O(m + n ⨉ log n), as m >> n.
A* algorithm
◆ A “combination” of BFS and Dijkstra.
◆ Does not use exact distances between nodes.
◆ Estimates the distance by using a heuristic.
◆ The heuristic should not overestimate the distance.
Possible heuristics:
◆ Manhattan distance - go straight, no diagonals.
◆ Diagonal distance - go only 45 deg. diagonals.
◆ Euclidean distance - distance in the plane.
A* traversal
The A* will visit the heuristically closest nodes to the target.
3.
Dynamic changes
What about updates on the world?
Distance recalculation
Opportunities:
◆ With every nth iteration of the algorithm.
◆ When the processor is idle.
◆ When a unit reaches a waypoint or a corner.
◆ When the “near world” has changed.
Challenges:
◆ Previously computed data is thrown away.
◆ Can be show for large maps.
Path splice
Main idea:
◆ Splice the large path into smaller
paths.
◆ Only recalculate one or more of
the smaller paths.
◆ Handle the coordination of
multiple units - see image.
Challenges:
◆ Responds poorly to large changes.
Region partition
Main idea:
◆ Partition the map into regions.
◆ Each unit depends of a
specific region.
◆ Propagate a change only
within the region.
Challenges:
◆ Responds badly to large
changes - see image.
Obstacle prediction
Main idea:
◆ Incorporate heuristics that
predict how obstacles will move in
the future - see image.
Challenge:
◆ Depending on the game, the move
may be easy, hard, or impossible
to predict.
4.
Multiple units
How can we coordinate them?
Individual movement
Algorithm:
◆ Find the center of a set of units.
◆ Compute the path from the center
to the target.
◆ Move each individual unit in
parallel, along the path - see
image.
Coordinated movement
Algorithm:
◆ Identify a leader among the units.
◆ Compute the path from the leader
to the target.
◆ Move the leader along the path.
◆ Make the other units flock around
the leader unit - see image.
Thank you.
Any questions?
You can find me at @dumitrix

More Related Content

What's hot

Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game DevelopmentSumit Jain
 
Game Design Fundamentals Megadeck
Game Design Fundamentals MegadeckGame Design Fundamentals Megadeck
Game Design Fundamentals Megadeck
Christina Wodtke
 
Week 2, Game Design
Week 2, Game DesignWeek 2, Game Design
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
Owen Wu
 
Understanding casual games
Understanding casual gamesUnderstanding casual games
Understanding casual games
Dori Adar
 
Core Game Design (Game Architecture)
Core Game Design (Game Architecture)Core Game Design (Game Architecture)
Core Game Design (Game Architecture)
Rajkumar Pawar
 
The Art of Game Development
The Art of Game DevelopmentThe Art of Game Development
The Art of Game Development
Amir H. Fassihi
 
Introduction to Game Design
Introduction to Game DesignIntroduction to Game Design
Introduction to Game Design
Martin Sillaots
 
Snake Game in Python Progress report
Snake Game in Python Progress reportSnake Game in Python Progress report
Snake Game in Python Progress report
Muhammad Aziz
 
Phases of game development
Phases of game developmentPhases of game development
Phases of game development
Victor Terekhovskyi
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentationSaad Symbian
 
Gameplay and game mechanic design
Gameplay and game mechanic designGameplay and game mechanic design
Gameplay and game mechanic design
missstevenson01
 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1
Andrea Resmini
 
2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)
Hafiz Ammar Siddiqui
 
Game development pipeline
Game development pipelineGame development pipeline
Game development pipeline
GAME Studios
 
Direct X
Direct XDirect X
Direct X
Yash Mittal
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
Shaan Alam
 
Game Design Fundamentals: The Formal Elements
Game Design Fundamentals: The  Formal ElementsGame Design Fundamentals: The  Formal Elements
Game Design Fundamentals: The Formal Elements
Christina Wodtke
 
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper PrototypesGame Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
David Farrell
 
Game project Final presentation
Game project Final presentationGame project Final presentation
Game project Final presentationgemmalunney
 

What's hot (20)

Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 
Game Design Fundamentals Megadeck
Game Design Fundamentals MegadeckGame Design Fundamentals Megadeck
Game Design Fundamentals Megadeck
 
Week 2, Game Design
Week 2, Game DesignWeek 2, Game Design
Week 2, Game Design
 
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio [Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
 
Understanding casual games
Understanding casual gamesUnderstanding casual games
Understanding casual games
 
Core Game Design (Game Architecture)
Core Game Design (Game Architecture)Core Game Design (Game Architecture)
Core Game Design (Game Architecture)
 
The Art of Game Development
The Art of Game DevelopmentThe Art of Game Development
The Art of Game Development
 
Introduction to Game Design
Introduction to Game DesignIntroduction to Game Design
Introduction to Game Design
 
Snake Game in Python Progress report
Snake Game in Python Progress reportSnake Game in Python Progress report
Snake Game in Python Progress report
 
Phases of game development
Phases of game developmentPhases of game development
Phases of game development
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
 
Gameplay and game mechanic design
Gameplay and game mechanic designGameplay and game mechanic design
Gameplay and game mechanic design
 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1
 
2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)
 
Game development pipeline
Game development pipelineGame development pipeline
Game development pipeline
 
Direct X
Direct XDirect X
Direct X
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 
Game Design Fundamentals: The Formal Elements
Game Design Fundamentals: The  Formal ElementsGame Design Fundamentals: The  Formal Elements
Game Design Fundamentals: The Formal Elements
 
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper PrototypesGame Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
 
Game project Final presentation
Game project Final presentationGame project Final presentation
Game project Final presentation
 

Similar to Pathfinding in games

GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
smashflt
 
Mrongraphs acm-sig-2 (1)
Mrongraphs acm-sig-2 (1)Mrongraphs acm-sig-2 (1)
Mrongraphs acm-sig-2 (1)
Nima Sarshar
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
Subid Biswas
 
Deep Learning Tutorial
Deep Learning Tutorial Deep Learning Tutorial
Deep Learning Tutorial
Ligeng Zhu
 
Darkonoid
DarkonoidDarkonoid
Darkonoid
graphitech
 
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_i
ankit_ppt
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolJun Hu
 
Practical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsPractical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsNaughty Dog
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics Pipeline
Mark Kilgard
 
2-Heuristic Search.ppt
2-Heuristic Search.ppt2-Heuristic Search.ppt
2-Heuristic Search.ppt
MIT,Imphal
 
dsa.pptx
dsa.pptxdsa.pptx
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
Geoffrey Fox
 
Ai part 1
Ai part 1Ai part 1
Ai part 1
spartasoft
 
Hadoop classes in mumbai
Hadoop classes in mumbaiHadoop classes in mumbai
Hadoop classes in mumbai
Vibrant Technologies & Computers
 
VoxelNet
VoxelNetVoxelNet
VoxelNet
taeseon ryu
 

Similar to Pathfinding in games (20)

GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
 
Mrongraphs acm-sig-2 (1)
Mrongraphs acm-sig-2 (1)Mrongraphs acm-sig-2 (1)
Mrongraphs acm-sig-2 (1)
 
Lecture set 5
Lecture set 5Lecture set 5
Lecture set 5
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Deep Learning Tutorial
Deep Learning Tutorial Deep Learning Tutorial
Deep Learning Tutorial
 
Darkonoid
DarkonoidDarkonoid
Darkonoid
 
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_i
 
Lucio marcenaro tue summer_school
Lucio marcenaro tue summer_schoolLucio marcenaro tue summer_school
Lucio marcenaro tue summer_school
 
Practical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsPractical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT Methods
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics Pipeline
 
2-Heuristic Search.ppt
2-Heuristic Search.ppt2-Heuristic Search.ppt
2-Heuristic Search.ppt
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
distance_matrix_ch
distance_matrix_chdistance_matrix_ch
distance_matrix_ch
 
Games.4
Games.4Games.4
Games.4
 
Ai part 1
Ai part 1Ai part 1
Ai part 1
 
Hadoop classes in mumbai
Hadoop classes in mumbaiHadoop classes in mumbai
Hadoop classes in mumbai
 
VoxelNet
VoxelNetVoxelNet
VoxelNet
 

Recently uploaded

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 

Recently uploaded (20)

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 

Pathfinding in games

  • 1.
  • 2. Hi, This is Adrian I am here because I love to build games and also to give presentations. Today’s is about...
  • 4. Our goal Reach a target as well as possible.
  • 5. Artificial intelligence Non-player character (FPS) Armies of units (RTS) Enemies (Tower Defense) Use cases Player exploration Objective display GPS (Racing)
  • 7. Racing Test Drive Unlimited 2
  • 9. Get objec positio Basic repetitive procedure Close object to target Estimate distance to target Get object positione object o target
  • 11. Grid Each cell is denoted by its row and column. 1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7 2, 1 2, 2 2, 3 2, 4 2, 5 2, 6 2, 7 3, 1 3, 2 3, 3 3, 4 3, 5 3, 6 3, 7
  • 12. Graph Node are connected through edges. 1 3 2 6 5 8 4 7
  • 13. Convex polygons Convex = all segments with extremities inside lie inside.
  • 15. Random backstepping Take one step in the direction of the target. Avoid obstacles by taking a step back. Simple algorithms Obstacle tracing Similar to random backstepping, calculates the collision before it happens.
  • 16. Advanced algorithms ◆ Breadth-first search (BFS) ◆ Depth-first search (DFS) ◆ Best-first search ◆ Dijkstra’s algorithm ◆ A* algorithm
  • 17. BFS vs DFS BFS is wide; DFS is deep.
  • 18. Worst-case space complexity Worst-case time complexity Implementation BFS vs DFS Small: linear in the length of the current path. Large: linear in the area of the explored surface, as it explores useless paths. By using a first-in, first-out (FIFO) data structure, e.g., a stack. DFS Large: linear in the perimeter of the explored surface. Small: quadratic in the length of the minimum path. By using a last-in, first out (LIFO) data structure, e.g., a queue. BFS
  • 19. Dijkstra’s algorithm ◆ Solves the single-source shortest path problem. ◆ Invented by Edsger Dijkstra, Turing award winner. ◆ Used in many games for efficient pathfinding. ◆ More efficient than BFS and DFS in terms of time. ◆ More complex in implementation too.
  • 20. Dijkstra pseudocode ◆ Start with two sets of graph nodes S and T. ◆ S contains the source node and T all others. While the target node is not in S, do: ◆ Find the node in T that is closest to a node in S. ◆ Move that node from T to S. ◆ Relax the edges from the node to T.
  • 21. Dijkstra efficiency ◆ To find the closest node, one can use an efficient data structure, such as a simple heap, to answer queries for the minimum in a totally-ordered set. ◆ Its operations take worst-case O(n) time, where n is the number of nodes. With a simple heap, the worst-case time complexity is O(m ⨉ log n), where m is the number of edges. ◆ By using Fibonacci heaps, one can reduce the time complexity down to O(m + n ⨉ log n), as m >> n.
  • 22. A* algorithm ◆ A “combination” of BFS and Dijkstra. ◆ Does not use exact distances between nodes. ◆ Estimates the distance by using a heuristic. ◆ The heuristic should not overestimate the distance. Possible heuristics: ◆ Manhattan distance - go straight, no diagonals. ◆ Diagonal distance - go only 45 deg. diagonals. ◆ Euclidean distance - distance in the plane.
  • 23. A* traversal The A* will visit the heuristically closest nodes to the target.
  • 24. 3. Dynamic changes What about updates on the world?
  • 25. Distance recalculation Opportunities: ◆ With every nth iteration of the algorithm. ◆ When the processor is idle. ◆ When a unit reaches a waypoint or a corner. ◆ When the “near world” has changed. Challenges: ◆ Previously computed data is thrown away. ◆ Can be show for large maps.
  • 26. Path splice Main idea: ◆ Splice the large path into smaller paths. ◆ Only recalculate one or more of the smaller paths. ◆ Handle the coordination of multiple units - see image. Challenges: ◆ Responds poorly to large changes.
  • 27. Region partition Main idea: ◆ Partition the map into regions. ◆ Each unit depends of a specific region. ◆ Propagate a change only within the region. Challenges: ◆ Responds badly to large changes - see image.
  • 28. Obstacle prediction Main idea: ◆ Incorporate heuristics that predict how obstacles will move in the future - see image. Challenge: ◆ Depending on the game, the move may be easy, hard, or impossible to predict.
  • 29. 4. Multiple units How can we coordinate them?
  • 30. Individual movement Algorithm: ◆ Find the center of a set of units. ◆ Compute the path from the center to the target. ◆ Move each individual unit in parallel, along the path - see image.
  • 31. Coordinated movement Algorithm: ◆ Identify a leader among the units. ◆ Compute the path from the leader to the target. ◆ Move the leader along the path. ◆ Make the other units flock around the leader unit - see image.
  • 32. Thank you. Any questions? You can find me at @dumitrix