[MUD-Dev] data structure design in a new mud

pauli.saksa pauli.saksa at ztango.com
Mon Mar 12 14:59:37 CET 2001


> From: "Justin Coleman" <JMCOLE at ENOREE.DJJ.STATE.SC.US>
 
> I'm working right now on coding a new mud from scratch, and I've hit
> a snag. What is a good way to store objects in a mud? Specifically
> in-game objects, like swords and such. Is it worth the (apparent)
> design time and effort of keeping one central list of all items, or
> is it all right to have smaller lists, one for each room and each
> player that has items?
 
> I seem to be doing fairly well with the player and room structures,
> but it seems to me that there's no "clean" way to have one list of
> all the items in a world without having ungodly numbers of pointers
> back and forth.

The question, how I see it, is whether to have one central list of
items in addition to smaller lists or not.  Those smaller lists have
to be there in some form or the other.

A central list allows some operations that smaller lists do not,
e.g. fast searching of items.  Also general administrating of items
would be trivial to implement with a central list. There are down
sides as well.  How the indexing would be done? I.e. How to make a
difference between two similar items. I'd hate to force my immortals
to 'add item #24562 to this mob'.

In my opinion the negative sides of a central list are greater than
the positive sides.  In our model there is no central list, therefore
there is no strict administration of items either.  Items may go
'unregistered' back and forth in the world and the only way to find
out what items are in a room is to walk into that room and look
around.  'Locate object' spells are not allowed either, but where's
the fun if players don't have to search the items.  Of course
sometimes there may be a need for locating particular items in the
world, but that's too time consuming to be done often.

The more interesting part of the topic is the connections between an
item type and an item instance.  If a blacksmith wants to create a
sword, where does the code find the correct attributes?  If a
blacksmith creates 20 similar swords, all the attributes don't have to
be stored separately in the memory for each sword.

In our model each item has two different sets of attributes: item type
data (=shared) and item instance data (=unique).  Shared data is
actually shared in the memory as well.  In addition to saving memory,
this is a major step towards easier balancing: if some type of a sword
is too good, all swords of that type can be downgraded in one place.

If there's no central list of item instances, should there at least be
a central list of item types?  Item types can be easily forced to have
unique names since those names don't have to be seen by players.  An
instance of 'sword done by human blacksmith' and an instance of 'sword
done by orc baker' may both be called 'a sword' without core dumps.
With a central list of item types, one could define several types of
items for a blacksmith to create.  Although, this could be done
without a central list as well..  so..  you choose :-)

I hope you find this helpful.

--
pauli.saksa at ztango.com
Enhanced Mud Implementing Team (EMIT)
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list