Jump to content
  • Advertisement
Sign in to follow this  
too_many_stars

squad implementation

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

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

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!