Pathfinding with Trees Samuel Bader <s.bader@unibas.ch> DMI, - - PowerPoint PPT Presentation

pathfinding with trees
SMART_READER_LITE
LIVE PREVIEW

Pathfinding with Trees Samuel Bader <s.bader@unibas.ch> DMI, - - PowerPoint PPT Presentation

Pathfinding with Trees Samuel Bader <s.bader@unibas.ch> DMI, University of Basel 13. Sep. 2016 a start point a goal point Pathfinding We are given a map Pathfinding with Trees 2 / 24 a goal point Pathfinding We are given a map


slide-1
SLIDE 1

Pathfinding with Trees

Samuel Bader

<s.bader@unibas.ch>

DMI, University of Basel

  • 13. Sep. 2016
slide-2
SLIDE 2

Pathfinding

We are given a map a start point a goal point

Pathfinding with Trees 2 / 24

slide-3
SLIDE 3

Pathfinding

We are given a map a start point a goal point

Pathfinding with Trees 2 / 24

slide-4
SLIDE 4

Pathfinding

We are given a map a start point a goal point

Pathfinding with Trees 2 / 24

slide-5
SLIDE 5

Dijkstra's Algorithm

A simple solution: Look at all points neighbouring the start point Continue until the goal is found Follow the arrows back to the start

Pathfinding with Trees 3 / 24

slide-6
SLIDE 6

Dijkstra's Algorithm

A simple solution: Look at all points neighbouring the start point Continue until the goal is found Follow the arrows back to the start

Pathfinding with Trees 3 / 24

slide-7
SLIDE 7

Dijkstra's Algorithm

A simple solution: Look at all points neighbouring the start point Continue until the goal is found Follow the arrows back to the start

Pathfinding with Trees 3 / 24

slide-8
SLIDE 8

Dijkstra's Algorithm -> Tree Cache

Save the search tree for a single root When searching: traverse the tree from start to root traverse the tree from goal to root invert the second part concatenate parts at the root

Pathfinding with Trees 4 / 24

slide-9
SLIDE 9

Dijkstra's Algorithm -> Tree Cache

Save the search tree for a single root When searching: traverse the tree from start to root traverse the tree from goal to root invert the second part concatenate parts at the root

Pathfinding with Trees 4 / 24

slide-10
SLIDE 10

Dijkstra's Algorithm -> Tree Cache

Save the search tree for a single root When searching: traverse the tree from start to root traverse the tree from goal to root invert the second part concatenate parts at the root

Pathfinding with Trees 4 / 24

slide-11
SLIDE 11

Dijkstra's Algorithm -> Tree Cache

Save the search tree for a single root When searching: traverse the tree from start to root traverse the tree from goal to root invert the second part concatenate parts at the root

Pathfinding with Trees 4 / 24

slide-12
SLIDE 12

Dijkstra's Algorithm -> Tree Cache

Save the search tree for a single root When searching: traverse the tree from start to root traverse the tree from goal to root invert the second part concatenate parts at the root

Pathfinding with Trees 4 / 24

slide-13
SLIDE 13

Tree Cache: Example 2

Paths can have redundant parts The redundant part can be easily removed by looking for the lowest common ancestor (LCA) of the two nodes

Pathfinding with Trees 5 / 24

slide-14
SLIDE 14

Tree Cache: Example 2

Paths can have redundant parts The redundant part can be easily removed by looking for the lowest common ancestor (LCA) of the two nodes

Pathfinding with Trees 5 / 24

slide-15
SLIDE 15

LCA: Naive implementation

A B C D F G H E

Pathfinding with Trees 6 / 24

slide-16
SLIDE 16

LCA: Naive implementation

A B C D F G H E

Pathfinding with Trees 7 / 24

slide-17
SLIDE 17

LCA: Naive implementation

A B C D F G H E

Pathfinding with Trees 8 / 24

slide-18
SLIDE 18

LCA: Naive implementation

A B C D F G H E

Pathfinding with Trees 9 / 24

slide-19
SLIDE 19

LCA: Naive implementation

A B C D F G H E

Pathfinding with Trees 10 / 24

slide-20
SLIDE 20

LCA: Faster implementation

A B C D F G H E A depth-first traversal and corresponding levels: A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1

Pathfinding with Trees 11 / 24

slide-21
SLIDE 21

LCA: Faster implementation

A B C D F G H E A depth-first traversal and corresponding levels: A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1

Pathfinding with Trees 11 / 24

slide-22
SLIDE 22

LCA: Faster implementation

