Another simple program. Like many that I wrote for the ZX81, Sugar Cube Munch was small with a singular purpose. In this case, the goal is to eat all the cubes of sugar as quickly as possible. Once all the sugar is eaten, the game is over and the number of turns is revealed. You can give it a try by using the ZX81 arrow keys 5,6,7, and 8 to move around.
Besides the difficulty of typing in programs on a rather small membrane keyboard, the machine was prone to crashes. If you bumped the RAM module or even the power cord, you'd lose any of the progress you made. Given that saving a program could literally take minutes, saving often wasn’t much of an option. Instead, I tended to keep the programs small and manageable. Typically, programs were something I could code from memory in a few hours. That isn’t to say that all my programs were short, as evidence by my Water Bug games, just that many were meant to be finished in an evening.
Sugar Cube Munch is like a lot of my earlier programs, something written to practice programming. It uses simple graphics, in this case a screen of blocks and an asterisk, with simple mechanics. I often came up with an idea and built on it as the program developed. For example the goal, to clear the screen quickly, was developed later as evidence by the odd line numbers. Each move is validated with a screen check and a score counter is updated. I brute forced the screen complete by simply checking that the counter reached the number of blocks that can be removed. At the end, I print the number of turns taken, a simple count of each time the input is checked.
That's it. Another month, another program. Maybe for next month I can find the time to enter in one of my longer programs. Until then, how fast can you eat all the sugar cubes!