Up to Main Index                              Up to Journal for July, 2023

                      JOURNAL FOR FRIDAY 21ST JULY, 2023
______________________________________________________________________________

SUBJECT: Revisiting the cottage, Mere edition take two
   DATE: Fri 21 Jul 20:12:07 BST 2023

This week I’ve been working on user functions for Mere. I’m not going to lie,
adding scoping has been tough. I finally had things kinda working by Thursday.

I really wanted to know if it was now possible to write a larger program using
Mere. Over the years I have written various versions of “The Cottage” in many
different programming languages. The ones on this site include:


                    [1] March   2018 • Go version
                    [2] May     2019 • PHP version
                    [3] May     2019 • JavaScript version
                    [4] October 2022 • Mere version


The cottage is a simple text adventure ‘toy’ for learning. The Mere version
was terrible. Hard to write, hard to maintain. Basically Mere was not ready
for extensive use and larger programs :( I wondered what would happen if I
tried writing a Mere version now, nine months later? It would definitely be
the biggest Mere program to date and an ideal test bed for the new functions…

After two evenings and a whole load of debugging and hacking on Mere itself:


    >mere examples/theCottage.mr

    Welcome to the cottage! (Mere edition)

    [ Path outside a cottage ]

    You are on a path leading north to a small, white cottage.

    You see exits: north south west
    ? exam path
    You examine a path.
    The path is made of small, neat paving stones.
    ? get path
    You can't take a path!
    ? inv
    You are carrying:
      a coin
    ? exam coin
    You examine a coin.
    The coin is small and silver.
    ? drop coin
    You drop a coin.
    ? w
    You go west.
    [ Front lawn ]

    You are standing on a small, neat lawn outside the cottage.

    You see a green frog here.
    You see a red frog here.

    You see exits: north east
    ? exam frog
    You examine a green frog.
    This is a small, green frog.
    ? get frog
    You get a green frog.
    ? w
    You cannot go west.
    ? e
    You go east.
    [ Path outside a cottage ]

    You are on a path leading north to a small, white cottage.

    You see a coin here.

    You see exits: north south west
    ? drop frog
    You drop a green frog.
    ? l
    [ Path outside a cottage ]

    You are on a path leading north to a small, white cottage.

    You see a green frog here.
    You see a coin here.

    You see exits: north south west
    ? q
    Bye bye!
    >


This time around it wasn’t such a terrible idea :) The code is… okay-ish? It’s
much better than the previous horrible disaster. Looking at the code I can see
plenty of room for language improvements — especially around the use of IFs
and GOTOs. The cottage does not run in Mere ICE as there is no mechanism to
get input from the player. The current live version of Mere ICE also does not
have user functions yet. However, I’ve included the source here for interested
parties to peruse. Comments and feedback welcome: diddymus@wolfmud.org


                             theCottage.mr ~11kb


You can click the link above to view in your browser, which might prompt you
to download, or right-click download. It’s probably easier to read the source
code if you download the file, load it into an editor and turn on either C or
BASIC syntax highlighting. Really need to work on a Vim syntax file for Mere.
I was quite encouraged when a work colleague, who does not know Mere, managed
to make sense of the code ;)

Once I have functions completed I’ll be working on getting Mere source code
and binary versions released. Then everybody can have a play.

Now I need to go and organise a mess of Mere code changes into some coherent
Git commits…

--
Diddymus

  [1] Welcome to the cottage: /journal/2018/3/17.html

  [2] The cottage revisited: /journal/2019/5/9.html

  [3] Returning to the cottage…: /journal/2019/5/13.html

  [4] The Cottage — Mere edition (terrible idea): /journal/2022/10/3.html


  Up to Main Index                              Up to Journal for July, 2023