Phantasmal MUD Lib for DGD

Phantasmal Site > DGD > Skotos > Introduction to SAM: Skotos Active Markup

The Problem of Dynamic Text

The Problem

SkotOS is largely concerned with presenting text to users. In a dynamic, interactive system such as ours, environments and occurances are forever changing, yet they must be described in consistent ways, even artistic ways, to the inhabitants of the virtual world:

   You are kneeling next to Fred in a dingy hut.  Jane stands near the door.
A
   long, black sword lies at her feet. The rain pours down outside.

This is a description which is clearly associated with the hut in which we are kneeling, yet refers to current occupants, items on the floor, and the weather outside: the description mingles static text with dynamic data. The system's ability to do this well is absolutely vital to making the user's experience in the world a good one.

A Solution

Since the program that serves the user with the description is the same one in which the dynamic data resides, there is a simple solution to the quandry above. Let the descriptive text contain special codes that instruct the world server to calculate and embed dynamic descriptions. This could be part of the description of a statue you find in a room:

   "The statue appears to be $(this.expression) at you."

This statue is alive, it turns out, and can either frown at you or smile, depending on whether or not you've kept up your sacrifices to the local dark lord. Thus when a user looks at the statue, the server knows to query the expression property of the statue. The definition of this property in the statue includes some logic that investigates the user staring at it, and sends back either 'frowning' or 'smiling'.

This is the core of SAM: the developer writes static descriptions that contain active markup. The markup is evaluated by the server at each time the user actually observes the description. The perceived description is populated with current data.

SAM Everywhere

Once we came up with this idea of marked-up text, a whole world of possibilities opened up before us. We look further than description; since web pages are essentially text, why not use this same system to generate web pages on the fly, populated with up-to-date world data:

   Welcome to Sir John's village status page!

   Johnsville currently has 612 inhabitants. The weather is cold
   and sunny. Thirty-one cows graze the fields. Alewife Christina
   made her latest batch of ale approximately nine hours ago.

The SAM in this case would underlie HTML rather than straight text, but to the server there is no difference.

More Power

The more we play with SAM, the more its potential power became apparant to us, and the more we added to it. Early on we decided to add conditional functionality:

   This is a long black sword with intricate carvings.
   <if val="$(greaterthan lhs='$looker.skill:weapon-lore' rhs='5')">
      <true>
         . You recognize the make as Alvatian.
      </true>
      <false>
         It is nighttime.
      </false>
   </if>

where the user will only be told of the sword's make if he has studied his weapon lore.

We also add iteration, e.g.

   Welcome to Sir John's cow status page! Here's who's grazing
   the fields today:
   <for var="cow" val="$(Cows)">
      $(Cow.CapitalizedName) is grazing in $(Cow.Pasture) and is
      feeling $(Cow.Contendedness).
   </for>

where $(Cows) is an array of, yes, cows, and the SAM within the for loop is executed once for each element of this array. The result is a list of cows, their whereabouts, and how happy they are at the moment.

We've introduced new syntax here; readers may recognize it as similar to HTML. It is in fact XML, a close relative, and it is the syntactic model we have chosen to express SAM.

Shortcuts for SAM

As we used more and more SAM, the extra "text" in the shortcuts required for XML often made reading descriptions more difficult. To address this, we created SAM Shortcuts. These are alternative ways to use SAM but with shorter tags, making it descriptions easier to read.

For example, in the Black Sword example above, the following SAM shortcut works exactly the same way:

   This is a long black sword with intricate carvings.
   {? greaterthen | $looker.skill:weapon-lore | 5 |
      . You recognize the make as Alvatian.|
      .}

Technically this is not XML markup, but internally SkotOS converts this to XML.

Existing Approaches

(We need someone to write up how LPMuds and other MUDs have tried to do this in the past)

Problems Solved by Skotos SAM System

(TBW)

State of Development

The SAM System is relatively mature and complete. Much of the fundamental power of it was proven in Castle Marrach, and now is being used more fully in various Skotos-Seven games, and is now also used for dynamic web pages and for our web client.

Open Issues in the SAM System

There are very few major issues with SAM itself, due to its maturity and several years of development. However, there are some related systems that have weaknesses that affect SAM:

  • Right now brief/glance/look/examine descriptions (and their all/dark/dim/bright/superbright variants) are not actually socials, so they do not get as many arguments as do the social tags. Useful information that is lacking includes which verb was used, the distance the actor is from the detail being viewed, etc. As soon as these commands are converted to Merry, all of these useful arguments will be available to these descriptions as well.
  • There are quite a few commands that are not converted to Merry yet, so can't be used with signal descriptions written in SAM.
  • The combinables system may have impact on SAM tags, as not all 'objects' will be single objects anymore.