• Advertisement
Sign in to follow this  

Reducing convergence of monsters

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

For my last minute 4e4 entry, I'm making a simple arcade game where you have to collect items while avoiding the enemies (I don't expect to win, it's just for fun). The problem I'm having is with the ninjas. Ninjas move by lerping either vertically or horizontally between their position and the position the player was when the ninja began the move (like a rook in chess, but real-time). The effect is really neat with only 1 ninja, but with more ninjas they eventually start to "converge": overlapping and moving as a single ninja, making it a lot easier for the player to avoid them. I fixed this problem with zombies (who just chase you slowly) by making them lose interest and move around randomly if the player is too far away. This wouldn't be practical for the ninjas because of their unique movement and because they're supposed to be significantly harder enemies. I've managed to slow the process of convergence by slightly changing the speed of each ninja and randomly assigning their starting direction (horizontal or vertical, rotating after every move) but the monsters still converge eventually. Anybody have a simple suggestion to help slow/stop the process?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Make the ninjas randomly choose a location the player could be at by the time the ninja gets there, and have the ninja move towards that spot. Or maybe the ninjas act differently if they are near other ninjas, and each nearby ninja selects a different location near the player to go towards.

Share this post


Link to post
Share on other sites
OK, the problem is pretty much fixed at this point (the only way the ninjas could converge now is if the player stands still, and in a normal game they'd be dead by at time).

First, I assigned a priority to each ninja. If a ninja is too close to another with higher priority, then their speed is reduced temporarily, which is easier to implement then keeping them a fixed distance apart. Second, instead of heading directly towards the player, they head to a random point within 10 units of the player. Third, the direction they move in is random (rand() % 2, 1 == horizontal, 0 == vertical) , rather then rotating each time. Together the 3 methods keep the ninjas fairly spaced, yet without reducing their difficulty/effectiveness.

Thanks for the help guys!

Share this post


Link to post
Share on other sites
I would keep them from overlapping by doing simple collision detection every time the AI is about to move, and seeing if that intersects with another ninja. I would probably do this with some sort of "minimum distance" system and checking all four cardinal directions in turn to see if it's possible to move in that direction without tripping over another ninja's toes.

As soon as you find an "open" direction, take it. The next ninja will do the same thing and eventually the group should move in a larger mass (but not overlapping) towards the player. Some may file out backwards but in general it should look pretty nice.

With different speeds/distances from the player, etc then the blob should be differently spaced and harder for the player to take out in a few shots. You could also control their speed based on their distance from the player (closer distances = faster speed)

If none of those directions appear open, then just sit and wait for that cycle.

Share this post


Link to post
Share on other sites
Quote:
Original post by jikbar
First, I assigned a priority to each ninja. If a ninja is too close to another with higher priority, then their speed is reduced temporarily, which is easier to implement then keeping them a fixed distance apart.


Rather than assign a hard priority to each ninja, you can say that the ninja closest to the player has right of way (higher priority). Resolve ties randomly. That would make them slightly more effective (and polite! polite ninja are important!), since a bunch of low priority ninja wouldn't have to wait for a high-priority ninja to overtake them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement