Introduction
There is probably no need to explain the fun you can have playing
games with computers. More specious though, perhaps, is the
enjoyment experienced by the person who programs the computer.
Most games played with cards, dice, and the like are challenging and
mentally stimulating. So too, is the process of computer
programming-perhaps even more so.
Nearly all games allow for some element of luck, but computer
programming is more finite; in fact lucky breaks are not really a
factor of carefully designed programs. Yet the quickening of the
pulse in anticipation of the next draw of cards is not very different
from that experienced by a programmer when he runs his newly
written program the first time.
There is another comparison of games and programming.
Matching wits with askillful opponent is somewhatakin to mastering
a machine. Perservering, finally getting an intricate program to
operate correctly is much the same as succeeding in a bout with a
clever adversary. And after a match of either type, as the warm
feeling of victory begins to wane, the thrill of the contest can be
rekindled with thoughts about future challenges.
Just as in games of skill, programming requires patience, practice,
and diligence to maintain high levels of proficiency. The optimum
combination of these two challenges- games and programming
- is to devise a program that enables the computer to playa
superior game, difficult even for its programmer to beat.
Computers are useful appliances in games. Advances in
micro-electronics in recent years have reduced the cost ofcomputer-based devices to the point where many machines are
available for purely entertainment purposes. Coming rapidly into
vogue now are devices for which a variety ofgame programs may be
purchased.
These exploit attributes such as the speed, arithmetic, precision,
or the impartiality of computers. The machine may serve as
the game board, playing field, or arena for human contestants.
Scorekeeping and refereeing are often features: it's tough to argue
convincingly with a machine. The more sophisticated computer
driven games may also have a player role, allowing for humanmachine
contests.
This book is not offered in competition to these technical
marvels of the seventies, nor with the many books that offer upwards
of a few htmdred game programs ready to be copied and
played. Of course the programs contained here may simply be
copied. Certainly they are fun. These selections intend a dual
purpose, however.
Do copy and play these games, but study them also as computer
programs. The variety from A to Z was carefully picked to
provide examples of gaming schemes appropriate to computers as
well as tricks and techniques for programming in BASIC.
The narrative of each chapter explains the scheme ofthe game,
of course, but provided also are lessons on game program construction.
I have also hied to insure that there is at least one programming
trick-of-the-trade per listing, useful for other types of programs
and for languages other than just BASIC. The purpose is to
equip the student for the maximum of enjoyment in playing games
and programming computers.
Some assumptions were made in choosing the games that
follow. BASIC, beginner's all-purpose symbolic instruction code, is
a commonprogramminglanguage. In the several years since BASIC
was invented, however, numerous variations have appeared. Insofar
as possible there was an honest attempt to provide programming
examples that are not particularly sensitive to a specific language
implementation.
The burgeoning microcomputer industry has adopted BASIC
almost universally. Various factions have taken liberties with the
original syntax, and each vendor's product has nuances- even
among those claiming they conform to the recent standard from the
American National Standards Institute. The language, conceived at
Dartmouth, made it easy to program a computer from a terminal on
a time-sharing system. The inventors could not anticipate the popu-larity BASIC would eventually attain, though, nor the permutations
of its form that would be forced by today's technology.
Many BASIC dialects are a direct outcome of its use in desktop
microcomputers, and extensions to the original language have
evolved to support modem peripherals. These influences were
factored also in designing the programs for this book.
The CRT (cathode-ray tube), the TV-set-like display, is especially
conducive to computerized games. All of the programs in this
book were developed on a CRT-based machine, but they will work
well enough on one with a serial printer. To facilitate easy implementation
on either, and to minimize device-specific language
features, all output formatting has been kept simplistic. As an aid to
those wishing to copy these games just as they are presented,
Appendix I deals with the subject of BASIC language conversions.
Many of the more common differences in dialects are identified
there.
Simplicity was attempted also in the internal design of these
programs. The practiced BASIC programmer, versed in a favorite
product, will find numerous opportunities to optimize these designs.
And to the professional offering critique, be aware that I believe in
the KISS* philosophy, especially for the benefit of our novitiates.
In all events. it is my hope that you will be able to quickly
perceive the nucleus of each of these games and that you will enjoy
full license to enhance and otherwise modify them to your own
liking. I hasten to add. however. that this invitation is intended for
personal endeavors and not for commercial plagiarism.
There is no special significance to the order of presentation of
the chapters that follow. other than the obvious one of using the
alphabet, keying on the first letter of the program name. The
shortest is Cokes, perhaps the simplest is Z-End (a variation of the
classic nim), and unquestionably the longest program is Fivecard
(poker). Across-reference appendix at the back of the book will help
you to locate different game types. programming techniques. algorithms,
etc.
Do read the notes that follow before immersing yourself in any
of these programs. It is here that I have described common aspects
of the structure of most of the programs and offered other comments
of a general nature to preclude repetition in each chapter.
http://www.x45.info/?UNmf0