Advertisement

[Programming Game AI by Example] Creating a detailed waypoint graph

Started by February 16, 2009 12:50 AM
3 comments, last by bibiteinfo 15 years, 9 months ago
I am currently reading the chapter on Practical Path Planning of the book "Programming Game AI by Example" by Mat Buckland. In this chapter,a map editor is used which automatically creates a finely grained waypoint graph for a user defined area. Mat uses the flood fill algorithm to create the waypoint graph. The code for the map editor is not included in the code samples for the book. I did a search on google on the algorithm but the results returned apply for colours, rather than nodes and edges. What are the general guidelines to create a graph of nodes and edges using floodfill? And also, is Mat (aka fup) still active in this forum? It looks like he has posted for some time. :s
Could you not just modify the code you found for a graph? Or better yet, look for a conceptual description and implement it yourself. Does the book not specify what conditions are required for a node to be constructed and what constraints must be satisfied in order for two nodes to be connected?
Advertisement
I'd suggest that u make urself a grid map of whatever size and consider a single gridlet as a unit u can merge into a node.



Floodfill is essentially floodfill. The basic ideas will be the same whether the algorithm is used for images or for something else. Note that there are two general methods, depth-first and breadth-first, and that in many situations breadth-first is to be preferred (among other things, it implicitly finds shortest paths).

Anyway, how could floodfill apply to your problem? I haven't read the book you refer to so I can't be sure what the author meant. But here's my guess:

Start at a point (x,y,z) in space somewhere in your level. Then see if you can move in a straight line from there to each of its "neighbors" [there are lots of sensible ways to define "neighbors." One might be to consider 6 neighbors, (x+dx, y, z), (x-dx, y, z), (x, y+dy, z), (x, y-dy, z), (x, y, z+dz), and (z, y, z-dz), where dx, dy, and dz are small numbers]. Then for each of these neighbors, see if you can move to each of their neighbors (only consider the ones you haven't already visited, of course) -- and so on.

This isn't necessarily the best way to do pathfinding (A navmesh approach is almost certainly better), but I'd bet this (or something like it) is what this guy is doing.
You can use Argorha Pathfinding which does this :

http://sourceforge.net/projects/argorha/

This topic is closed to new replies.

Advertisement