Up to Main Index                               Up to Journal for May, 2021

                      JOURNAL FOR SUNDAY 30TH MAY, 2021
______________________________________________________________________________

SUBJECT: Some you please, some you don't…
   DATE: Sun 30 May 16:22:52 BST 2021

The response to my last entry, about working on a WolfMini to explore ideas,
was interesting. First of all, people seemed to understand why I am working on
WolfMini at the moment. Even those who were dismayed at more delays understood
why. Largely the sentiment was "do what you need to do", even if they didn't
like it. I don't think I had anyone who flat out stated that what I was doing
was wrong or a bad idea.

Progress on WolfMini has been going well. Since it's proved so invaluable to
development on WolfMUD, I've added my tree debugging early in development this
time around:


  >#dump chest
  `- 0xc00005a230 *proc.Thing - UID: 6, CHEST
     |- Name - a chest
     |- Description - This is a large iron bound wooden chest.
     |- Is - 00000000000000000000000000010000 (Container)
     |- As - len: 1
     |  `- [11] Alias: CHEST
     `- In - len: 2, nil: false
        |- 0xc00005a140 *proc.Thing - UID: 3, BALL
        |  |- Name - a green ball
        |  |- Description - This is a small green ball.
        |  |- Is - 00000000000000000000000000000000 ()
        |  |- As - len: 1
        |  |  `- [11] Alias: BALL
        |  `- In - len: 0, nil: true
        `- 0xc00005a1e0 *proc.Thing - UID: 5, BAG
           |- Name - a bag
           |- Description - This is a simple cloth bag.
           |- Is - 00000000000000000000000000010000 (Container)
           |- As - len: 1
           |  `- [11] Alias: BAG
           `- In - len: 1, nil: false
              `- 0xc00005a190 *proc.Thing - UID: 4, APPLE
                 |- Name - an apple
                 |- Description - This is a red apple.
                 |- Is - 00000000000000000000000000000000 ()
                 |- As - len: 1
                 |  `- [11] Alias: APPLE
                 `- In - len: 0, nil: true


Since last time I wrote I've been cleaning up the code and making it 'nice' -
something I'd want to work with. I've added writing and doors, along with the
READ, OPEN and CLOSE commands. In fact I've just been implementing doors.

Doors are interesting items as they need to be in two locations at once - or
at least at the border between two locations and hence accessible form two
locations at once. Here is the tavern door from both sides in action:


  >e
  [Tavern entrance]
  You are in the entryway to the dragon's breath tavern. To the west you see
  an inviting fireplace and south an even more inviting bar. Eastward a door
  leads out into the street.

  You see exits: East South Southwest West
  >#dump door
  `- 0xc00013a2d0 *proc.Thing - UID: 9, DOOR
     |- Name - the tavern door
     |- Description - This is a sturdy wooden door with a simple latch.
     |- Is - 00000000000000000000000000000010 (Narrative)
     |- As - len: 3
     |  |- [11] Alias: DOOR
     |  |- [13] Blocks: E
     |  `- [10] Where: L3
     `- In - len: 0, nil: true

  >e
  You can't go East. the tavern door is blocking your way.
  >open door
  You open the tavern door.
  >e
  [Street between tavern and bakers]
  You are on a well kept cobbled street. Buildings loom up on either side of
  you. To the east the smells of a bakery taunt you. To the west the entrance
  to a tavern. A sign outside the tavern proclaims it to be the "Dragon's
  Breath". The street continues to the north and south.

  You see exits: East South West North
  >#dump door
  `- 0xc00013a2d0 *proc.Thing - UID: 9, DOOR
     |- Name - the tavern door
     |- Description - This is a sturdy wooden door with a simple latch.
     |- Is - 00000000000000000000000000100010 (Open|Narrative)
     |- As - len: 3
     |  |- [11] Alias: DOOR
     |  |- [13] Blocks: E
     |  `- [10] Where: L3
     `- In - len: 0, nil: true

  >exam door
  You examine the tavern door.
  This is a sturdy wooden door with a simple latch. It is open.
  >close door
  You close the tavern door.
  >exam door
  You examine the tavern door.
  This is a sturdy wooden door with a simple latch. It is closed.
  >w
  You can't go West. the tavern door is blocking your way.
  >


First you see the door from one side and then the other. As can be seen from
the address of the Thing and the unique identifier (UID) this is the same door
in both of the location inventories. What's happening here is that the door
knows where it's primary location is via As[Where]. In this case our location
(L3 - Tavern entrance) matches As[Where]. If we interact with the door while
at L3 and try going east we just check the direction the door is blocking via
As[Blocks] and whether it is open or not via Is&Open == Open. However, when we
are on the other side of the door (L5 - Street between tavern and bakers) and
want to go west we handle things a little differently. We know we are not in
the primary location as our location is now L5 and does not match As[Where].
When we check the direction we therefore need to check the reverse or opposite
direction being blocked, in this case west. We now have a working door, minus
the reset to automatically put the door back in its original open/closed
state. At the moment everything is single threaded without locking so adding a
reset goroutine for the door now would cause data races.

As this all looks very promising, I'm planning on adding tests and benchmarks
next. It's only five source files, about 675 lines of code and comments, but
there is a lot going on. Not adding tests during initial development was a big
problem in WolfMUD - I find it difficult to keep tests going when development
is moving fast :(

After tests and benchmarks I'm not sure what's next. The output could use with
being tidied up, coloured and wrapped. There are also the HOLD, WEAR, WIELD
and REMOVE commands missing. I can't add SAY, SHOUT, TELL and WHISPER unless I
go multiplayer. Do I want to take this multiplayer? Not sure yet. The parser
could also use some work - it's currently a simple "each item has one alias"
and no qualifiers implementation. As it stands items have a map[uint32]string
for properties. I'm not sure how to handle multiple values for a property. The
map is nice because I can use As[property], for example As[Alias], As[Where]
and As[Blocks]. Making As a map[uint32][]string would break that nice feature,
but maybe I can add some nice helper methods to compensate…

--
Diddymus


  Up to Main Index                               Up to Journal for May, 2021