Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to pathfind intelligently once target is out of sight


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Mythics   Members   -  Reputation: 135

Like
0Likes
Like

Posted 19 March 2012 - 02:51 PM

Working on a turn based, 2D tile based game. Going very heavy on tactics/strategy.

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

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 12337

Like
1Likes
Like

Posted 19 March 2012 - 03:40 PM

This paper explains how to use particle filters for this type of problems. It's about the only technique I can think of that would help in the situation you describe.

#3 IADaveMark   Moderators   -  Reputation: 2389

Like
2Likes
Like

Posted 19 March 2012 - 04:49 PM

Damián Isla has done some great work under the title of "occupancy maps". They are similar to an influence map but the influence radiates from the last-known position into adjacent areas that are unseen. As you move and reveal more areas, the values in those areas are 0'ed out and distributed to the other, unseen, areas. At any point, the bot can work with the assumption that the player is in the area with the highest rating. Obviously, as more things are revealed, that location can change. Also, the map continues to "bleed out" over time (under the assumption of continued movement) so that the highest rating can actually move down corridors and around corners. This makes sense and allows for the bot to "chase" the player through a series of logical twists and turns despite not seeing the player any more. When faced with two directions, the bot will check one and, when determining that it is clear, automatically assume the other one, etc.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
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!"

#4 Álvaro   Crossbones+   -  Reputation: 12337

Like
1Likes
Like

Posted 19 March 2012 - 06:09 PM

Yes, I should have mentioned occupancy maps too. Particle filters and occupancy maps are basically different representations of posterior probability as you allow for your estimate to move out and as you eliminate possibilities for where the target is. They are both forms of Bayesian reasoning.

#5 jefferytitan   Crossbones+   -  Reputation: 1913

Like
0Likes
Like

Posted 19 March 2012 - 06:40 PM

Ditto on the occupancy maps. Unknown terrain does make it harder. If one is chasing someone and comes to an unknown T junction, there are only a few options available, e.g.:

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*

#6 IADaveMark   Moderators   -  Reputation: 2389

Like
1Likes
Like

Posted 19 March 2012 - 07:12 PM

I don't think unknown terrain is as much a problem in occupancy maps as you might think. If you don't know what the hall around the corner looks like, you treat is as an open area. As you discover walls, etc., you just remap the probabilities onto the list of "walkable" areas.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
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!"

#7 Mythics   Members   -  Reputation: 135

Like
0Likes
Like

Posted 19 March 2012 - 07:51 PM

Wow, excellent. Thank you all very much, exactly what I was looking to find. In regards to unknown terrain, that's exactly how I've been handling it IADaveMark, thanks for the reply to jefferytitan so I can feel more confident in that approach.

Occupancy maps sounds like a slightly easier approach, but I'll definitely look into both.

Thanks again.

#8 jefferytitan   Crossbones+   -  Reputation: 1913

Like
0Likes
Like

Posted 19 March 2012 - 08:02 PM

Hmm, interesting upshot of that approach is that exploration would be encouraged because unexplored areas would register as low cost. I wonder what metric you'd use for a more balanced approach? Cost for unknown areas = weighted average of surrounding known costs?

#9 wodinoneeye   Members   -  Reputation: 700

Like
0Likes
Like

Posted 01 April 2012 - 04:56 PM

What you have to understand is that this goes beyond 'pathfinding' to higher level behavior control.

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.
--------------------------------------------Ratings are Opinion, not Fact

#10 jefferytitan   Crossbones+   -  Reputation: 1913

Like
0Likes
Like

Posted 01 April 2012 - 05:21 PM

Agreed about the higher level logic. You don't want your guard AI becoming a solo adventurer in the outside world, all in pursuit of a player which may be long gone.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS