Intergalactic Space Rescue in Tiny BASIC
Friday, 30th August 2019
As I predicted, I've got severely distracted now that the Tiny BASIC interpreter is working. I decided to see if I could port my old game Intergalactic Space Rescue to the language, and managed to do so in a couple of hours.
Intergalactic Space Rescue (henceforth "rescue") is a simple puzzle game set in space. It's in the same genre as Hurkle and Wumpus, where you are wandering around a game environment looking for a particular object, receiving clues about where it is. Like Hurkle, the map is a simple 10x10 grid. Like Mugwump, your clue is the distance between you and your objective. Like Wumpus, you move around one step at a time, and there are obstacles in your way.
The back story of Rescue is that you are a rescue pilot, involved in mission after mission of seeking out starships in distress in order to rescue their passengers. You have a limited amount of fuel. Obstacles are asteroids, which cost extra fuel to navigate around, and hyperspaces, which are wormholes that transport you to a random hyperspace elsewhere on the map. To balance these out are planets, at which you can refuel. The chance of encountering planets is constant throughout the levels, but the hazards increase in number as you progress.
I originally wrote this game in BASIC on a 2KB Sharp pocket computer in the 1980s. Two decades later I rewrote it for Psion pocket computers, adding the idea of multiple levels and a graphic interface. A few years afterwards, I implemented it on the 16K ZX Spectrum in assembly language. The original Sharp version was a text-based game, and I thought that Tiny BASIC might be an ideal target. The only difficulty was the lack of arrays in Tiny BASIC; all previous versions stored the generated map in a 10x10 array. But this is where procedural generation comes in.
On all versions of the game with multiple levels, the maps are procedurally generated from a set seed. This means that the levels need not be stored, and are generated at will. The same can hold true of the map locations themselves. As long as they are always generated in the same sequence, any map square can be queried by resetting the seed, and generating all the map squares in that sequence up to the one you want to examine.
Using this method I can simulate a randomly generated array, and thus implement Rescue in Tiny BASIC. A similar algorithm can be used to create any kind of large adventure world, as long as the state of each location remains constant.