[MUD-Dev] Persistent Worlds

J C Lawrence claw at kanga.nu
Thu Feb 15 20:26:09 CET 2001


On Thu, 15 Feb 2001 12:22:14 -0800 
Ryan Rhodes <ryanshaerhodes at hotmail.com> wrote:

> I'm writing this in responce to a thread of posts from back in Q2
> 1998 reguarding object persistence and the mapping of runtime
> morphic objects to an RDBMS or OODBMS.  

One of the nice things about the list archives is that you can reply
to old messages directly from the archive, along with full quoting
etc.

> Please excuse my attempt to sort through some Kanga.Nu vocabulary.

Every population tends to evolve its own shorthand and nomenclature.
MUD-Dev is hardly alone in that regard.  

> What is Persistence?

> As far as the post have talked the concept of persistence seems to
> fall under two catagories.

>   1) World Persistence

>   2) Persistent Store Technologies & Object to DBMS mapping

> World Persistence being, as far as I can understand it, a world
> which persists in state through reboots.  To accomplish this I am
> assuming you are somehow running the world directly from disk,
> which is my first question.

Persistance can be better defined in two regards:

  Can players cause permanent effects on the game world?

  Does the game tend to "magically" reset world states back to some
  definition of "normal"?

These are functional definitions; they define how the system
behaves, not how it accomplishes that behaviour.

> Question: In the runtime environment of your worlds do you have
> both a copy of the world in memory and a copy of the world on
> disk?  

Both models are widely used, along with a number of points between
encluding such things as checkpointed states, snapshots, transaction
logs and replayes, and so forth.

> Or do all games actions directly manipulate the DB?  

Some run entirely in memory.  Some entirely off disk.  Some of a mix
of both.  Some using various other abstractions.  You are esentially
asking the equivalent if the only way of storing sequential regular
data is in an array.  Certainly that is a common form, but vectors,
linked lists, trees, DBMs and a host of other data structures and
storage formats are commonly used as well.

> If you run strait from disk, what memory caching techniques do you
> use to improve performance?  Did you implement these yourself are
> have you used off the shelf software?

I use a custom object cache using a slightly tuned LRU (I factor in
time and use rate).  Others vary.  Moebius IIRC relies on the SQL
daemon to its cacheing for it.

>   Question: Is it even neccesary to run the game strait from disk
>  to effectively have a persistent world?  Can you run the game from
> memory and just back the whole changing world up to storage for
> reboots?  

Certainly.  It depends on what functionality and what level of fault
resiliance and (potentially) what distribution models you sich to
support.

> Does this make maintaining persistence somehow more difficult?

That would depend almost entirely on you the models and design and
operational specifications you elect.

> Beyond the question of how your doing it, more importantly is why?
> I mean this most seriously as I'm trying to weigh the advantages.
> I understand your projects are less geared towards PK and more
> towards realistic simulations.  The benefits I can come up with so
> far are:

Fundamental to this question is the definition of the service you
wish to offer/support, and if that service is a game, is GoP, is
more in the manner of an environment where players may elect to
create games within your context, or any of a wide variety of other
possibilities.  

Real care needs to be taken with these early definitions, as in the
end they are what drive and unite the rest of your design.  

In my case while I enjoy GoP games, I have little interest in
creating them as I feel that my ability to define and manage
interesting GoP platforms is far below that of an even mediocre
player base, and certainly the rate at which I can create and
support such new game definitions is vanishingly small in comparison
to theirs.  Instead I prefer to think about environments, about
frameworks, and about structures and resource sets that don't in and
of themselves define GoP structures, but which present attractive
tool sets with which to build GoP structures, and in particularly,
to build multiple simultaneous GoP structures which may be mutually
competitive or compleatly orthogonal to each other.

> While pondering this, it occured to me that the developers role
> might become something different in this context.  For the world
> to remain persistant it would now seem not enough to just store
> the original version of a room or object in the DB.  You are now
> storing the element in all of its various states.

... in any possible state.  Yes.

>   Question: If you are storing the original version of a room in
> the DB and it becomes burnt down, are you now storing the burnt
> version and completely throwing away the original?  Or did you
> store both versions from the begining?

There are multiple unstated questions underneath this, encluding:

  Is there a concept of original state for an object?

  Is the concept of original state significant in regard to an
  object?

  Doe the relative state of an object, and its history of state
  changes, have a particular logical significance in regard to the
  states of other objects and their state change histories, and if
  so, how is that significance realised and relied upon, and by
  what?

  Does the history of state changes of an object have any especial
  value either in-game, or to the server's logical model?

  Do you support versioning of object states, and therefore
  potentially support rollback of object states?

  Do you support rollback and thus replay of object state
  transitions, or in fact of sections of the entire data store?

For what I'm doing I don't generally consider the question of
original state significant.  There are two specific limits to this:

  Certain objects have a concept of one or more states to which they
  will attempt to return (eg grass will attempt to grow back into
  meadow), or to which they will attempt to return other objects
  (the guard closes cell doors as he finds them open).

  Objects which are specific instantiations of ur-objects "know"
  this fact, and will decay back towards ur-ness if opportune.

> In general this principle would seem to persist with the world,
> that you are no longer just adding creatures or items.  You are
> now required to provide for the way these things are generated and
> repopulate.  

Yes.  You are responsible for building a resource economy, and for
defining and instantiating at least the minimal mechanics of how
that economy operates.

> For instance moving from a fixed list of creatures in a rooms
> birth state to an algorythm that generates creatures for a
> room... In the case of creatures.  

No, you have creatures which then follow their own economic cycle
based upon whatever resources you wish (or model of those resources
as approximations are often cheaper than following the state
calcuations in real-time).  If that means that they happen to appear
in some room at a particular time, they do, if not, they don't.  The
room itself, unless a factor in the economic mechanics of the
logical structure is largely (typically) irrelevant.

For an example look into the whole Orc Orc
breeder/fighter/noble/king scenarios.

>   Question: Do you see putting together a more PK action oriented
> game with a persistent world as opposed ideas?  

No.

cf UO.

> What elements of a pk action world might in fact be less workable
> in a persistent world setup?

Repetitive player actions will tend to become less valuable.

> In your posts on mapping to DBMS you both talked about the
> impossibilites of mapping a runtime morphic language to an RDBMs.

Yes.  OODBMS systems to not map well to RDBMS systems, especially if
the object heirarchy is runtime morphic.

> The major barriers being dynamic attributes and inheritance, and
> in general a lack of object reflectivity.  Our system allows
> online compiling / cloning of objects.  We don't use any script
> languages, but implement all components directly in java, by
> extending one of the classes provided in our framework.  So, the
> code of our game is runtime extendable through dynamic class
> loading, but reguardless of weather the classes were compiled and
> loaded pre-boot or within the game at run-time, they are still
> java classes and fully reflective.  We do not use dynamic
> inheritence or dynamic attributes.

What is your intended handling of a base class being edited?

> This would seem to indicate to me that we will be able to provide
> a fixed mapping between the objects and an RDBMs.  

This depends upon the extent to which subsequent objects deviate
from your initial object models.  If your basic structures and
inheritance trees remain the same without much extention of new
class types being defined, then yes.

> I believe J C said mapping wasn't difficult for systems with
> static structures.  Ours, while it changes at runtime, still seems
> this kind of static structure.

>   Question: Will this system map to an RDBMs?

You haven't said enough about it to tell.  

> Now in discussing this, I noticed you both commented on how no
> persistent storage technologies to date supported runtime morphic
> code.  To my understanding, and please please correct me if I'm
> wrong here, these persistent storage technologies actually require
> you to generate the class from the table.. ie the class must be
> designed in the RDBMS.  

Yes.  This is also true of OODBMS systems, which require the schema
for the object heirarchy to be defined first and to then remain
immutable.

> Once the system has generated a class from this, you can use it in
> your code and it will automatically map it back to the RDBMS for
> storage.  Now if this is true, it would seem its not just runtime
> morphic systems that won't map, but all systems which are adding
> classes at runtime.  

Yup.

If all your users are doing is redefining already defined structures
you have no problem.  If they are defining new object types with new
structures and new object heirarchies, or are redefining extant base
classes, you are in trouble.

>   Question: How would you suggest mapping collections to an RDBMS.
> Normally every field would map to a column in the corresponding
> classes table.  An object field would end up mapping to a forein
> key reference to another table where that object would be stored.
> Collections like java Vectors, Hashtables, and arrays seem to pose
> a problem.  I don't think I would want each object in the
> collection to map to a foreign key in the previous item in the
> lists table.

My solution to this has been to make the object structure from the
RDBMS vantage, opaque.  I reveal only key features of the object
definitions: inheritance trees, ObjectIDs, etc, which are used to
classify objects and object access patterns.  I then leave the rest
of the internal object representation opaque, pickling it it in and
out of runtime/storage formats.

> Example: Inventory is a linked list.  I would like for player to
> have a forein key under inventory for looking up an inventory
> table for that player.  However the algorythms described thus far
> would leave the inventory field in player as a reference to the
> table for the first item of his inventory, not the whole list.
> That item would contain a foreign key to the next, and so on.  Is
> there no elegant solution to this, or am I just going to have to
> write a custom mapping for a bunch of different types of classes
> thats different from my general mapping algorythm.

It would seem so.  I cheated on this by exposing the
contained-in/contained-by values at the storage format level.  This
of course removes my storage layer from being a pure abstraction as
its now bound to a particular model of containment etc, but I saw no
elegant way about this.

ObNote: It might be worth investigating ZODB in this regard to see
how it handles runtime morphism.

> Question: Do you do your building from within the DB.  

Never.  The DB dopes not understand enough about object
instantiations, let alone class definitions to be useful.

> Do you have online building in systems where the game is stored in
> a DB?  

Yes.

> Are there any systems that use a DB for storage and have provided
> a graphical environment for Building that hooks directly into the
> DB?  

cf TkMOO-Lite.

> Are there any systems with a GUI that allow you to build while
> also being online? (with the Builder GUI interacting with the
> game) and in General ...

cf TkMOO-Lite and several MCP functions (such as the recently
mentioned TinyFugue scripts supporting external editing).

>   Question: Is it easier to edit pfiles and area files from within
> a DB or a text file?

This would depend entirely on the types of operations you wish to
perfoprm on those data, and how that operation may be realised on
that representation of your data set.

I realise I didn't really answer many of your questions.  Its not
that I'm trying to be balky or confusing, but simply that you are
asking absolutist questions when the only real answer to the area is
the uncomforting one of, "it depends."  There are few hard and fast
rules in this space, just as there are few hard and fast rules in OS
design (its worth noting that OS design and MUD server design have a
*LOT* in common).

--
J C Lawrence                                       claw at kanga.nu
---------(*)                          http://www.kanga.nu/~claw/
--=| A man is as sane as he is dangerous to his environment |=--
_______________________________________________
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