Up to Main Index                              Up to Journal for July, 2019

                     JOURNAL FOR THURSDAY 18TH JULY, 2019
______________________________________________________________________________

SUBJECT: Command parser musings
   DATE: Thu 18 Jul 18:55:22 BST 2019

I’ve just pushed out some updates out to the public dev branch: a set of tests
for the DROP command and a few additional tests for the GET command. Mostly
I’ve been rewriting the PUT command to use the new matcher. I was holding off
on the updates until the new PUT command was ready. However the PUT command is
taking longer than I expected to rewrite and has had me thinking a lot about
command processing after it raised a few issues…

When writing commands it’s important for players to be consistent. For the PUT
command the container you are putting items into can either be carried or at
the same location. A player can then put things into a cupboard on the wall as
easily as putting things into a bag in their inventory. Ordering becomes
important when multiple containers are viable. For example, if there are two
boxes — one box on the floor and another box that you are carrying:


  >PUT BALL BOX
  You put a ball into a box.
  >


Which box did it pick? The one you are carrying or the one on the floor? The
PUT command consistently picks the box you are carrying before the one on the
floor. This behaviour can be changed by specifying exactly which box you mean:


  >PUT BALL 2ND BOX
  You put a ball into a box.
  >


This would put the ball into the box on the floor and not the one you are
carrying — which would be the first box. I’m actually thinking of changing the
messages to give a better indication of which container is being used:


  >PUT BALL BOX
  You put a ball into a box you are carrying.
  >PUT BALL 2ND BOX
  You put a ball into a box.
  >


You could check which boxes are available using the which command:


  >WHICH ALL BOX
  You are carrying a box.
  You see a box here.
  >


This all works nicely, but only in isolation. For example, if you use the GET
command it only considers the items at the location and ignores what you are
carrying — you can only GET what you haven’t already got, so it makes sense:


  >GET BOX
  You get a box.
  >


Now the box on the floor is considered the first box and is now inconsistent
with the PUT command[1]. If the selection of items was the same as the PUT
command then you would always be trying to get items you already have before
items you have not — which makes no sense and would be cumbersome for players.

Until now I’ve tried to pick the ordering commands use based on what seems
sensible: GET picks from the location, DROP picks from your inventory, EXAMINE
picks from the location then your inventory as does the READ command. For
EXAMINE and READ you can’t limit to just your inventory otherwise you couldn’t
read or examine things you can’t GET — examine a tree or read a road sign[2].

I’ve been thinking of adding a MY special prefix to the matcher to refer
specifically to items you are carrying. For example:


  >PUT BALL MY BOX
  You put a ball into the box you are carrying.
  >PUT BALL BOX
  You put a ball into a box.
  >


For the “PUT BALL BOX” it would then be possible for the PUT command to look
for boxes at the current location and then in the player’s inventory. Where as
“PUT BALL MY BOX” would only consider what you are carrying. This does mean
you have to keep using MY for your own items which would be a pain :(

Note that if there is only one viable container, a box on the floor or a box
you are carrying for example, PUT will just use that with no messing about.

Another issue is that, for simplicity, the PUT command expects the player to
already be carrying the items they want to PUT into something. There is no
reason why the PUT command couldn’t automatically GET the item for the player
if it was at the location. Something to look at in the future…

I’m thinking it might be a good idea to have the matcher recognise IT, and
maybe HIM and HER, to refer to the last item/person interacted with:


  >EXAMINE MY BOX
  This is a small cardboard box, handy for putting things in.
  >PUT BALL IN IT
  You put a ball into the box you are carrying.
  >DROP IT
  You drop a cardboard box.
  >


I’m also thinking I might be over thinking the issues and that this might just
complicate things even more. It’s important that commands are simple, easy and
make sense for the players.

--
Diddymus

  [1] The WHICH command looks at a player inventory then the current location
      as well. Maybe there needs to be another command or switch to list
      location then inventory instead of inventory then location?

  [2] I guess there are ways and means to walk off with trees and road signs
      if you really wanted to - but that’s not the point I’m making here.


  Up to Main Index                              Up to Journal for July, 2019