1
ANU COLLEGE OF ENGINEERING & COMPUTER SCIENCE Fast and Optimal Pathnding on Grid Maps Daniel Harabor Adi Botea 1 The Problem Pathnding in modern video games often involves exploring highly regular environments such as cities, sewers or dungeons see for example Fig- ure 1. These locations are usually symmetric in the sense that many optimal length paths exist be- tween arbitrary pairs of locations. Symmetry is undesirable as it increases the size of the search space and forces search algorithms to waste time. In this work we speed up pathnding by identifying and eliminating symme- try in 4-connected grid maps. Our method is fast, optimal, memory efcient and readily combined with any existing pathnding system. Figure 1: Typical examples of highly regular video game environments. 2 The Big Idea We propose the following ofine symmetry breaking technique: V = IR E = mc 1. Decompose the grid map into a set of empty rectan- gular rooms. 2. Prune all tiles not on the perimeter of an empty room. 3. Connect tiles on opposite sides of the perimeter. Sometimes a tile which has been pruned is later re- quired; for example as a start or goal location. To handle such cases we use an online re-insertion procedure. Figure 2 shows a concrete example. Figure 2: We speed up search by decomposing a 4-connected map into empty rectangular rooms which can be traversed without visiting any tiles from their interior. This method is both fast and provably optimal. 3 Results Figure 3 summarises our main result while Figure 4 and Figure 5 show the amount of improvement we can regularly obtain. We evaluate performance by running the well known A* algorithm on a range of realistic and synthetic benchmarks: Adaptive Depth: 12 maps of size 100×100 which are composed of rectangular rooms and large open areas. Baldur’s Gate: 120 maps from BioWare’s Baldur’s Gate II: Shadows of Amn. Sizes vary from 50×50 to 320×320. Rooms: 300 maps of size 256×256 which are divided into 32×32 rectangular areas. 50 100 150 2 4 6 8 10 Average Speedup: Adaptive Depth Path Length Avg. Speedup Factor Nodes Expanded Search Time 0 100 200 300 400 2 4 6 8 10 Average Speedup: Baldur's Gate Path Length Avg. Speedup Factor Nodes Expanded Search Time 0 100 200 300 400 500 5 10 15 20 Average Speedup: Rooms Path Length Avg. Speedup Factor Nodes Expanded Search Time Figure 3: Using symmetry elimination A* runs between 3 to 20 times faster on a range of synthetic and realistic benchmarks. The best results are achieved on maps with large open areas where we eliminate many symmetric paths. Figure 4: Tiles explored before symme- try elimination. Figure 5: Tiles explored after symmetry elimination. 4 Future Work We are investigating a number of extensions: Stronger symmetry breaking techniques to prune more tiles. An analogous algorithm for 8-connected grid maps. Hybrid algorithms that combine our speedup technique with existing methods to achieve further performance increases. 5 More Information Email: [email protected] Web: http://harablog.wordpress.com

Daniel Harabor Adi Botea - users.cecs.anu.edu.au

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

ANU College of eNgiNeeriNg & CompUter SCieNCe

Fast and Optimal Pathfinding on Grid MapsDaniel Harabor Adi Botea

1 The Problem

Pathfinding in modern video games often involvesexploring highly regular environments such ascities, sewers or dungeons – see for example Fig-ure 1. These locations are usually symmetric inthe sense that many optimal length paths exist be-tween arbitrary pairs of locations. Symmetry is undesirable as it increasesthe size of the search space and forces search algorithms to waste time.

In this work we speed up pathfinding by identifying and eliminating symme-try in 4-connected grid maps. Our method is fast, optimal, memory efficientand readily combined with any existing pathfinding system.

Figure 1: Typical examples of highly regular video game environments.

2 The Big Idea

We propose the following offline symmetry breaking technique:

V = IRE = mc

1. Decompose the grid map into a set of empty rectan-gular rooms.

2. Prune all tiles not on the perimeter of an emptyroom.

3. Connect tiles on opposite sides of the perimeter.

Sometimes a tile which has been pruned is later re-quired; for example as a start or goal location. Tohandle such cases we use an online re-insertionprocedure. Figure 2 shows a concrete example.

Figure 2: We speed up search by decomposing a 4-connected map into empty rectangular rooms which can betraversed without visiting any tiles from their interior. This method is both fast and provably optimal.

3 Results

Figure 3 summarises our main result while Figure 4 and Figure 5 show the amountof improvement we can regularly obtain. We evaluate performance by running thewell known A* algorithm on a range of realistic and synthetic benchmarks:• Adaptive Depth: 12 maps of size 100×100 which are composed of rectangular

rooms and large open areas.• Baldur’s Gate: 120 maps from BioWare’s Baldur’s Gate II: Shadows of Amn.

Sizes vary from 50×50 to 320×320.• Rooms: 300 maps of size 256×256 which are divided into 32×32 rectangular

areas.

50 100 150

24

68

10

Average Speedup: Adaptive Depth

Path Length

Avg

. Spe

edup

Fac

tor

Nodes ExpandedSearch Time

0 100 200 300 400

24

68

10

Average Speedup: Baldur's Gate

Path Length

Avg

. Spe

edup

Fac

tor

Nodes ExpandedSearch Time

0 100 200 300 400 500

510

1520

Average Speedup: Rooms

Path Length

Avg

. Spe

edup

Fac

tor

Nodes ExpandedSearch Time

Figure 3: Using symmetry elimination A* runs between 3 to 20 times faster on a range of synthetic and realisticbenchmarks. The best results are achieved on maps with large open areas where we eliminate many symmetric paths.

Figure 4: Tiles explored before symme-try elimination.

Figure 5: Tiles explored after symmetryelimination.

4 Future Work

We are investigating a number of extensions:• Stronger symmetry breaking techniques to prune more tiles.• An analogous algorithm for 8-connected grid maps.• Hybrid algorithms that combine our speedup technique with

existing methods to achieve further performance increases.

5 More Information

Email: [email protected]

Web: http://harablog.wordpress.com