ebook img

BASIC Game Plans: Computer Games and Puzzles Programmed in BASIC PDF

333 Pages·1982·19.82 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview BASIC Game Plans: Computer Games and Puzzles Programmed in BASIC

BASIC Game Plans From the Library of Birkhiiuser Boston __P rinting _~Edition __R elease Date (Not for sale) Riideger Baumann BASIC Game Plans Computer Games and Puzzles Programmed in BASIC Thomas S. Hansen, Editor and Translator Donald Kahn, Technical Editor Springer Science+Business Media, LLC Riideger Baumann Thomas S. Hansen Donald Kahn Lilo-Godenstrasse 16 Department of German P.O. Box 10 2120 Liineburg Wellesley College Colrain, MA 01340 Federal Republic of Germany Wellesley, MA 02181 U.S.A. U.S.A. Library of Congress Cataloging-in-Publication Data Baumann, R. (Riideger) BASIC game plans. Bibliography: p. I. Computer games. 2. Basic (Computer program language) I. Hansen, T. (Thomas) II. Title. GVI469.2.B38 1988 794.8'2 83-27551 CIP-Titelaufnahme der Deutschen Bibliothek Baumann, Ruedeger: BASIC game plans : computer games and puzzles programmed in BASIC / by Ruedeger Baumann. Edited and translated by Thomas S. Hansen. Techn. ed.: Donald Kahn. -Basel; Boston: Birkhiiuser, 1988 ISBN 978-0-8176-3366-0 ISBN 978-1-4757-3918-3 (eBook) DOI 10.1007/978-1-4757-3918-3 NE: Hansen, Thomas S. [Bearb.] Printed on acid-free paper. Originally published under the title Computerspiele und Knobeleien programmiert in BASIC by Vogel Verlag, Wiirzburg (German Federal Republic). Copyright 1982 by Springer Science+Business Media New York Originally published by Vogel-Verlag, Wiirzburg in 1982. English translation based on second edition (1983). Copyright of the English translation 1989 by Birkhiiuser Boston Inc., Cambridge, Massachusetts, U.S.A. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or oth erwise, without prior permission of the copyright owner. Text provided in camera-ready form by the editor. 987654321 FOREWORD The computer is a toy tossed to us by Nature for diversion and comfort in the darkness. d'Alembert I hate everything which merely instructs without stimulating me or increasing my own activity. Goethe Let's try to eliminate some misconceptions from the outset: this book is not a collection of game recipes as sembled in the form of finished programs which only have to be typed into the computer and then played. Far from it. The object is to challenge readers to activate their own creativity in using computer games. The game concept is designed to develop into game strategy and this then should form the basis of computer programming. Programming comput ers is in itself the game. Or, to put it another way, read ers can learn programming while playing. No previous knowledge of programming is assumed of readers and users of this book -- only the willingness to accept new ideas and improve upon them independently. While all the programs in this book have been run and tested, some are intentionally imperfect. They await the finishing touches from you, the reader. The additional brainteasers at the end of the chapters (or, occasionally, after a sec tion within a chapter) are therefore designed to inspire your imagination and encourage your independence. The material is drawn from numerous sources. Martin Gardner deserves particular mention as his books and his columns in Scientific American are a great treasure trove of game ideas. Furthermore, the j ournals Creative Computing and Jeux et strategies deserve mention. Gardner's influence can be felt in their pages although he himself also draws v upon other writers in this field. Very often it is impos sible to determine the original inventor of a computer game. Game playing is as old as the human race; all peoples and cultures know and promote the activity. In our times game playing has received new impetus through the so-called "Third Industrial Revolution," on the one hand because our leisure time has been increased, and on the other, because the computer has provided us with a partner and master play er of remarkable talent and versatility. It is fascinating to be able to instruct a machine so that it can be taken seriously as a game opponent. The computer has such univer sal talent that every game whether a game of survival or mere entertainment -- can be simulated on the machine or played against it. Some people think that games lose their appeal once the theories behind them are known. For the lover of computers, however, this is just where things get interesting. Playing may be fun but programming the game is more so. After all, one can't play the game until it has been thoroughly under stood. Game playing is an activity very distinct from work in that it is practiced for its own sake, or rather, for the sake of the continuous pleasure it provides -- even (or maybe especially) in our technologized world. The computer so often maligned as a force opposed to human values - is thus contributing to the aesthetic education of mankind. R. Baumann Lueneburg (West Germany) If you would like a 5 1/4 inch, Commodore compatible disk ette for the programs in this book, please send $5.00 to: Donald Kahn P.O. Box 80 Colrain, MA 01340 vi TABLE OF CONTENTS Foreword ...............•............................... v A Word to the User ..................................... ix Introduction ........................................... xiv 1. Rules of the Game: Playing with and Against Computers 1.1 Which hand? ................................ 1 1. 2 Addition Warm-ups .......................... 4 1.3 Too high -- too low........................ 7 1.4 Target 100 ................................. 10 1.5 Match the Partners .......................... 13 2. Learning Games 2.1 The Alphabet Game ......................... 21 2 . 2 Number Sensor.............................. 22 2.3 Total Recall............................... 24 2 . 4 Card Shark's Memory........................ 28 2.5 Math Practice.............................. 32 2.6 State Your Terms........................... 34 2.7 Driver's Ed ................................ 38 3. Games with Graphics 3.1 starting with the Screen .................. 45 3.2 Sonar Sensing (The Bat).................... 56 3.3 Star Hunt.................................. 59 3.4 The Lizard's Snack ........................ 63 3.5 Balloons 66 3.6 The Maze .................................. 70 3.7 Back from the Klondike..................... 78 3.8 Melody Maker ............................... 86 3.9 Game of Life .............................. 89 4. Games of Searching and Guessing 4.1 Mathlete (Nichomachus) ..................... 105 4.2 Guess the Number .......................... 107 4.3 Guess the Word ............................ 109 4.4 Scrambled Words ............................ III 4.5 Crack the Code ("Super Brain") ............. 113 4.6 Spy Ring .................................. 116 4.7 LAP ....................................... 120 5. Games of Chance 5.1 SixHex •.•..•..•.•..•.•................... 130 5.2 Crap Shoot ..•.•..•......................... 134 5.3 Penny Toss ••••••...••.•.•..............•... 138 5 . 4 Twenty-one................................. 143 5.5 Roulette ......•......•..................... 150 5.6 One-armed Bandit •....•.•................... 157 6. Games of Strategy 6. 1 Nim •••.••.••••.•.••.•..•.•................ 172 6.2 Bowling ••.•....•.••••.•.•..•..•........... 182 6 • 3 Queen in the Corner •..•................... 187 6.4 Tic Tac Toe ••.•....•.•..•.•............... 195 6.5 Bridge Builder .•......•..•................ 208 6.6 Mini Chess ..•....•........................ 215 6.7 Four is the Winner •........................ 228 7. Varied Strategies 7.1 Choose Up for Pennies .•.•.•................ 235 7.2 Guess the Card ..••.•.•..•.•..•............. 244 8. Puzzles 8.1 Magic Squares •..•.•..•..................... 255 8.2 Too Many Queens .•.•..•..................... 268 8.3 Knight Errant .•....•....................... 276 8.4 Fifteen Blocks •.•..•.•..................... 282 8.5 The Pouring Puzzle •.•..•................... 294 8.6 Rubik's Cube .•.••.•..•......•.............. 299 9. Mixed Brainteasers 10. Appendix The Programming Language BASIC ................. 317 viii A WORD TO THE USER The computer programs in this book were originally conceived for the Commodore PET. Nowadays few readers still have access to this famous machine that helped to revolutio nize the world of personal computing. Its popular succes sors that are more frequently found in private use include the Commodore 64, the Apple II, and the IBM PC (and compati ble machines). This book and its programs have been revised for users of such modern hardware. These three quite dif- ferent computers still have much in common. For example, they share common languages, of which BASIC is one, although there are differences between the various versions of BASIC when run on different machines. Furthermore, each machine is different internally, so the use of POKE (or PEEK) can be slightly different. All such details are explained in full below so that you will be able to write and run the BASIC programs in this book on your own machine. In keeping with the spirit of the rest of the book, instructions and technical information are provided, but the implementation is, for the most part, left to the reader. PET BASIC There are only a few differences between Commodore BASIC and Apple and IBM BASICs which affect the programs ih this book. The GET A$ command is replaced on the IBM PC with A$=INKEY$. Also, IBM PC BASIC does not allow you to omit GO TO following an IF ..• THEN statement. The Commodore variable TI reads a clock in the Commodore; the IBM's clock is read with TIMER, but the Apple II requires an add-on card for this function. Reseeding the Commodore random number generator is accomplished most randomly with RND(-TI). Use RANDOMIZE TIMER on an IBM PC. Those of you with Apples may need to use your imagination to most randomly reseed. ix PET Graphics The computer programs in this book use two methods of display, PRINTing and POKEing. (All programs may be assumed to be in text mode.) The table below indicates the meaning of PRINTing the eight CHR$ codes which represent screen control commands, as well as the closest equivalent commands for the Apple and the IBM. Function Commodore AppleSoft II IBM BASIC PRINT command command Clearing CHR$(147) HOME CLS the screen Cursor to CHR$(19) VTAB 1: LOCATE 1,1 home (upper HTAB 1 or left.) PRINT CHR$(ll) Right CHR$(29) HTAB or PRINT CHR$(28) cursor PRINT II II Left CHR$(157) HTAB PRINT CHR$(29) cursor Down CHR$(17) VTAB PRINT CHR$(31) cursor Up CHR$(145) VTAB PRINT CHR$(30) cursor Reverse CHR$(18) INVERSE COLOR x,y on Reverse CHR$(146) NORMAL COLOR y,x off Also, moving the cursor around the screen may be ac complished by POKEing. In the Apple II, address 36 contains the cursor's horizontal position, and address 37 contains the cursor's vertical position. x

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.