Game directory data structure

Started by
0 comments, last by VertPingouin 9 years, 4 months ago

Hello everyone,

I was trying to implement some sort of global directory for my game where all actors are registered with some tags.

For example, all objects I need to update over timùe are tagged UPDATABLE, ennemies are tagged too... so with a simple getbytag function, I can get an iterable list of these, or single.

Groups are pre constructed when objects are registered to improve speed as I'm in python and it works pretty well.

But now, I wan't to implement a positionning grid and add some functions like :

  • is_there_a(tag, direction distance) (returns True if there is an object with tag within a direction in a certain distance)
  • get_the_nearest(tag, direction, distance) (returns gameobject)

But I'm stuck with my first implementation, I had a dictionnary by object and a dictionnary by tag, but If I add a position criteria, it's naturally getting more like a relationnal database. Besides, I'll need to update positions maybe 2 or 3 times by seconds. Could be a performance bottleneck for sure...

My question is what data structure to use in this case.

Maybe sqlite living in memory but in this case I've no idea how to store an object refernce in it, and no idea whatsoever of the perfs...

Thanks in advance for your answers !

Advertisement

For what I've tried, sqlite in memory seems affordable.

For 50 objects I get the nearest object with a certain tag : results are thrown in less of 1/100 seconds.

So doing it 2 or 3 times by seconds won't be an issue.

This topic is closed to new replies.

Advertisement