Sign in to follow this  
rego

best representation for RTS units

Recommended Posts

Hi guys, i'm investigating which STL container to use for storing/accessing/retrieving RTS units I'm guessing the use of a mutlimap or vector would be appropriate. However lists can me merged and so i thought that might come in handy for creating unit groups perhaps??? what do you guys think? cheers

Share this post


Link to post
Share on other sites

A vector seems a good start to store references to all units, since it should be common that you need to loop over them for updating etc. Storing groups could be done by keeping seperate vectors per group as well. All in all, I think the container choice should mostly be based on what's convenient for you. With all the other things eating away at your performance, the occasional list merge for example shouldn't be a big issue, provided you're not working with thousands and thousands of units.

I've been toying with some RTS ideas myself and I think where the container choice really matters would be for movement, specifically moving units as a group and moving units through other groups (so units getting out of the way of other units). Ideally your container should offer some index based on proximity between units, so keeping groups into formation and moving nearby units out of the way would be easier to do. Unfortunately I can't offer you any good suggestions on what container to use there, so further ideas would be appreciated.

Share this post


Link to post
Share on other sites
How many units do you have? How often do you add and remove units? Do you need to look up individual units based on some criteria?

If you want to remember groups of units, you can have separate structures to maintain those groups.

I think the choice of container here is completely arbitrary and it's just down to what makes your life easier. Decide how you want to access your data first, and the choice of container is usually made apparent.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this