Skip to main content
GameDev.net gamedev.net
🔒 Locked

squad implementation

Started by too_many_stars Jan 19, 2016 at 9:57 PM 5 replies 4k views
Original Post
too_many_stars
too_many_stars

Hello everyone,

Just wanted to run this by you guys to see if I am on the right track. I would like to build a squad, with one leader, and any number of grunts.

The steering, goals pathfinding is solved.

However, I am not sure how to implement a squad.

Do I give every grunt a pointer to the leader, and give every leader an array of pointers to each grunt.

Or do I use a messaging/telegram system

Or are there other options I have not considered.

If anyone has every implement a squad, please let me know.

Thanks,

Mike

ApochPiQ
ApochPiQ
I would try to avoid the circular reference pattern, personally, but that's mostly a matter of taste.

Here's how I'd go about it:
  • Appoint a Squad Leader
  • Squad Leaders have a list of Followers
  • Followers might also be Squad Leaders if you want a command hierarchy!
  • Squad Leaders issue orders to their followers directly, through their list of known squadmates
  • If you need it, you can use tricks like Blackboards to communicate internally with the squad
Without knowing more about your game design and such though, it's hard to be highly specific. What sorts of things do you want this squad to do? What are the design requirements for how squad members should behave? What kinds of challenges do you foresee (or have already encountered) that might need a special code approach to handle?
Hodgman
Hodgman

If you need it, you can use tricks like Blackboards to communicate internally with the squad

I was going to suggest this smile.png
You can give every squad member a pointer to a shared 'blackboard' of knowledge. The leader can write squad orders into it, and the rest of the squad can follow the orders written on the blackboard. Every squad member can also add information such as enemies that they've spotted, so all squad members can be aware of them.
too_many_stars
too_many_stars

Thanks for the reply guys,

Please keep in mind this is my first attempt at this sort of thing, so if my ideas sound crazy or unhinged, I apoligize.

What sorts of things do you want this squad to do?

I want to start with something simple. An enum perhaps with "orders" such as "FIND_COVER", "ADVANCE_FORWARD", and "RETREAT". I would like for this to be set through the squad leader through a function such as void setOrder(unsigned int order_type); which would then be relayed to the grunts, and they would act accordingly.

What are the design requirements for how squad members should behave?

These are simple. A pointer to a path manager class, A pointer to a steering behaviour class, and a pointer to a state machine/goal oriented architecture. The order given by the leader should route through say the grunts finite state machine class to turn on/off "arrive" or "flee" or whatever among other things.

What kinds of challenges do you foresee?

This is the tough one. Efficient communication between the squad leader and the grunts. I need the squad to act in unison. I may need tiered Ai where the squad has a state, along with every member. For example, a squad state might have to rotate 90 degrees, but each squad member is still in a state called "looking for cover."

I must say, I have never heard of this "blackboard" method (among many other things). Could you guys explain it to me or give me some useful links?

Thanks,

Mike

captain_crunch
captain_crunch

You should look up what Chris Jurney wrote about squad AI for Company of Heroes. There is very detailed information in AI Game Programming Wisdom 4.

too_many_stars
too_many_stars

Thanks for the links guys, I will check them out.

I have two AI books. Mat Buckland's Programming Ai by example and Artificial intelligence for games by Ian Millington. I know it's only scratching the surface but we all have to start somewhere.

Mike

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.