Sign in to follow this  

Game directory data structure

This topic is 1110 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,

 

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 !

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

This topic is 1110 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.

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