Well, first off I want to note this is my first post.
But anyway, back to the topic. So I've been playing MUDs for years now. And I've allows seen the basic movement system. From one room to another, by selecting directions. Each room has a description and its pretty basic. Now don't get me wrong I enjoy that, reading the description and getting a feel for the room is nice.
But, I'm going for more of a realistic feel, using a map. That I've had a debate with a friend that in a way it is the same. Because coders can allow the player to view the room system like a map. But I'm aiming at the map system, that involves using x, y coordinates.
Now my question at hand, I've attempted to work with making a map-based system. That is sorts each area as zone or area. But I always seem to run into problems, with keeping track of information and the best way to implement it. I seen people use lists within lists. 2D arrays, and etc. But I just wanna hear what some people have to say about it.
What exactly is your question here – how to store the rooms in a data structure? Well, first of all, what language are you using? If you're writing in a language that supports maps, you can easily map from coordinate pair to room.
How are you going to deal with collisions? For example, going east then north doesn't bring you to the same place as north then east.
FYI, this is a very big topic and comes with all kinds of issues… :smile:
What I meant about collisions is dealing with the situation where two rooms that should occupy the same space. You can't really just set it to null because that would mean throwing away all rooms at that coordinate. I'm not sure what you meant about movement checks, either: you need to know that those rooms are there if you're trying to map a path through rooms, right?
Collisions are going to be one of your big headaches. Other headaches will be how to render this to clients, especially if you need to "stretch" the map to account for collisions.
You will also have issues if your exits are abnormal somehow, for example, one room with many rooms going into it from the same direction. Imagine a big room that you can get to by going "west" from 10 rooms – from each of those 10 rooms going "west" brings you to the same room. How's that going to work on your map?
Of course, one way to solve those collision/exit normality issues is to simply say that such scenarios are impossible. That brings up a whole new set of issues when it comes to world design.
How are you going to represent vertical coordinates? (Does your game even have up/down exits?) How are you going to handle rooms that shouldn't be the same size on the map? For example, you might have a big 'street' room but if you enter a house, it takes up 10 rooms of space while still being the same size as that single street room. (It's hard to draw this in text and I'm lazy right now, but hopefully you get the idea.)
Where are you in the process here? It seems to me that you haven't gotten too far in your design or coding because these issues are fairly immediately apparent. Just trying to figure out where you are in your thinking and implementation.
I've never been any good at design. Through I guess at my basic design. I have a map object that contains tile objects, which are the same as rooms. Each tile has a boolean variable that determines rather or not the adjacent tiles have access to it.
I didn't really have a plan for handling vertical coordinates, but if I had to do it. I would probably add a z axis to the map and just make so tiles can be stacked on top of each other.
And doing a check for any rooms under the tile could result in a fall for a character or if the boolean variable is set could allow for walking across it.
You could implement MSDP which in combination with reporting the ROOM variable will give you a client side map in combination with the TinTin++ automapping script. There are some snippets linked on the MSDP page which makes implementation a little easier. It should only be a matter of time until other automapping plugins become available for other clients as over 20 MUDs support MSDP.
(Well, when all you have is a hammer… MSDP makes sense for everything!)
Anyhow, Lundex, if your world is an actual tile map then things are a lot simpler. I was assuming that you had the more common rooms-with-exit-links model, rather than a grid of rooms. If you are working with a grid, then you can just use a 2d array as your data structure. This will be reasonably memory-efficient assuming that your map isn't too sparse. Performance-wise, a straight array lookup is pretty much as fast as you can get.
I think that for this conversation to make sense beyond the general pointers that have been given out (and there is a LOT of content in those linked threads) you'll need to be more specific about what you have, where you want to go, what the constraints are, what shape the world has, what kind of operations will be performed (path-finding? map-drawing? etc.), and so forth.