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
- Marco Polo simulates a three-year journey over the Silk Road in 1271. It is easy to play once you get the hang of using jewels in place of money. However, it is a challenge to complete the journey in three years and have enough jewels remaining for trading.
- Westward Ho! simulates a six-month journey over the Oregon Trail in 1850. It uses the same framework as Marco Polo but, because you have fewer resources, it is slightly more difficult to finish the trip.
- The Longest Automobile Race simulates the 1908 auto race from New York to Paris (east to west). In those days, the cars were unreliable, the roads were nothing more than cart tracks, and, as always, the weather was unpredictable. It is not too difficult to reach Paris, but quite difficult to win the race.
- The Orient Express simulates a mystery case aboard the famous train in 1923. You will almost always complete the trip, but the mystery is extremely difficult to solve.
- Amelia Earhart simulates the around-the-world flight attempt of the famous aviatrix in 1937. If you load enough fuel and pay attention to maintenance and repairs, you will have no trouble reaching Southeast Asia. From there on, it is tough going.
- Tour de France simulates the famous three-week bicycle race. Along with intelligent decisions, this game requires manual dexterity on the keyboard. It is reasonably easy to finish, but quite difficult to win.
- Appalachian Trail simulates the trek of a hiker walking from Georgia to Maine. Preparation is half the key to completing the hike, but sensible decisions along the Trail about eating, walking speed, and walking hours are important also.
- Subway Scavenger simulates the rounds of a messenger using the New York subway system. During the first few plays of the game, you must develop a map of the subway system. Even with the help of a map, you will find this an extremely challenging game to finish.
- Hong Kong Hustle simulates the Tai Pan collecting bags of gold from various locations around Hong Kong. Using the same framework as Subway Scavenger, you must first develop a map, then go for the gold.
- Voyage to Neptune simulates an imaginary journey to Neptune in the year 2100. It is a game of trading and tradeoffs. It is not difficult to get to Neptune; it is very difficult to do so in six years or less and have enough fuel left for the return trip.
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