Jump to content
  • Advertisement
Sign in to follow this  
crusadingknight

Top-Down Herd/Flocking AI ?

This topic is 4743 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

Recently, I was looking at making a single-player RPG, with some weird AI stuff (herding, influence, etc.) in it, and yesterday, I was considering herding. Anyway, what my idea is is this: Every n ticks, a herd AI is called. It considers the basic layout of the area (Which is composed of data it's members have reported since the last iteration, such as "Attacked", "Cut off", or "Position is" if nothing else happened. [This is used to determine the approximate position]) and sets a command struct up with a VERY basic command, such as "Move NNW", "Attack", or "Scatter", though nothing specific. Each time a NPC who has the herd flag set wants to do something, they look at the herd struct they belong to, read the command, and react to it. The rules for belonging to a herd are very simple, and are evaluated before movement: A: If two NPC's with the herding flag set are within 2m of each other, the one from the smaller herd will join the larger herd. If neither belongs to a herd, the first evaluated will create a new herd, which the other will join. If one has no herd, it will join the other's herd. For any case, every other NPC within the 2m will be evaluated before it tries to join or form a herd. B: If an NPC is 8m from it's herd, it cuts all relation to it, and evaluates A again. (Each NPC will always try to stay within 5m of it's herd, so this shouldn't pose a problem.) Now, is there any way I could make this more effective? Right now, I'm not particularly keen on eating through too much CPU. I suppose I could also use attraction between the entities, but that is slow ofr movement (though easier on CPU), and causes them to stay in approx. the same place, and move quite slowly, as opposed to a herd, where all members do approx. the same thing, and aren't afraid to move. Thanks in advance, I really appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
I'm curious as to why you want to do this "top-down" when the mechanisms for the behaviour as "bottom-up" are fairly well understood and documented? Do you have performance concerns or control concerns?

Share this post


Link to post
Share on other sites
I think that the cpu requirements will be quite modest for this sort of thing, especially if you use a spatial data structure to reduce the number of members you have to compare against others.

Share this post


Link to post
Share on other sites

As mentioned above, the major expense in terms of CPU for bottom-up is the influence checking and this can be dramatically reduced by using sensible data structures, or may well not be an issue at all if you have small herds.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!