Data Structure library/Tips when making one

A small introduction to my question before making it:

As it stands, in my 2 years of game programing (20 hours/week only tough, so you can say 1 year), ALL games start very well but in the middle or so in the development it gets veeery bad in regards to data structure, i recognize that where i work, we don’t do ANY planning at all(and that might be the cause of it). This worries me a lot and that is why (actualy only one of the reasons) i haven’t even started to make my own project.

End if introduction.

So i wanted to ask if there is some open source data structure library or something somewhere in the internet? If not, what kind of things i should watch for and care about when making my own for my game?

One of the pre-requisites of my game that i set, was that i make as much as possible of it using the same tools as anyone in the comunity will have access to when making mods for it. When i say ‘as much as possible’, i mean even the combat system, or even the fact that things drops loot when die, or even the comcept of items and death.

What i have in mind so far is:

Entities(like the player or a enemy, or a tree, or a house wall) have a type and a code associated with it’s type (for instance, a creature-type entity have the code 14, and no other creature may have the same code, but a structure-type entity (like a door or a lamp) may have the same code 14).

Then entities will have datasets(or something) that every mod will add. For instance, the combat system mode would add attributes, life, mana, stamina for a entity, this would be a dataset. And the Hunger mod would add a hunger for the entity, that would be another dataset.

The entity type would determine whose entities have which datasets by default, and which they might adquire or lose during gameplay (like vampirism or lycantropy, or both).

In short: How much of this is already implemented and free on the internet? What should i watch for? Should i use protobuffers for saving/loading? Xml for defining and extending entity types? Java reflection API for accessing dataset information? (as one mod might use another(like crafting and the concept of item), but they idealy should be made without access to the source for each other to ensure seamlessly compatibility or something)

This is an example how you can do it using the jme3 api solely and directly in the update loop:

I think the approach of doing it like this and using Nodes/Spatials as “entities” in the end (actually its just numbers here too) is the best for small scale games but also should scale well up to RPG’s etc.

When you talk about “entities” you sound like you mean an entity system (entity-component-system), afaik theres maybe some out there but as most of the code goes into the systems anyway you’ll probably go best by implementing it yourself. Just remember its unwise to be “object-oriented-programming-wise” when going entity systems :wink: For storing components a simple text file format like xml or best a database should be used I guess.

Thanks for the exemple, i shall give it a look later!

Yeah, i was afraid there would be no shortcuts on getting this done, i will probabaly have to implement it all by myself, altough luckly there are tons of XML readers avaliable to use and i might even use that google’s protobuffers thingy, but i don’t think there is much more avaliable besides that.

About the databases i was thinking on something like xml files, easy for the comunity to add new entries.

If you get serious about looking into entity systems then you can start here:

Entity Systems are the future of MMOG development – Part 1 –

Read it. Read the comments. Read it again, maybe. If by the end you are still not sure what the point is then the enlightenment hasn’t happened yet. :slight_smile:

There was also a bit of a back and forth about it here:

Using an Entity System with jMonkeyEngine (mythruna) –

I don’t know if it will be helpful, though. There are a few open source entity-component systems out there. I looked at some when I was trying to understand things but I didn’t like any of them ultimately and just rolled my own.

They have the one underlying feature that they greatly structure the entire game system. When you really take it in, there is very little “where do I put this?” anymore. In fact, these days, half of my design dead-ends are because I ignore the entity system principles and shoot myself in the foot trying to take a “short cut”.

Thanks pspeed, never heard of entity systems before, very useful read.


I’m using XML to store template information. But as for actual state, ie a player’s save game, probably just binary. I want people to be able to add new monsters etc, not to edit savegames. Well I dont particularly care if they edit savegames, I’m not going out of my way to make it possible. So I’m using a combination of groovy and XML.