How to pathfind intelligently once target is out of sight
I have field of vision working quite well for players and enemies alike, but I'm struggling with how to have enemies chase a player once the player has left the enemy's sight. Tiles are unknown to characters (enemies/players) until they have been seen at least once, and when not in direct view it is unknown what is actually at that tile even if the terrain is remembered.
The game is mostly within a tunnel like cave system, so an enemy chasing a player could encounter things like the path splitting two ways or even encountering dead ends. The field of view is also a 90 degree cone in front of the character and turns are taken using action points, so a single character could take multiple steps per turn (easily leaving another character's current line of sight).
I'm sure there's some form of pathfinding that could use things like last known position, previous movements observed, etc to 'chase' a target, but I haven't had a lot of luck with Mr. Google today in finding anything relevant to my exact kind of situation.
Any help on this would be appreciated.
Thanks,
Mythics
PS: If there's anything else I could add to assist someone in assisting me, please just ask. Ty
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
1. Go where you expect the opponent has maximum utility. For example, if your opponent is trying to escape the caves, the path which heads up is more likely.
2. Go where you can see the most. If one tunnel is twisty and the other goes to a big cave, you can rule out a lot of options of where your opponent is by going to the big cave.
3. Go where you can corner your opponent. e.g. if you've mapped most of the area you have an upper limit on how much unknown territory is connected to each branch.
4. Follow past precedent, e.g. the opponent turns left more often.
Also in general when predicting opponent behaviour don't forget the time factor. If your opponent has a tight deadline such as escaping before bombs go off, assume they will take the suicidal shortcut or direct path that may be a dead-end rather than any other option which is tantamount to giving up.
You can also investigate D*, which is often used when discussing a robot pathfinding in unknown terrain (although it doesn't revolve around chasing):
http://en.wikipedia.org/wiki/D*
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
Occupancy maps sounds like a slightly easier approach, but I'll definitely look into both.
Thanks again.
You would have a 'last known location' and if you could see sufficient terrain (discovered) a path to get to at least that point.
A higher level behavior of 'discovery' has to be carried out if you want to persue that now unseen target.
You can move towards that 'last known location' but as you move closer and previously hidden terrain may be filled in (or the target even comes back into view) you need to do some checking along the way to react logically (you might even uncover terrain that allows a shorter path to that 'last known location')
So there is more than a little logic/states needed to control this discovery/search process.
Once you get to taht 'last known location' and you STILL cannot see your target then another search process will take over considering where the target went:
You can assume it didnt go back the way you came (you would have detected it, and acted accordingly)
If there is only one way the target could have gone then the decision is simple ( tracing all routes and discarding deadends type processing).
If there are several directions then you have to have some exploration strategies to try to first discover the terrain and then the possible paths of the target (with the possibility of seeing the target again while you do all this)
Do you do some stepped breadth first seach down the available paths or a depth first (that may be taking you further and further away from the correct path)
Depending on the extent of your maps there could be an explosion of potential paths/directions the target went, so
at some point you may want to have the 'behavior' give up and assume the target is lost (have limits for the search strategies)
Remember pathfinding is just a tool and there is always higher level logic that will control how that tool is employed (prefereably efficiently and appropriately) Your game mechanics (like that unvisited/hidden terrain) and map data will likewise effect how the pathfinding is to be employed.