Maya Grab [Day 19] – Interpreter

Last two days I was working on the first part of the interpreter which filled again almost all remaining bytes. The game is now playable from start to the end; if you type the correct commands, the wrong ones are not handled yet. That leads us to the point how it’s all working.

To have a smart command interpreter I’m immediately thinking, ok, first I’m going to analyze the words for the grammar, then I’ll combine the verbs with objects that are available at this point of the game and check their relations to the room the player is in or other objects in the game… etc. Nice, I’ll do it maybe next time in a object oriented language. Organizing and handling so much data is really painful in BASIC, and going through all lists of possibilities will be also very slow. I’m pretty sure it’s doable, but for this project it isn’t really necessary.

So I’m using the most straight forward dumb system on earth – pure string comparison. When the player enters a command, the first thing to check is, is it a special command. Special commands are inventory, statistics and an option to restart the game; these are not available in the original game. If it isn’t a special command, the interpreter compares the command with all possibilities which are available for the room the player is in. If still there is no match, the parser will try to check the command and give an appropriate response to the player (“unknown command”, “this can’t be done now”… etc). The code that I’ve did for the rooms looks like hell with bunch of IF THEN commands and setting various bit flags for every room.

Next time (after freeing again some space) I hope, I’ll implement the missing special commands and finish the interpreter by adding the parser.

Program size: 38532 bytes, on disk 36576 bytes or 144 blocks
Free BASIC memory: 379 bytes
Used BASIC commands: OR, AND

Source code BASIC
Source code ASM

* * * * *