Archived

This topic is now archived and is closed to further replies.

Enemy Finding On Mud Like Game

This topic is 5390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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>

Share on other sites
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

Share on other sites
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

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631724
• Total Posts
3001903
×