Forestry in the home

by Graham Relf

c. 1985

Comments in square brackets added in hindsight, 2012

It is now three years since I developed "The Forest" as a simulation of orienteering on the [Sinclair] ZX Spectrum home computer. With the recent availability of the much-requested version for the BBC microcomputer, this may be a suitable time to discuss some aspects of its design.

Firstly, why simulate orienteering? Why replace the open-air delights of pine-scented woodlands by a cartoon substitute on the living-room table? I felt there were three main reasons: the terribly worthy ones of providing a navigational training aid for existing orienteers and possibly of advertising orienteering to an audience who would otherwise play space-invaders in their living rooms [the Spectrum had to be plugged into the domestic TV for its display], but also the more personal challenge of combatting the many restrictions of such a small computer as the Spectrum, to try to make it do something interesting.

The navigational training aspect was emphasised by deliberately making the simulated terrain artificial in certain respects. By omitting paths, streams and other linear features, the hoped-for users of the program would be forced to read the contours on the map and use aiming-off techniques. [In reality linear features are much harder to create mathematically.] A further educational aspect was introduced by making it possible to display maps of any part of the terrain on the screen, at various scales and orientations, together with three-dimensional views which had the contours drawn on them. The relationships between the maps and scenes on the ground could be explored with the aid of the program.

The problems of achieving all this within the limitations of one of the cheapest home computers were varied. On one hand, how could enough information be stored in the machine to describe a sufficiently large area of ground for orienteering? On each of the two maps supplied with the program, about 1500 point features are shown. Each of these features requires at least four numbers to describe it: two coordinates, a feature type indicator (whether it is a depression, boulder, etc) and an indication of whether the feature has a control flag associated with it. If there is a flag, then a control code is needed (two letters). Given that fifty percent of the features in The Forest have control flags, the features on the two mapped areas alone require some 13,500 items of information (in fact this would occupy at least 18,000 bytes). When we consider that the description of contours and the shapes of vegetation boundaries also need to be stored, it can be seen that the (less than) 48,000 bytes of available memory in the Spectrum could rapidly be consumed by these descriptive data, with no room left for any program! Remember also that each map we have been considering is in fact only a two-kilometre square portion of the terrain which the program actually portrays. Each complete forest extends for just over 65km eastwards or northwards.

Has anyone gone far enough to discover what happens after 65km? The ground then just repeats itself and the orienteer does not fall off the edge of the simulated world. Each forest is effectively on a toroidal (ring-shaped) planet. You can see this by imagining the square map of the complete forest, 65km by 65km. Wrap the northern edge over, behind the map, until it joins up with the southern edge. This makes a tube. Bend the eastern edge of this round until it joins up with the western edge, to make a ring. Where on earth can you find orienteering like this?

However, let is return to the main question: how could a humble microcomputer store a thousand times (about 652 / 22) the amount of data we estimated for each map? It doesn't, of course. Instead, I devised a method of generating numerically the characteristics of any point on the ground from its coordinates, In other words, given a distance eastwards (x) and a distance northwards (y) from a fixed starting point, the machine determines the height of the ground, the type of terrain at that point (one of six kinds, ranging from mature trees to towns and lakes), whether that point has an orienteering feature (one of twelve kinds), whether the feature, if present, has a control flag and if so, the code on that flag. Using this mathematical approach, by generating the forest rather than storing it beforehand, means that actual forests cannot be portrayed by the program: you cannot use it to learn every route through your favourite wood and become champion when the British Championships are held there! I think this is a virtue rather than a restriction, firstly because our scarce orienteering terrain should be preserved for real orienteering and secondly because it offers a sense of escapism: even the author of the program can explore the world within the machine without knowing exactly what he will come across.

Another major problem in designing The Forest was that of representation: how could the very limited graphical display from the machine portray all aspects of the scene at any point in a manner which could both be understood easily and also be responded to adequately through the awkward medium of a keyboard? The second of these needs was the easier to satisfy, once I had decided to keep the number of responses to a bare minimum and for each to consist only of a single key stroke.The keys to be pressed were chosen to be easy to remember. For example, pressing B displays the compass Bearing, P Punches the control card, a right arrow turns the orienteer to the right (and the scene correspondingly pans leftwards on the screen).

The representation of the scene was less easy, however. It was decided to represent each type of terrain by a pictorial symbol typical of it. For example, a tall tree represents mature runnable woodland. The main constraint on the design is time: such a symbol requires up to 560 bytes (numbers) to be moved within the machine and this is done by executing some 6,000 program instructions, in loops of machine code (not BASIC). Fortunately the Spectrum is able to run such a sequence of instructions in about one hundredth of a second [the Z80A microprocessor had a clock frequency of 4MHz - compare with PCs in 2012 running almost 1,000 times faster]. But one tree does not make a scene. For the orienteer to have a realistic rate of forward motion through the terrain we also need to display at least two or three scenes per second. For each of these scenes there are other computations to be done too, not just graphical display. Hence the need for careful compromise in the design, and the decision to use only ten terrain symbols in each scene. Height is indicated by the vertical position of the base of each symbol relative to a flashing spot in the middle of the screen. The shape of the ground ahead is thereby indicated and the orienteer (so I have been assured) can relate this to the contours on the map and really practise navigation without "handrails".

Finally, I would like to return to the fact that it has taken three years for the BBC version of the program to follow the Spectrum one. This is despite the fact that Chris Barrington-Brown (BAOC) essentially finished the conversion more than two years ago. The problem has largely been the reluctance of publishers to handle a product which has both educational and game elements, particularly for the BBC machine which is most widespread in schools. The fear is loss of sales through illicit copying, which is always a problem for computer software but is viewed as being worse in schools. It is ironic that illegal copying in schools is deterring publishers from marketing material with a substantial educational content. Only mindless quick-selling large-volume games are being produced because those are the products that sell. People have consequently lost interest in machines which they increasingly perceive as toys. Perhaps another justification for The Forest was to try to alter that perception.

[And then the rise of the IBM PC in business changed perceptions anyway. It may be worth noting that one defence The Forest had against copiers was its reliance on a printed map.]

Comments in square brackets added in hindsight, 2012

More recently (2014) I have been experimenting with a version of The Forest that runs in any browser and is written in JavaScript (HTML 5, using graphics canvas). It is unfinished but runs well, so please try it. I would be interested in feedback (gr at grelf dot net) and I may develop it further.

Back to main O-maps page