Sign in to follow this  
xee

2D game, pursuit code Q's

Recommended Posts

I'm currently working on a rogueish/nethack text game, I'm somewhat stuck on how to implement the pursuit code (how a monster chases down your character). I somewhat took a stab at it and currently have the monster take your X,Y, and by using a series of subtractions/additions relative to it's own position, did manage to have it head towards your general direction quite consistently. But say it runs into a wall that's in it's way, should I code it somehow so that it knows it's looking at a wall and have it try to figure out how to walk around the wall to get to you? Or should I just make it cheat a little, and just record your keystrokes from the moment you start fleeing and just have the monster follow your footsteps exactly [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] ? Thanks for any info!

Share this post


Link to post
Share on other sites
[quote name='xee' timestamp='1340921718' post='4953774']
I'm currently working on a rogueish/nethack text game, I'm somewhat stuck on how to implement the pursuit code (how a monster chases down your character). I somewhat took a stab at it and currently have the monster take your X,Y, and by using a series of subtractions/additions relative to it's own position, did manage to have it head towards your general direction quite consistently. But say it runs into a wall that's in it's way, should I code it somehow so that it knows it's looking at a wall and have it try to figure out how to walk around the wall to get to you? Or should I just make it cheat a little, and just record your keystrokes from the moment you start fleeing and just have the monster follow your footsteps exactly [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] ? Thanks for any info!
[/quote]

There are a couple ways this can be handled, depends on how you want to model your AI. If you want "perfect" AI, then you can use pathfinding (with A* or A-star being the common one).

If you want imperfect AI (or more realistic), you can try simulating tracking by scent and/or sound. There is an article here about this: [url="http://roguebasin.roguelikedevelopment.org/index.php/Tracking_by_Scent_and_Sound"]http://roguebasin.roguelikedevelopment.org/index.php/Tracking_by_Scent_and_Sound[/url]

While I'm link roguebasin, here is another that might be relavent: [url="http://roguebasin.roguelikedevelopment.org/index.php/The_Incredible_Power_of_Dijkstra_Maps"]http://roguebasin.roguelikedevelopment.org/index.php/The_Incredible_Power_of_Dijkstra_Maps[/url]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this