Pathfinding and Databases

Started by
17 comments, last by Theis_Bane 8 years, 3 months ago

If the room is 3x3 and has 16 edges then just move toward the goal in a straight line. There's no need for any complication. Pathfinding is only necessary when there are obstructions.

Incidentally, four more edges would complete that graph quite nicely.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
Advertisement

I would, however, enjoy seeing how navimeshes and the like are stored in a database for MMORPG's, as that would probably mirror my setup the closest.



No serious (read: shipped) MMO would store navmesh data in a relational database format. What you will typically find is some kind of custom binary format that describes a compact data structure. Most of the time that data is just read directly into RAM, potentially with some fixups for pointer addresses, and used from there.

MMO servers typically have many GB of RAM available and sometimes even use a good chunk of it for caching and precomputation purposes. RAM is cheap and computers are fast. If you don't have profiling data to prove your performance assumptions, then those assumptions are worthless, period. It doesn't matter if you're new to game programming or have been doing it since the punch card era; I don't care what your intuition says, unless you've benchmarked the exact use case in question, you're probably wrong. There's a good chance you're dramatically wrong.

As has also been touched on, some data is not relational by nature and storing it in a relational DB is just unwise at best. It isn't really a performance or efficiency concern in my mind, though. It's an appropriateness of abstraction concern. The more you cram into your DB without reason, the more awkward things are going to get.

Trust your gut. Your gut says it would suck to store your navigation data in your database. So listen.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


MMO servers typically have many GB of RAM available and sometimes even use a good chunk of it for caching and precomputation purposes. RAM is cheap and computers are fast. If you don't have profiling data to prove your performance assumptions, then those assumptions are worthless, period. It doesn't matter if you're new to game programming or have been doing it since the punch card era; I don't care what your intuition says, unless you've benchmarked the exact use case in question, you're probably wrong. There's a good chance you're dramatically wrong.

To add to this, MMO servers are also typically highly partitioned. Even for huge AAA projects, they don't have the world on one box (well, they probably do, but it's on-disk), but a small piece of it. Working at a MMO developer, RAM has never been our bottleneck. Typically it's either the database or some abstraction on top of the database.

But that's all a moot point when talking about a MUD, which is orders of magnitude different.

I would, however, enjoy seeing how navimeshes and the like are stored in a database for MMORPG's, as that would probably mirror my setup the closest.

No serious (read: shipped) MMO would store navmesh data in a relational database format. What you will typically find is some kind of custom binary format that describes a compact data structure. Most of the time that data is just read directly into RAM, potentially with some fixups for pointer addresses, and used from there.MMO servers typically have many GB of RAM available and sometimes even use a good chunk of it for caching and precomputation purposes. RAM is cheap and computers are fast. If you don't have profiling data to prove your performance assumptions, then those assumptions are worthless, period. It doesn't matter if you're new to game programming or have been doing it since the punch card era; I don't care what your intuition says, unless you've benchmarked the exact use case in question, you're probably wrong. There's a good chance you're dramatically wrong.As has also been touched on, some data is not relational by nature and storing it in a relational DB is just unwise at best. It isn't really a performance or efficiency concern in my mind, though. It's an appropriateness of abstraction concern. The more you cram into your DB without reason, the more awkward things are going to get.Trust your gut. Your gut says it would suck to store your navigation data in your database. So listen.

EDIT - Reread after I've had some sleep, and now I feel silly. Leaving the below as a reminder to myself to stop and think. Thanks to everyone.

Alright, the tone of this response irked me, so I apologize in advance if I come across harsh.

I'm not discussing ram. I understand that part. The vast majority of my game runs in ram. The database is only used for persistence. What I'm asking about is persisting navigational data. I can only work with what I know, and what I know is databases. I literally can not speak to any other method of storage when it comes to this because I'm not fully aware how it would work. If you have another suggestion, great. I would love to hear about it and learn. That's why I'm here.

Not to mention the fact that I've already admitted to not really knowing the performance outcome, and believing im being overly conservative. I feel like, had you read my posts, you would have seen that.

I apologize if I'm reading too much into this, but I read it six times and am having a hard time seeing this any other way.

If the room is 3x3 and has 16 edges then just move toward the goal in a straight line. There's no need for any complication. Pathfinding is only necessary when there are obstructions.

Incidentally, four more edges would complete that graph quite nicely.

There will be the possibility for obstructions, so I will need to account for that. I am curious though, where are the other four edges coming from? I only count 16.


All this being said, I think I'm going to build a static navigraph class with nodes and edges preloaded, as all the rooms are generically shaped. This will allow me to plan a route with very little extra data needed to be stored. I will use my entities to shape the room how I see fit, like placing a 'hole' entity in a square and making it take up the whole square, so that the square appears blocked when i try to path. Thank you everyone for your time. You've helped more than you know!

I am curious though, where are the other four edges coming from? I only count 16.
Entries and exits of the room.

[attachment=32948:4a7700d571.png]

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

I am curious though, where are the other four edges coming from? I only count 16.

Entries and exits of the room.

Ah. I figured that may be what you meant. However, in my game, I would potentially need nine more edges on enclosed rooms, and.... A whole lot more on open terrain. I did that so you could have multiple doors on one wall, allowing players to enter and exit a room from multiple spots.

Mad props on that graphic though.

EDIT - Holy crap! I just found the other four edges INSIDE the room. Blind as a bat...Thanks!

The database is only used for persistence. What I'm asking about is persisting navigational data.


This is totally unclear from your posts, unfortunately.

There are two basic situations in which you would use persistent navigational data:

- Static geometry
- Dynamic geometry


In the former case, you will only need to load the data once and then never modify it or otherwise do anything with it besides searches. This is the optimal case for using a simple data structure that is serialized to disk at build time, and then loaded at runtime once and used indefinitely for navigation queries. That's the solution most games have because most games don't need much in the way of truly dynamic navigation.

For the record, you can fake dynamic navigation in a method similar to what you suggested yourself: store the "fully connected" world in memory, and simply score some edges of the navigation graph as impassable if the situation calls for it. An example would be a door that is only big enough for hobbits to crawl through. If an ogre makes a navigation search, he can use the exact same navigation data as the hobbit, but the ogre's score for the door will be impassable/blocked whereas the hobbit will perceive an edge that he can traverse.


Truly dynamic navigation is another beast and based on the logical assumptions most people would make from the thread, it isn't something you actually need. You haven't described any design goals that specifically require it. However, the typical solution is to store a hierarchical navigation data structure: one structure per "room" or "area" or whatever, and another high-level structure that describes how those smaller elements interconnect. When the navigation structure of the world changes, you simply rebuild the data structure for the affected regions. The hierarchical approach helps limit the knock-on effects of localized changes.


Note that both approaches involve custom data structures (graphs or navmeshes usually) and no relational DBs at all. Persistence does not inherently imply storage in a relational DB, that's all I was trying to say :-)



I can only work with what I know, and what I know is databases. I literally can not speak to any other method of storage when it comes to this because I'm not fully aware how it would work. If you have another suggestion, great. I would love to hear about it and learn. That's why I'm here.


I've described better solutions as has almost every other post in the thread. I responded because you were still talking about relational DBs even after all the suggested superior alternatives were available for you to analyze on your own. Also because I work on an MMORPG and I wanted to correct a misconception that we use relational data for navigation.

Nobody's asking you to speak to anything you don't know. We're giving you options to learn about and broaden your skill sets. If you don't know the tools for the job, learn them! There's nothing wrong with that and no reason to feel slighted by being told that you're missing a useful piece of knowledge.


Not to mention the fact that I've already admitted to not really knowing the performance outcome, and believing im being overly conservative. I feel like, had you read my posts, you would have seen that.


As I explicitly said, I don't even think performance is the real problem with relational DBs for this situation. I think the misuse of the tool is far more important on a conceptual level than a speed level. I remarked on performance merely for cohesion with the rest of the discussion but my real point was here:

It isn't really a performance or efficiency concern in my mind, though. It's an appropriateness of abstraction concern. The more you cram into your DB without reason, the more awkward things are going to get.

Trust your gut. Your gut says it would suck to store your navigation data in your database. So listen.



Anyways, I'm sorry if that all came off as a bit harsh or insensitive. I think we were simply operating under different sets of assumptions about what the subject of the thread is and where things stand with regards to finding a solution.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

No, no. It's not problem. I was a bit tired last night when I wrote that. Woke up this morning and reread what I and you wrote and was sort of like....eh? Didn't want to just delete it as I wasn't sure if it had been read.

As for the above, that makes sense. Didn't realize I wasn't clear about loading my database into memory for calculation purposes. Sorry about that.

I think I've probably got this figured out now. Again, thank you for your time. Apologies again for MY tone. Back to the grind!

This topic is closed to new replies.

Advertisement