Up to Main Index                         Up to Journal for September, 2023

                  JOURNAL FOR SATURDAY 23RD SEPTEMBER, 2023
______________________________________________________________________________

SUBJECT: A quick update, plus plans for Mere and WolfMUD
   DATE: Sat 23 Sep 16:47:45 BST 2023

I have finally managed to purchase a Raspberry Pi Zero 2 W to add to the small
farm of machines I develop and test on. I’ve not had the time to actually do
anything with it yet, but I do have some Mere benchmarking and Go builds in
the works.

Recently I finished adding the label types to Mere. Then it was back on to the
strong typing work. Along the way I’ve found many small bugs in Mere code I
have written. This means the strong typing is a good thing and has been worth
doing. However, I do wonder if I’m not wrecking the language in the process :(

Another boon has been the error reporting changes. It’s much easier to have an
error pin-point a source line instead of staring at traces and dumps and going
“Eh?” all the time :)

For now I’m busy going through all of the example code and tests adding in
type information everywhere, fixing bugs and in some cases having to re-write
tests.

I think that once strong typing is done I need to work on the compile time and
runtime checking. Once that is out of the way it will be time for the ultimate
goal — integration with WolfMUD. Then work can continue on WolfMUD proper.

Integrating Mere with WolfMUD should let us do some nice things. For example,
this is the definition of the barkeep in the tavern:


        Ref: M6
       Name: a barkeep
    Aliases: BARKEEP MAN NPC
   Location: L4
       Body: @MOBILE
     Gender: MALE
     Health: @MOBILE
     Armour: @MOBILE
     Damage: @MOBILE
  Inventory: M6O1
    Holding: M6O1
       Veto: COMBAT→The barkeep just shakes his head and sighs.
     Action: @MOBILE
   OnAction: $ACT picks up a glass and wipes it with a rag.
           : $ACT smears the top of the bar with a rag.
           : $ACT starts to arrange a few of the curious bottles behind the bar.
           : $ACT drums his fingers on the bar.
           : $ACT starts to whistle a little ditty.
           : $ACT examines an old rag. He finds a hole in it.
           : SAY Can I get anyone something?
           : TALK ANY PLAYER Can I get you something?
           : SNEEZE
           : EXAMINE BAR
           : EXAMINE BOTTLES
           : EXAMINE BOTTLES
           : EXAMINE RAG
           : @ACT_GENERAL
      Reset: @MOBILE
    OnReset: The barkeep walks in.


Using Mere for scripting, we could add more dynamic actions:


           : SAY code{
               time := env["world"]["time"]
               if time < 12
                 return "Good morning!"
               elif time > 18 && time < 20
                 return "Good evening!"
               else
                 return "Good day!"
               fi
             }
           : SAY code{
               if len env["location"]["mobiles"] < 5
                 return "What a slow day."
               else
                 return "Nice to be busy!"
               fi
             }


I’ve not worked out the exact semantics yet, but the general idea is that Mere
will be passed environment data. The environment data would contain global
information, such as the time, and details of the current location and what is
in it. This information can then be queried and acted upon by the scripts. The
code{} blocks will then be replaced with output from Mere. Using the simple
examples from above could result in “SAY Good morning!”, “SAY Good evening!”
or “SAY Good day!” and “SAY What a slow day.” or “SAY Nice to be busy!”.

The plan is to allow for anything in zone files to be scripted. This should
enable unique and dynamic interaction for things like quests, stories and
in-game events.

All of the Mere code snippets will be compiled and cached when the zones are
loaded. This will help with performance. I also plan on making code blocks
work with @Refs so that the code blocks are reusable.

Mere has deliberately been written without any file, network or other low
level capabilities. Mere only works in a sandbox with data given to it. It’s
up to the programs embedding Mere to decide what data to make available in the
sandbox and what data to take back. This deliberate design choice is intended
to provide a safe environment for running code you may not fully understand or
completely trust — that is, it’s not going to take over your computer and do
nasty stuff…

I do get asked if WolfMUD itself will be re-written in Mere. No, it can’t be.
See my comments about Mere not having file or networking capabilities. Mere
programs are also single threaded and Mere does not itself support starting Go
routines. This is another deliberate design choice that keeps embedding Mere
simple and allows a server to have many little scripts running at once.

Isn’t it amazing that I actually thought through all of these little details
nearly a year ago when I started designing Mere and what I wanted from it? ;)

Depending on how well Mere performs, it may be possible to implement commands
and other functionality in Mere and externalize them from the main code. This
would provide an easy way for new commands and functionality to be added and
for existing commands and functionality to be customised. However, to do
anything like that is still quite a ways off…

So, those are my current plans and thoughts. I hope others are as excited by
the possibilities Mere will bring to WolfMUD as I am :)

--
Diddymus


  Up to Main Index                         Up to Journal for September, 2023