Advertisement

Enemy Finding On Mud Like Game

Started by October 14, 2003 07:42 PM
1 comment, last by Supaflyfrank 21 years, 4 months ago
How would I get a Mud game criminal find a mud game player. Say the player fought the criminal and then fleed and went in known directions. I would I get the criminal to go through all the rooms to end up by the game player. Each room is actually a number to an array index. So to find a player you could go like 4 9 10 14 28 29 each of the number is a number to an index to the room array and 4 is where you started off and 29 is where the game player is. Anyway how would i get the criminal to find those index numbers by it self. Dont know how I would find it because the different rooms number might very alot because the player can go North East South Or West so its not like i can just make the criminal go room index 3 4 5 6 7 to find the player it could be totally weird and actually be 3 8 10 14 17. So does anyone know how i can solve this probably i would be greatful if you can thanks in advance>
I''m just thinking of this off the top of my head so sorry if there are any blatent mistakes.

But i''d probably try a modified version of the a* path finding algorithm (the one that there was an article on just a little while ago). Your world is already split up into squares (the virtual rooms) so you don''t need to worry about that.

So you start at one position, you know where the pc is. So you device a path to the person like normal. But instead of always going in the right direction, introduce a chance to pick the wrong direction(perhaps based on the MOB''s tracking skill). Since you can only visit a square once this will make the MOB "find the trial again" leading to a longer path (if they have a poor tracking skill) or in the event they don''t make many mistakes a quicker/shorter path( for instance if they have a high tracking skill).

Hope that helps
Advertisement
Search is a reasonably obvious answer... but if there aren''t too many rooms then you could solve this problem using a flood fill technique, like the Distance Transform Algorithm. You can find the algorithm in the archives of this forum.

Basically, you start at the players location and label all rooms adjacent (directly connected) to hers with a cost of 1. Then all rooms adjacent to those, that are not already labeled, with a cost of 2. Keep going until you have labelled the criminals room. Then the criminal merely follows the numbers in decreasing order, always choosing any of the adjacent rooms to its own that have a lower number assigned to them.

Cheers,

Timkin

This topic is closed to new replies.

Advertisement