Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 09-09-2007, 09:26 AM   #1
Alankor
New Member
 
Join Date: Sep 2007
Posts: 3
Alankor is on a distinguished road
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
Alankor is offline   Reply With Quote
Old 09-09-2007, 09:52 AM   #2
KaVir
Legend
 
KaVir's Avatar
 
Join Date: Apr 2002
Name: Richard
Home MUD: God Wars II
Posts: 2,052
KaVir will become famous soon enoughKaVir will become famous soon enough
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.
KaVir is offline   Reply With Quote
Old 09-09-2007, 12:14 PM   #3
Alankor
New Member
 
Join Date: Sep 2007
Posts: 3
Alankor is on a distinguished road
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.
Alankor is offline   Reply With Quote
Old 09-09-2007, 12:35 PM   #4
Ide
Senior Member
 
Join Date: Feb 2006
Location: Seattle
Posts: 361
Ide will become famous soon enoughIde will become famous soon enough
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.
Ide is offline   Reply With Quote
Old 09-09-2007, 02:14 PM   #5
chaosprime
Member
 
Join Date: Jul 2007
Home MUD: Lost Souls
Posts: 199
chaosprime will become famous soon enough
Thumbs up 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.
chaosprime is offline   Reply With Quote
Old 09-09-2007, 02:31 PM   #6
Alankor
New Member
 
Join Date: Sep 2007
Posts: 3
Alankor is on a distinguished road
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.
Alankor is offline   Reply With Quote
Reply


Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 05:37 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022