Portal-based pathfinding
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
You could also store instructions for passage in a link. More than just whether to jump, whether to climb, you can store higher level information. Suppose you have a door that is locked, the portal will keep a list of instructions for passing it:
retrieve red key
come back
unlock door
step back
pull door open
pass
The character could then query it's logic system for 'retrieve red key', and hopefully the character will have logic for that and be able to determine how far they would have to travel to get the red key and come back, and add that to the cost of the edge. You can store more specific information like which animations to use, where the keyhole and door handles are in order to help drive your animations, etc. If the agent doesnt know enough, for instance, hasnt found the red key yet, you could assign a really high cost.
You can have edges to things other than actual portals as well. You could, for instance, have an edge that goes to a motorcycle, that would have information on how to mount and drive it, how fast it will increase your speed between other waypoints, etc. that will help the AI decide whether it is best to take the straightest route across the map by foot, or run back and get the motorcycle.
You would probably want to make it hierarchical. Besides the main edges between portals, you can have a number of waypoints inside of each cell to help navigate through it. You can use the same A* algorithm when you are in the cell to find your way around in it, and you only figure the lower level paths for the cell that the character is in, and use the higher level portal-portal paths for traversing through other cells.
You can have a bounding sphere or bounding box associated with these waypoints that determine their areas of influence; to get from point A to point B within a cell, find the closest waypoint to point A, and the closest waypoint to point B and use your A* or other algorithm to find the best path between those points based on some kind of cell map or weights that are generated offline and modified by dynamic objects to affect the cost of moving between each point.
Peace
[edited by - krippy2k on February 24, 2004 5:13:59 PM]
I guess it makes much more sense to work with volumes than with points/edges when looking at things like ''can I collect ammo while on my way to the target'' and so on. If there''s an ammo entity within a given cell (i.e. the collision detection system gives it to us), the pathfinder can take that into account - I initially thought that was a modification to the heuristic function, but now I''m not so sure. How do you influence a path to go ''via'' a particular cell?
It could also be extended for map learning, I think. An agent could keep a database of visited cells, with a small set of values with strategic information for each cell - health available, ammo available, "strategic worth" (if that can be assessed), danger level / number of enemies, etc. As cells are visited, that information gets updated.
With regards to going ''via'' a cell, perhaps it''s a question of creating the full path and then finding the simplest possible alteration to include the via node? Take a soldier, he could work something like this:
1) Prioritize goals. Let the primary goal be rendezvous with his squad at a given location; secondary/tertiary/etc goals include things like collecting health/ammo. The more damaged/low on ammo he is, the closer the respective goals get to becoming the primary goal. Say that when health drops below 25% then ''collect health'' becomes the primary goal, etc.
2) A target node is selected for the primary goal. This would be the rendezvous point; it could be the nearest cell with health packs/ammo in, or possibly the one with the best contents:distance ratio. (better to go a little further for more stuff than a little shorter for much less).
3) A path is built to the target node.
4) For each secondary goal, the path is ''grown'' - an A* search is conducted from each node in the path (I think this can be done through putting all nodes in the path on the open list). The limiting cost (i.e. the value at which it stops searching outwards) depends on the priority; if health is 75%, the search will not extend as far as if health were 50%. And so on.
5) Build a new path: from start node to ''via'' node, and then from ''via'' node to target node. (If there''s more than one ''via'' node I guess we''d need to build all possible paths, with the via nodes in all possible orders, and then pick the shortest path).
It seems a bit costly, especially finding the ''via'' nodes (and the final step of rebuilding the path), and there are probably many opportunities for optimization. I think it could probably be justified on a background thread - the soldier pauses for a moment to figure out where he''s going to go.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Timkin
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
It is talked about briefly in AI Game Programming Wisdom 2, but they don''t say what games it was used in, the author was just described as somebody who develops tactical AI for games, and who works at CGF-AI. Incidentally, on the CGF-AI homepage you can see an example of how to modify A* to handle cover and concealment, so that instead of finding the shortest path through a room it will find the shortest path that provides adequate cover against a hostile in the room. www.cgf-ai.com
I have been using it in a game that I am working on (Reciprocity) for a while. It was one of the first pathfinding solutions I came up with, and it stuck.
Peace