Tiny BASIC

Interpreter and Compiler Project

Hunt the Hurkle

Dating from the early 1970s, Hunt the Hurkle is a simplistic search game based on a grid. Because it's so simple to program, the game inspired lots of variations. One of those is another Tiny BASIC sample game (Mugwump), but there were also 3D variants with themes like submarine hunting, and variants with obstacles like Intergalactic Space Rescue.

The basic idea is that there's a creature, the Hurkle, hiding somewhere in the game world which is a 10x10 grid. On each turn, you are asked for coordinates. If those coordinates aren't where the Hurkle is, then the game tells you in what compass direction you should look. In this game, (0,0) is at the top left.

After entering a random number (which should be between about 0 and 4000), the game starts asking you to guess where you think the Hurkle is. You can enter the coordinates on one line, e.g. 5,5 (followed by return). You have a limited number of turns to find the hurkle. The best strategy is to start at the middle of the grid, so that if your first guess is not correct then your search area is narrowed down to a quarter of the grid.

This program shows a method for generating random numbers in Tiny BASIC. The language lacks a random number generator of its own, so numbers are calculated using a formula. Because we need to do this twice, the formula forms a subroutine. To prevent the numbers from being the same each time the program is run, the player is asked to enter a number at random at the start of the game; this is called the seed.

Filename: hurkle.bas.

Next: Mugwump