Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Rooms and links between rooms (http://www.topmudsites.com/forums/showthread.php?t=4540)

Alankor 09-09-2007 09:26 AM

Rooms and links between rooms
 
Good evening. Let me please introduce myself, I'm a man of wealth and taste... and a young spanish coder and ocasional MUD player, please forgive my english, it's not my mother language. Not much info there, actually.

Anyways, I'm not really going to code a mud, but still have a question: in MUD code, do rooms "know" what rooms they're linked to? I mean, there are explicit references inside the class? And if it's not so, how are links between rooms kept?

Actually this question only really makes sense if there are MUDs coded in Object Oriented languages, and I believe most are done in C for performance reasons?

I know this might be a little too basic, I searched the forum but didn't find anything helpful. If you people answer, I only need a high level view, I can think about the rest.

Muchas gracias

KaVir 09-09-2007 09:52 AM

Re: Rooms and links between rooms
 
The approach used by the majority of muds is for each room to store a list of exits, each of which contains the room number to which it links. Thus room 1 might have an exit for "north" leading to room 2, an exit for "south" leading to room 3, and so on.

Other muds use alternative approaches - for example, some don't use exits but instead assign each room a coordinate position, and moving to that coordinate position will then move you to the appropriate room.

Personally I'd recommend downloading a few codebases and taking a look how they work. Whether the mud is Object Oriented or not shouldn't make any difference in regards to the way rooms are linked.

Alankor 09-09-2007 12:14 PM

Re: Rooms and links between rooms
 
Oh, ok. So all rooms contain references to the rooms they're linked to. OK, I was thinking it would be good to have them decoupled, so no room knows what it is linked to, or even if it is linked, and another class keeps the linking map between the rooms.

I mean, if each room keeps a reference to the next, if we have a hallway with rooms 1-2-3-4-5, and want to change the order to 1-3-4-2-5 we would need to update all rooms. If the responsability of knowing the "map" is on another class maybe it would be easier and centralized. You could have one guy coding rooms, another one thinking about the areas and linking them. And maze building could be easier, maybe. What do you guys think? Has anyone tried something like this?

I thought about looking into codebases, but understanding it looked like too much trouble for a high-level answer on a basic topic.

Ide 09-09-2007 12:35 PM

Re: Rooms and links between rooms
 
I think of links as so intrinsic to the rooms themselves that I'm finding it hard to think of a benefit to separating the two. Another thing is that many builders (me included) write some or all of the exits into the room description. I always find it a little confusing, in terms of navigation and plain 'what is this room' coherence, when the exits aren't written in.

Not to say that there couldn't be special cases where it would be effective to separate rooms and their links.

chaosprime 09-09-2007 02:14 PM

Re: Rooms and links between rooms
 
That's interesting. I don't think separating rooms from exits (nodes from vertices) is going to benefit you for building purposes -- having one guy making the rooms in a maze and the other connecting the dots is not going to turn out well -- but I can think of considerable technical benefit.

See, with the usual room model, exits aren't necessarily constrained to be orthogonal (an orthogonal exit is one where, if there's an exit north from room A leading to room B, there is also an exit south leading from room B to room A), and if you want to attach any behavior to the linkage between the rooms, you have to do it on each side separately, because the linkage isn't modeled as a thing in itself.

So, in the usual model, if the exit from room A to room B above is one that could only be used if you can fly, that condition has to be defined separately for room A and room B. And if you want, say, doors modeled as full objects, you wind up with twin versions of the door on the two "sides" of the exit, which can be a pain. Some operations wind up such that you have to query room A for information about the exit and then room B for information about its reciprocal exit; again, a pain.

Modeling the linkage between the rooms as a thing in itself would allow all concerns like that to be managed in one place. If passing between room A and room B requires you to be able to fly, that's one setting in one place, which is just plain better design.

Alankor 09-09-2007 02:31 PM

Re: Rooms and links between rooms
 
Chaosprime, that's what I was thinking about. I was trying to code something like that for a different project, and thought maybe MUDs were doing something like this so I wanted to check out how they were doing it.

I find that keeping links between elements as full objects leads me to a lot of subclassing (I keep one base class for link, then subclass for special cases that require specific conditions, and there are quite a few), wich is not *that* bad by itself, but maybe it could be implemented in some other way that could save us all those classes. Any ideas?

PS: One nice thing it lets me do is keeping a "Theseus thread", so I can rollback all actions and go back through the same path, keeping all conditions (if I need to have a switch activated on room 2 in order to go from room 4 to 5, it asks for the same when going from room 5 to 4). But there are quite a few uses, maybe a labyrinth where links between rooms keep changing randomly on 10 minutes intervals or stuff like that.


All times are GMT -4. The time now is 01:00 AM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022