1
\$\begingroup\$

I would like to know if anyone has recommendations or experience with using an in memory data store for a real time, non-networked game. This is not necessarily for loading levels or saving data, but to be accessed within the game loop as the game is running. Pretty much everything I look at w.r.t. data stores in games refers to networked games like MMOs.

As I am working on my game I find myself building a lot of ad hoc structures to hold various bits of game data and I was thinking it would make more sense to leverage work in this area that would provide a more consistent (and hopefully efficient) retrieval/storage method.

Does anyone have any experience or recommendations on in memory databases or key value stores or document stores that would be reasonable?

For my own purposes, my game is being written in Scala but the answers don't need to be Scala/Java specific.

EDIT

To be more specific I am primarily talking about entity data and lists of entities not necessarily things like 3D meshes.

\$\endgroup\$

4 Answers 4

1
\$\begingroup\$

I see two things that need to answered here:

First of all, the simple data structures that you build through normal code are way more efficient than any kind of database, you should as far as possible store your data using those.

If you have a real need to reference data by a string name you should use a search tree, I'm sure you can find a library that implements one.

\$\endgroup\$
3
  • \$\begingroup\$ I want to be able to do things like "Get all of the ogres in the forest without a weapon" and some place else "Get all buildings that haven't been damaged". I feel like there is a more consistent way to do this. I don't want to necessarily say a SQL interface but some more consistent means of querying game data that is at least reasonably performant. \$\endgroup\$
    – Michael
    Commented Jan 5, 2012 at 22:26
  • \$\begingroup\$ For that sort of stuff you keep lists, simple linked lists may be what you are looking for. So you could keep lists of all those ogres and if one of them gains a weapon remove it from the list, if an unarmed ogre enters the area add it to the list. But most of the time you probably don't want to keep too many lists, making a list for each type of entity for each area will probably be sufficient. If there is less than a thousand enemies in an area it is no big deal to go through the lot and find all unarmed ogres whenever you so desire. \$\endgroup\$ Commented Jan 5, 2012 at 23:02
  • 3
    \$\begingroup\$ @Michael those things you want to do sound exactly like the LINQ where clause. You can do similar things with lambda expressions inside of find statements in C++. You don't need a "data store" to do those kinds of queries on your data in an easy way, as long as you're using a relatively modern language. \$\endgroup\$
    – Tetrad
    Commented Jan 5, 2012 at 23:03
1
\$\begingroup\$

If you want what is essentially a database, then you might be best off using one. For example http://www.sqlite.org/ can be compiled in with your code, and can store it's data in RAM if you want.

\$\endgroup\$
0
\$\begingroup\$

The purpose of anything that you would actually call a "database" is primarily to make searching and finding specific information easy and fast. Unless you have some need to find entities via specialized queries based on many of their properties, you don't need a database. You just need a simple array or map or whatever.

A simple thing like "find entity by name" is something that your programming language's standard library can cover. In C++, the first go-to type for this would be std::map.

\$\endgroup\$
-3
\$\begingroup\$

RDM Embedded has a free evaluation download and the database has pure and hybrid in-memory capabilites. http://raima.com/products/rdme/

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .