[plt-scheme] How to use Eval for a MUD

From: Jakub Piotr Cłapa (jpc-ml at zenburn.net)
Date: Wed Jan 27 11:53:16 EST 2010

This is IMHO a very interesting topic and I always wanted to play with 
it myself. Here are some ideas I researched:

1.

This is just a thought but I think you want to ignore much of the PLT 
Scheme namespace infrastructure. IMHO you should be wrapping all 
wizard-written code in a lambda which gets the current world state as an 
argument. You will probably want to make your own dynamic object system 
(maybe prototype-based). Then you can write modules with 
functions/macros that get imported to the sandbox namespace and are used 
by user code. Packing it as a PLT language and using #lang mud on top of 
every room/object file would be a good idea.

My point is that you probably don't want to make much use of Scheme 
object/code-organization/module infrastructure since it may be not 
dynamic enought for you. OTOH you want to evaluate the code once and get 
nice closures JITed for efficiency.

2.

For MUDs STM seems to be the best way to handle concurrency [1]. So your 
action/method closure would need to get a wrapped world state as an 
argument and make all modifications on local copies which would be 
folded back into the global world in the end. Opening an STM transaction 
for the duration of one player command seems to be a good idea. (almost 
all player commands must be atomic)

For an STM implementation you may try the approach outlined by Alan Kay 
recent work on JavaScript Worlds [2].

[1]: http://citeseer.ist.psu.edu/old/112011.html
      (see also DGDMP which AFAIK is based on a similar idea)
[2]: http://www.vpri.org/pdf/rn2008001_worlds.pdf

-- 
regards,
Jakub Piotr Cłapa


Posted on the users mailing list.