A B C D F G H E A depth-first traversal and corresponding levels: A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1

Pathfinding with Trees 12 / 24

slide-23
SLIDE 23

Range minimum query implementation

A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1 The range minimum query can be solved with a few lookups by pre-calculating the minimum for all sub-ranges of length : A A A C D D D D D D C C C A 2 A A A C D D D D C C C A 4 A A A C C C C A 8

Pathfinding with Trees 13 / 24

slide-24
SLIDE 24

Range minimum query implementation

A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1 The range minimum query can be solved with a few lookups by pre-calculating the minimum for all sub-ranges of length 2i: A A A C D D D D D D C C C A 2 A A A C D D D D C C C A 4 A A A C C C C A 8

Pathfinding with Trees 13 / 24

slide-25
SLIDE 25

Range minimum query implementation

A B A C D F D G D H D C E C A 1 1 2 3 2 3 2 3 2 1 2 1 The range minimum query can be solved with a few lookups by pre-calculating the minimum for all sub-ranges of length 2i: A A A C D D D D D D C C C A 2 A A A C D D D D C C C A 4 A A A C C C C A 8

Pathfinding with Trees 14 / 24

slide-26
SLIDE 26

Tree Cache: Example 3

Paths can be bad without redundant parts

Pathfinding with Trees 15 / 24

slide-27
SLIDE 27

Tree Cache improvement: More than one tree

Generate more than one tree, store distance as well as parent When searching: calculate path distance for each tree choose tree with shortest path construct path

Pathfinding with Trees 16 / 24

slide-28
SLIDE 28

Tree Cache improvement: More than one tree

Generate more than one tree, store distance as well as parent When searching: calculate path distance for each tree choose tree with shortest path construct path

Pathfinding with Trees 16 / 24

slide-29
SLIDE 29

Tree Cache: Example 4

Tree Cache generated path far too long without redundancy

Pathfinding with Trees 17 / 24

slide-30
SLIDE 30

Using Multiple Trees

Using multiple trees generates better path with redundancy

Pathfinding with Trees 18 / 24

slide-31
SLIDE 31

Both improvements combined

Generate more than one tree, store distance as well as parent, calculate LCA information for each tree When searching: look up LCA and calculate path distance for each tree choose tree with shortest path construct path

Pathfinding with Trees 19 / 24

slide-32
SLIDE 32

Both improvements combined

Generate more than one tree, store distance as well as parent, calculate LCA information for each tree When searching: look up LCA and calculate path distance for each tree choose tree with shortest path construct path

Pathfinding with Trees 19 / 24

slide-33
SLIDE 33

Experiments

Maps from the Gridbased Path Planning Competition Most maps 512x512 tiles, the largest 768x768

Pathfinding with Trees 20 / 24

slide-34
SLIDE 34

Results

map size:768x768 time per tree memory per tree Trees 230 ms 10 MB Trees + LCA 400 ms 110 MB

Pathfinding with Trees 21 / 24

slide-35
SLIDE 35

Results

map size:768x768 time per tree memory per tree Trees 230 ms 10 MB Trees + LCA 400 ms 110 MB

Pathfinding with Trees 21 / 24

slide-36
SLIDE 36

Results: Root placement

Pathfinding with Trees 22 / 24

slide-37
SLIDE 37

Conclusions

Tree Cache finds potentially bad paths very fast Path quality can be improved significantly Combination of improvements big amounts of memory Good results using only a few trees

Pathfinding with Trees 23 / 24

slide-38
SLIDE 38

Conclusions

Tree Cache finds potentially bad paths very fast Path quality can be improved significantly Combination of improvements big amounts of memory Good results using only a few trees

Pathfinding with Trees 23 / 24

slide-39
SLIDE 39

Conclusions

Tree Cache finds potentially bad paths very fast Path quality can be improved significantly Combination of improvements big amounts of memory Good results using only a few trees

Pathfinding with Trees 23 / 24

slide-40
SLIDE 40

Conclusions

Tree Cache finds potentially bad paths very fast Path quality can be improved significantly Combination of improvements big amounts of memory Good results using only a few trees

Pathfinding with Trees 23 / 24

slide-41
SLIDE 41

Future Work

advanced root placement strategies compress tree information adapt to directed graphs

Pathfinding with Trees 24 / 24

slide-42
SLIDE 42

Future Work

advanced root placement strategies compress tree information adapt to directed graphs

Pathfinding with Trees 24 / 24

slide-43
SLIDE 43

Future Work

advanced root placement strategies compress tree information adapt to directed graphs

Pathfinding with Trees 24 / 24