"Designing a PathFinding Algorithm to Enable Dynamic RTS Serious Games", in Proceedings of International Workshop on Serious Games Development and Applications. University of Derby, Kedleston Road, Derby, UK. July 2010.
International Workshop on Serious Games Development and Applications
1. ELIOS Lab
Designing a PathFinding
Algorithm to Enable
Dynamic
RTS Serious Games
M. Bardini, F. Bellotti, R. Berta, A. De Gloria
ELIOS Lab
DIBE – University of Genoa
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 1
2. RTS
Popular game category
Take decisions and move objects on a territory
Continuous time-line
In typical RTS, roads and tracks in the
background map are not considered by the
application’s logic
Just a different pattern, an ornament
No benefits by passing through them
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 2
3. The past of RTS
TM TM
Popular game series Age Of Empire and Total War
In the Age of Empire series any unit follows the shortest path,
even if it’s a simple worker or a soldier in patrol
In the Total War series roads are used only to enrich maps
In the world map, roads connect different cities
– In this case they are pre-calculated paths
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 3
4. And the future?
TM
Recently, Ubisoft proposed a new RTS for
TM
the WWII, R.U.S.E
Official news and videos
benefits for using roads
units will gain a speed up for the transfers, so controlling
roads will become vital
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 4
5. Serious Game for Geo-Training
Work in Progress Serious Game
Training military workforces and civil protection
personnel on specific target geographic areas
Challenges
Logic
Artificial opponent’s intelligence, levels, resources etc.
Processing of map images used as dynamic
inputs.
Semantic interpretation and annotate of images usable
as a background corresponding to the logic of the
application
– Identification of points for resource placement
– Characterization of the territory
– Definition of best paths to destination
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 5
6. The idea
A player moves objects on the map
The system computes the best path & relevant time cost.
Considering the actual nature of the segments
– E.g. roads, fields, wood
– standard image segmentation algorithms
RealPath
Automatic procedure for identifying best routes
solely relying on the real-time processing of
grayscale input images
With parallel computing implementation
Solution for designing levels of RTSs
Other geo-referenced applications with paths in
outdoor maps
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 6
7. Pathfinding
How to extract the nodes of a path-search
tree from a picture?
Grid layouts
Polygonal/Tiles Movement, Edge Movement,
Vertex Movement
Hybrid solutions
Waypoints as meaningful points in an
environment
Placed manually, like the connections
Very efficient tree building
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 7
8. The RealPath algorithm
Input
Raster image, satellite or aerial
Possibly ortophotos
– Accurate representation of the earth's surface
– Adjusted for topographic relief, lens distortion, and
camera tilt
Target
Automatic definition of waypoints
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 8
9. Automatic definition of waypoints
Pre-processing
Pixel value normalization
0-255 range
Square to enhance gradient
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 9
10. Automatic definition of waypoints
A* search to destination
Every pixel in the image as a possible node
Traveling cost proportional to the gradient
difference
Differentiate among large roads and small
winding roads
Cost weighted with the terrain nature
– Terrain recognition
A gradient threshold prevents off-road traveling
and reduce the number of arcs
The destination point may be off-road, the graph
may result unconnected
– a loop gradually reduces the gradient threshold if the
graph results to be unconnected
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 10
11. Automatic definition of waypoints
A simple animation
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 11
12. Optimizations
A* algorithm scrolls all the nodes in the
Open List to know whether a node was
already created
Critical for a real-time response
Open List implemented as a Hash Table
Constant computational cost for each element,
independent of the search area
The Hash function relies on the position of the
pixel in the image
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 12
13. Optimizations
Our work has not considered
optimizations for realizing a natural
movement for the NPC
Important for 3D games
Lots of solutions already implemented in
current videogames
The RealPath’s output can be post-
processed by a standard algorithm, to
smooth the path and move it away from
obstacles
Better results expected as computation points
are much more than in waypoint/grid algorithms
1st International Workshop on
Serious Games Development & Applications
13
Univ. of Derby, 8 Jul. 2010
14. Pyramidal parallel implementation
Parallel algorithms to speed-up
performance in current architectures
Pyramidal algorithms, an established
family of parallel algorithms for image
processing
Robust feature extraction
Multilevel-resolution
A pyramid consists of a sequence of scaled
and Gaussian-filtered images
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 14
15. Pyramidal parallel algorithms
Not a parallel version of A*
RealPath designed to exploit parallel
executions of A* processing distinct sets
of data obtainable through lower-
resolution analysis
Compute a very coarse first path
Define an initial set of points and
Recursively refine the subpaths until
converging to the final path in the original,
high-resolution map.
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 15
16. Pyramidal parallel algorithms
A data structure (pyramid shape) is
needed for
A first, coarse-grain analysis on a small-size
image
subsequent path refinements in ever more
detailed maps
After experiments, for a medium-size image
(1-4 MB), 3- or 4-level Gaussian pyramids
are sufficient
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 16
17. Pyramidal parallel algorithms
From the first path (top of the pyramid), a
series of n points is chosen
Dividing a path into 30-40 segments usually gives
optimal results
Strong dependence on the parallelism level of the
underlying computing architecture
Every subsequent couple of such n points
constitutes the start and arrival points of n-1
sub-paths
Every sub-path is independent of each other =>
separable working data sets => parallelizable
computation
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 17
18. Pyramidal parallel algorithms
By joining the sub-paths in the original image, a sub-optimal
path from the origin to the destination is obtained.
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 18
19. Pyramidal parallel algorithms
By joining the sub-paths in the original image, a sub-optimal
path from the origin to the destination is obtained.
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 19
20. Pyramidal parallel algorithms
A simple animation
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 20
21. Experiment
75 paths from 5 pictures (4 US, 1 Afg)
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 21
22. Results
Image Rate
1- Suburban area. Large and well defined roads 73%
2- Metropolis. Narrow and winding roads 67%
3- Residential area. Winding, tree avenues (with noise due to 73%
shadows)
4- Residential area. Narrower, but less winding roads 93%
5- Central area in Kabul. Only dirt roads, difficult to distinguish 60%
also at naked eye
Success criterion: path was the shortest and at least 95% on roads
In all cases, start and arrival points were defined on roads
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 22
23. Case studies
Naturalistic ortophotos
Rural paths
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 23
24. Case studies
Large and compressed orthophoto
Symbolic grey-scale image
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 24
25. Time performance
Standard PC platform
CPU: Intel Dual Core E6600 2.4 Ghz
Ram: 2 GB, 800 Mhz
8 MB cache
Operative System: Windows 7
Language: C++, single thread, single task program
Mode Time
With hashtable 1 ms 1.4x Memory
Without hashtable 3,6 ms
footprint increase
Real-Time behaviour
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 25
26. Subpath length & performance
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 26
27. Target applications
RealPath to be incorporated into game level editors of
RTS games
With RealPath a designer (even an end-user) can load
geographic pictures to build game maps
An RTS game player’s task of collecting resources
may become repetitive and boring as soon as he has
learnt the position of resources and the existing paths
in the map
Also strategies in the same battles fields may become trivial
for skilled users
RealPath can improve the game’s longevity by
supporting a simple and automatic generation of new
game maps
The mods concept
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 27
28. Target applications
Peace keeping mission scenarios
The player has to reach destinations for monitoring (they may
be placed automatically on the map) and move conveys
minimizing attack risks and damages
Decision strategy training combined with the possibility for a
player to contextualize his experience in the real target area.
Civil protection scenario
First, the whole road network for an area is computed through
several iterations of the RealPath algorithm
Then, some roads are blocked with a symbol, simulating the
damages of the destructive event
e.g., an earthquake
Also in this case, personnel can realistically train on strategies
in a real-world environment.
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 28
29. Conclusions
A new solution for automatic definition of paths on
aerial/satellite images
Costs reduced for creating new game maps, also supporting
UGC
High-performance parallel implementation
GPUs
Now porting on CUDA
The algorithm has been tested with several real-world images,
with good results
1st International Workshop on
Serious Games Development & Applications
Univ. of Derby, 8 Jul. 2010 29