Up to Main Index Up to Journal for May, 2019 JOURNAL FOR THURSDAY 9TH MAY, 2019 ______________________________________________________________________________ SUBJECT: The cottage revisited DATE: Thu 9 May 19:49:07 BST 2019 I’m always programming, and hence write a lot of code — in many different languages. A lot of the software I write is simple, one-off creations. These little creations serve a number of purposes. I may have a specific one-off problem to solve. I may investigate how an algorithm works, or develop a new algorithm. Sometimes I want to verify how a specific feature of a programming language works. Sometimes I just want to play around with something for the fun of it. Case in point, I have a fully working subleq[1] assembler and runtime written in Go from May 2015… Most of these little critters never see the light of day. However, back in March 2018[2] one escaped into the wild. It was called ‘The Cottage’. The cottage was a very simple, single player, text ‘toy’. It couldn’t really be called a game. It was just a starting point for people to experiment with, something that was not as complex as WolfMUD. Children love it! :) Recently I received an email. Someone had managed to catch an elusive ‘The Cottage’. They found it interesting, but didn’t program using Go. “Could I write it in a different programming language?”, they asked. “Okay, what language did you have in mind?”, I asked. “How about PHP?” they replied. To which I then replied “Yuck!” :P Then I thought about it a bit and said, “What the hell! Okay, give me a few days…”. Now before everyone gets all excited and carried away, this is NOT a web based version of ‘The Cottage’. It is still as simple as the original, and like the original runs on the command line: >php -f cottage.php Welcome to the cottage! [Path outside a cottage] You are on a path leading north to a small, white cottage. You can see exits: north south west ?n [Front door] You at standing at the open front door of a small, white cottage. You can see exits: north south ?quit Bye bye! > However, it is all written in plain PHP — no extensions or frameworks — and like before all contained in a single file. Code is available for viewing here: cottage.php If you want to try it out for yourself, maybe play around with the code, just right click the link and save the file somewhere locally. Install PHP[3] if you do not have it installed already. Then open a terminal window and change to the directory where you saved the file. Then run: php -f cottage.php See the file itself for more details and the journal entry referenced[4]. It has been tested on Linux (Debian) using PHP v7.3.4 and v5.6.26. I even tested it on Windows 10 Pro using PHP v7.3.5. For those of you who are disappointed that this is not on the web and running in a web browser — I will be returning to the cottage again soon ;) -- Diddymus [1] subleq is a single instruction programming language, for a one instruction set computer - OISC as opposed to the more common CISC or RISC: https://esolangs.org/wiki/Subleq [2] Journal entry for ‘The Cottage’: ../../2018/3/17.html [3] Official PHP site: https://php.net [4] Who’s idea was it to not have reusable footnotes? :( See footnote 2. Up to Main Index Up to Journal for May, 2019