INTRODUCTION

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:

The Game The Date The Mode of Transportation The Duration
Marco Polo 1271 Camel, foot 3 years
Westward Ho! 1847 Wagon, oxen 6 months
The Longest Automobile Race 1908 Automobile 6 months
The Orient Express 1923 Train 4 days
Amelia Earhart 1937 Airplane 1 month
Tour de France present Bicycle 3 weeks
Appalachian Trail present Foot 5 months
Subway Scavenger present Subway train 8 hours
Hong Kong Hustle 1997 Mixed (bus, tram, ferry, train, subway) 1 day
Voyage to Neptune 2100 Spaceship 6 years

SUMMARY OF THE ADVENTURE SIMULATIONS

Following the ten simulations is a section on machine requirements and converting the programs to other versions of BASIC. Be warned that converting programs as long as these is a major undertaking.

I hope you have fun trekking through this volume. Good luck on your computerized journeys!

COMPANION DISK TO BASIC COMPUTER ADVENTURES

To save you hours of typing in the programs—and the additional hours of finding those inevitable typos—David Ahl has created a special program disk for BASIC Computer Adventures. The disk contains all 10 programs included in the book, plus loading instructions for the IBM PC, PCjr, and PC-compatible computers.

This disk is only available directly from David Ahl. To order, send $20.00 (plus $1.00 per disk for domestic postage and handling charges, $2.00 for foreign orders) to: David Ahl, 12 Indian Head Road, Morristown, NJ 07960. Payment must be in U.S. funds. You may pay by check or money order (payable to David Ahl). Please allow 4 weeks for delivery.


Return to Table of Contents | Previous Section | Next Section