WRITING A SIMULATION
When writing a large and complex program, the first question always is where to start? The answer is, start with a pad of paper and DON’T turn on the computer.
Writing a computer simulation of some real or imaginary system is not especially difficult. The much bigger job is gathering the data and learning as much as possible about the system so you can define the relationships among its various facets. Once you understand the whole system, you must then break it down into the smallest possible pieces, analyze each piece in depth, determine how to model it, and combine the pieces back into the whole.
In developing the algorithms and writing the programs for each piece, you must determine the most accurate and efficient way to proceed. Is it an exact process that can be represented by a mathematical formula? Is the process continuous or discontinuous? Is it ever interrupted abruptly? Are there random elements involved?
An enormous amount of time must be spent testing each piece. Does the simulation behave in a sensible way? What happens at various extremes? These same questions must be asked again and again as all of the pieces are combined into the whole system.
Like most real-world systems, most of the simulations in this book are a combination of well-defined processes and random elements. For example, Amelia Earhart’s airplane flies and consumes fuel according to well-defined physical principles. On the other hand, in Southeast Asia in July, she has a 30% chance of running into a torrential rainstorm. If it occurs, the problems she faces will be quite different from those on a sunny day.
There are five distinct parts to each of the simulations: an introduction to the game, historical background, program notes, program variables, and the progam listings. I encourage you to read The Story (historical background) before taking each computerized journey. By doing so, you will have a much better understanding of the original journey and you will make better decisions as you go along.
Later, if you want to see why the program works the way it does, examine how a routine operates, or even modify the program, the program notes and the list of variables will serve as your guide. You may also find in these programs many interesting and useful routines that you can use in programs of your own.
The ten simulations in this book are rather diverse. Some require many decisions on the part of the player, and some require relatively few decisions. In some, they are easy to make, but random hazards make it difficult to finish the journey. In others, the decisions are more difficult, but the journey itself is easier.
The programs are arranged in chronological order ranging from Marco Polo (1271) to Voyage to Neptune (2100). I suggest you play them in the order in which they appear. Following is a brief preview of what to expect in each simulation. Other aspects of the programs are summarized in the following table: