ee aR Keon James | |

The Atmos Book of Games

The Atmos Book of Games

Wynford James

BE cro PRESS

First published 1984 by

Micro Press

Castle House, 27 London Road Tunbridge Wells, Kent

© Castle House Publications 1984

All rights reserved. No part of

this publication may be reproduced, stored ina retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording or otherwise, without the prior permission of the publishers.

British Library Cataloguing in Publication Data

James, Wynford The Atmos book of games. 1. Computer games 2. Atmos (Computer)— Programming I. Title

794.8'028'5425 GV1469.2 ISBN 0-7447-0018-3

Typeset by Keyset Composition, Colchester, Essex Printed by Mackays of Chatham Ltd

Contents

Introduction Wallsmasher Caterpillar Bomber Creatures Snailtrail Wipeout Zombies Artificial Intelligence Program Sheepdog Trial Adder Minefield

Alien Attack Grave Robber Manhunt

Derby Day Starship Warrior Trap

Ratkiller

Catch

Canyon Bomber

pase J

11 17 22 29

40 46 54 61 67 72 76 82 87 93 98 102 107 112

Introduction

The Oric Atmos is an improved version of the Oric-1. The Oric-1 had excellent sound and graphics facilities but unfortunately it also proved to have a few bugs. These have been eliminated in the Atmos and the new machine is a pleasure to use.

The manual accompanying the Oric-1 was woefully inade- quate. However, the documentation for the Atmos is well written and any reader who finds the following explanations too brief should look to the Atmos manual for more detailed descriptions.

What you see on your television screen when you are typing in or running a program is actually part of the computer memory. Just as any program is stored in the computer memory, so data can be stored in the part of the memory which is visible on- screen. To store data there we need one vital piece of information what are the memory locations used for the screen display? Consulting the Atmos manual, we find that Appendix 5 shows that with a 48K Atmos in Text or Lores mode, the screen occupies the locations from #BB80 to #BFEO. The # at the start of these numbers means that they are in hexadecimal. If you do not know what this means, do not worry. However, it is important that you do not miss the # from the start of the numbers whenever they are used in a program. In the following programs, line 900 nearly always contains a series of hexadecimal numbers. Due to a printer quirk, these numbers have been printed beginning with£ rather than #. It is most important that you type these numbers beginning with # otherwise the programs will not work.

Now that we know the screen memory locations, we can have a look at the method for getting things to appear on-screen.

POKE is normally described as a command which changes the contents of a memory location. If you type POKE#BC84,65 the number 65 will be placed at memory location #BC84 which just happens to be one of the screen memory locations. Will we see the number 65 appearing in the middle of the screen? No, because to the Atmos each number is also what is called a character code, and the number 65 is the character code for A. By typing POKE#¥BC84,65 we cause the letter A to appear in the middle of the screen. A list of the Atmos character codes is given in Appendix 1 of the manual.

The Atmos Book of Games

So we get characters on-screen using POKE but how do we know when we have shot a space invader, scored a hit ona sub, or bumped into a wall? For this we use PEEK.

PEEK enables us to examine the contents of a memory location in other words, find out what is at a particular address. When running games programs, we often need to PEEK to a memory location to see what character code is stored there. Returning to our earlier example, if we typed POKE #BC84,65: PRINT PEEK #BC84 the Atmos will print 65, because it is telling us what is stored at the memory location where we just placed the number 65.

Suppose we were playing a simple game where we fired at space invaders which were dropping down the screen towards us. Every time we fired a ‘bullet’ at a space invader we would have a chance of hitting it. Before we moved the bullet to this new position, we would PEEK that memory location to see what is there. If we find the character code for a space invader, we know that we have hit it, and we can POKE an explosion symbol to that location, use EXPLODE to give a suitable sound, and add a little extra to our score.

On the other hand, we may find that the memory location for the bullet’s new position contains the character code for a space, 32. In this case we would just erase the bullet from its old location by poking 32 there (a space) and we would poke the character code for the bullet into its new memory location.

This process is carried out so swiftly by the Atmos that it gives the impression of movement—to the naked eye the bullet will travel without pausing. In fact it is not moving at all: we are just poking the bullet to a position, then erasing it by poking a space there, and then repeating the sequence at a new position.

Often the Atmos character codes will not be suitable for a particular game. On older micros there was no way around this problem, and many times I have seen a glum micro user firing a stream of full stops out of a gun which was the letter A, and trying to avoid the deadly attacks of hordes of letter Zs!

Fortunately the Atmos lets us make up our own characters and use them to replace those already available. It is important to choose characters which are unlikely to be needed elsewhere. It would be very foolish to replace the number 3 by a monster character, as we would then be unable to use a3 anywhere in the program!

Throughout this book the character codes 91-96 and 123-125 are

Introduction

used when new characters are created. These codes are normally used to indicate square brackets, the copyright sign, and other characters which are not likely to be needed in the course of a program.

Character creation is described in some detail on page 86 and onwards in the Atmos manual, so we shall not repeat the explana- tions here. Needless to say, these programs have been written so that it is easy to insert your own characters if you find, for example, that the monsters in the program ‘Zombies’ are not sufficiently horrific for you.

To simplify matters, the programs all have a common format which makes them straightforward to amend.

Line 900 contains the most important screen locations. These locations are TL, the top left memory location for the screen, TR, the top right, BL, the bottom left, and BR, the bottom right. LL, the line length, or number of characters you can get on one line, is also defined.

There are two advantages to defining all the screen locations in one line like this. Firstly, these locations will be common to many programs, and line 900 and several other lines can be saved as a common ‘skeleton’ program about which the rest of the program can be constructed.

Secondly, and more important, defining the corner locations of the screen like this makes it easy to change the size and shape of the screen area to suit your own taste. You may well prefer all the action to take place in a much smaller area than that given. You do not have to use the true screen corner locations in line 900, and you may decide to move TL, TR, BL and BR in two memory locations diagonally from the actual screen corners.

You can thus make a game more or less challenging by changing just one line from the program.

The lines following 900, up to 950, similarly ease the modifi- cation of the program in other ways.

Line 910 contains the character codes for all the symbols used in the course of the game. Subroutine 2000 pokes these character codes into memory, and if you want to make up your own characters to use in a game and dispense with those given, you need only change the data statements in lines 2010 onwards.

Line 920 contains all those variables which affect the course of a game: NB might be number of bullets that you can fire, NL the number of lives you can lose before the game ends, and so on.

3

The Atmos Book of Games

Again, collecting all these variables together on one line means that only minor changes are needed to make a game very easy or much more difficult.

Lines 930 and 940 are only used in certain games. They contain 8 array values, D(0) to D(7). You do not need to change these lines, but a word of explanation is necessary to clarify their function. The array contains the 8 values for movement in the 8 compass directions. To move up the screen, for example, we would need to subtract the line length from the present memory location to get the number of the location directly above it on- screen. D(0) is therefore set equal to —LL, minus the line length. The other array values give movements in the other major compass directions.

When a key is pressed on the keyboard, a variable showing the present movement number is adjusted so that it indicates which array value D(_ ) should be added to the present memory location to give the new position. If we pressed the key for up-screen movement, for example, the movement number variable would take the value 0, showing that D(0) is to be added to the present memory location to give the new one.

Line 950 sometimes contains DT, the distance along the screen top, and DL, the distance down the left side. Lines 960 and 965 ask whether instructions are required, and line 1000 always clears the screen and sets the foreground and background colours.

Lines 2000 and those immediately after it deal with the creation of user defined characters, and lines 5000 onwards always give the instructions and set the skill level.

Sound commands are scattered throughout the programs, and if you have delicate ears you are advised to omit these statements!

The programs usually begin with a statement that turns the cursor and keyboard click off, and then there is an immediate jump to line 900, where the initialisation of the variables begins. This may seem odd, but there are advantages to this structure. Whenever a GOTO statement is used in a program, the computer has to search through all line numbers from the start to find the line to which the jump must be made.

If we place the initialisation routines at the very start of the program and put the lines which actually run the game immediately afterwards, the game will be slowed down, because whenever a GOTO is used in the latter half of the program, the computer will have to check through all those extra program lines

4

Introduction

before it finds the desired one.

The programs presented here are for pleasure, and none of them is intended as an example of a perfect program. There are probably many improvements you can make. The concentration of all the variables in lines 900-950 should make modifications simpler.

Lastly, a word of advice. Having entered these programs, try to resist the temptation to run them immediately. Save them on cassette first. As nearly all the programs described here use POKE, a mistake on your part can cause a POKE to an area of memory off the screen. This sometimes makes the computer lose the program entirely, and you will have wasted a lot of time and effort.

Provided you have made no typing errors, the program should work perfectly. Each of these programs has been run and tested many times, and there are no major bugs. You should be able to use many of the ideas from these programs in your own games. I hope you enjoy the ones listed here.

General Notes on the Programs

In the following programs, £ signs should be replaced by #. For example, in ‘Wallsmasher’ line 900 should read:

900 TL=#BBD2:TR=#BBF5:BL=#BECA:BR=#BEED:LL=40

16K Machines

Owners of 16K machines should make the following changes. If line 900 contains any hexadecimal numbers, change the B at the start of each number to 3. Again, taking ‘Wallsmasher’ as an example, line 900 should read:

900 TL=#3BD2:TR=#3BF5:BL=#3ECA:BR=#3EED:LL=40 In all programs with a line 2000 of the following form, change it to read: 2000 XX=13312+ Z* 8:FORO=XXTOXX+7:READU: POKEO,U:NEXT:RETURN In ‘Bomber’ make this additional change at line 2030:

2030 DATA15844,15885,15967,16008,16050,15932,15898, 15980, 15894, 15859

Wallsmasher

In this game you have to stop the deadly rain of bombs by blowing them up in mid-air with your rockets. Fortunately you are protected by a thick wall of rock, but once the bombs get through that...

This relatively simple program illustrates many of the advantages of using only variables defined in lines 900-920. For example, you can change the number of bombs that drop at any one time by adjusting BN in line 920, or you can increase your own speed relative to the bombs by increasing BV on the same line. Find the going too tough? Increase the value of WT in line

6

Wallsmasher

920—this is the wall thickness. Too easy for you now? Increase TL and TR in line 900. This moves the top of the playing area down, and means there is much less time to react as the bombs drop. Changing these few variables produces many interesting variations on the game. Experiment and see what combination gives you the most challenge.

Program notes

10 Key click and cursor off.

20-40 Bomb start position routine. 20 chooses a random position along the top from which the bomb will drop. 30 ensures a bomb is not placed on top or directly above another bomb. 40 stores the start position in array B( ).

50-90 Bomb move routine. 50 is a count so that the bombs only move once for every twice the player moves. 55 checks the bomb’s present position. If the bomb has been blown up leaving empty space, it is poked back into a new position at the top of the screen, 65. Otherwise the bomb is erased and its new position checked to see if the rocket is there. 75 finishes the game when any bombs hit the ‘ground’, and 80 pokes the remaining bombs to their new positions and saves those positions in the array B( ).

110-140 Player move routine. 110 accepts the keyboard input, which may move the rocket launcher right, 110, or left, 120. 130 prevents the launcher going off-screen at the sides, and 140 pokes it to its new position.

260-300 Player rocket launch and rocket move. 260 updates the time taken so far. In 290 the rocket launched flag RL is checked. If a rocket has been fired no other can be launched, and while a rocket is sliding through the protective wall, it should not be poked on-screen, 295.

300 prevents the player from launching a second rocket while the first is still on its way. 300-360 move the rocket, 340 causing an explosion if either a bomb or the top of the screen are hit.

370-380 gives the score.

900-950 Initialisation routine.

The Atmos Book of Games

960-1030 Game set-up routine. 1015-1020 pokes the protective wall onto the screen, 1025 chooses the start positions for the first wave of bombs.

2000-2020 User defined character creation routine.

5000 onwards instructions.

Important variables

BC Bomb count bombs do not move until this reaches BV, giving the player a speed advantage.

BN Number of bombs falling at one time.

BP Bomb position on-screen.

BV Bomb velocity a high number means the bombs move slowly.

GP Gun position location of rocket launcher on-screen. NP New gun position after movement. RL Rocket launch flag set to 1 when rocket is launched.

RP Rocket position on-screen.

Symbols used

BS Bomb symbol.

ES Explosion symbol.

GS Gun symbol for player to launch rockets. RS Rocket symbol.

10 PRINTCHR$ (6) CHR#(17):60TO900

20 BP=TL+INT(RND (1) #DT+1):PR=PEEK (BP): PN=PEEE ¢ BF+LL)

30 IFPB=BSORPN=BSTHENZO

40 B(BR)=BP:RETURN

SQ BC=BC+1i: IFRC<BVTHENI IG

So BC=0:FORB=1TOQBN: BP=B(B):FR=PEER (BP)

60 IFPB=32THENS=S+1

63 IFPR=3Z2THENGOSUB20

8

Wallsmasher

70 FOKEBP,32: BP=BF+LL:FPR=PEER (BF): IFRPR=RSORPE= WSTHENFOKEBF,32:EXPLOGE: GOTO7G 73 TFRP?WRTHENFGEEBF-LL,ES: GOTOS79 BO POREBRF,BS:8(B) =BF 90 NEXT 110 NP=GF:AS=KEY$: IFA¥=CHRS$ (9) THENNP=NP 41 120 IFA#=CHR#(8) THENNF=NF-1 130 IFNP=GPORNF<«< BLORNF?BRTHEN260 140 POREGP,32:GF=NF:FPOREGF,65 260 T=T+i:T#=STR#(T)sPLOTI7,24,7# 290 IFRL=1ANDFPEER (RF) =WSTHENIW=1:RP=RF-LL:GOTG 50 295 IFRL=LANDIW=1THENRP=RF+LL: IW=0:G60T0340 S00 TFRLALTHENS36 S10 IFA#< =" "THENS60 320 RL=l:RF=GF-LL:GOTO2Z99 330 PREFEER (CRE) :POKERP, 32: [FPR=32ANDRF2GP-LLTH ENRL=0:GOTOS0 340 RP=RP-LL: TFRPEEK (RP) =BSOGRRP« TRIHENFORERFP, 32 rEXPLODE: RL=0:G60TO50 350 PORERF,RS 360 GOTOSG 370 CLSO:FRINT*You iasted for time "37 S20 END 900 TL=£BBD2: TReEBBFS: BL=£BECA: BREEBEED: LL ade 910 BS=91:ES=92:65=923:k5=94:WS=95 916 FORZ=917T095:G0SUR2000: NEXT 20 J=O:BC=0: BN=2:BVeer WHE: LW oO QT=TR-TL:WL=BL-LL:WR=GR-LL:IGP=BLEINT (Liye: 960 CLSO:FRINT"Do you want instructions (¢f/Ni "3 965 INFUTA#: [FAS="¥"THENGOSUBS 300; 50TO1G05 igoo CLS:INkO:FPAPERS Lads FLOTI1,24, "TINE: % 1010 FOREGF,GS 1015 FORA=WLTOWL+DT:FOREA,WS:NE2TA L@2Q WI=WT-i: TFWTSOTHENWL=WL-LL:G0TGi9815 25 FURB=1TORN: GOSUBSO:NEXTB ® GOTOSS 1 RR=460R804 248; FORO=22TOXX+7:READU:FOREG,U: PRETURN O DATAG,19,4,4,4,4,90,0,5,2,32,1,16,4,0,9,12 2e1f,50,30,45,45,45 O DATAIZ,12,12,12,12,63,45,45,635,355,33,353,5

7, ors og bg O

oye oa, Os

oOo

The Atmos Book of Games

5000

ndg":sFRINT" must try

CLO:PRINT"You

control aro te Blow up

5005 FRINT"bombs as possibl? ob RINT +

aes SOS

s tg a0G0 "SPR ices BOD

10

"destroyed. You may anivy

FRINT’ rocket HiSwiii have t + x

is brea PRINTLERINT"C "!PRIANT "mova ¥ Sam oles SINT*’Press any sere Reve

a “another, bn PRINTHTS" bricks e

at a time - Oo wait until I

evolades at

% iT a“

ma mi 7

ee

thick. Gnc

our launcher Fress tne spa key to begin

ched, the came e ontrois - use th

cket

launcher a

as many”

evore yan are'rF ire one"

it you miss you" the”

the too of tre

auch otected oy a wal @ this" me ends. e@ cursar key jet ang" ace bar to tire.

Caterpillar

In this game you control a tiny caterpillar, and you can make it grow by gobbling up suitable food. The “food” consists of numbers which appear at random on the screen. As the game continues and your caterpillar grows longer and longer, it will become more difficult to control. But your caterpillar is so poisonous that if it bites itself, it will die. And you dare not bump into the walls either because they’re electrified!

The main problem in this program is how exactly we can make the caterpillar grow. It might seem that the simplest way to do this is to draw the caterpillar, erase it, then draw it again in its new position. When the creature eats a number, we need only

11

The Atmos Book of Games

draw it one unit longer at the new position and it will appear to have grown.

There is only one thing wrong with this approach it does not work! The Oric takes too long to draw and then erase the cater- pillar. We need to devise a program which does not involve rubbing out the entire caterpillar each time. One way to do this is to only erase the very end of the caterpillar, place a segment of the body at the old position of the caterpillar’s head, and draw anew head. The following diagrams should make the process clear:

1 2 3 4 5 6 7 8 ie NWA NX NC NX YY | 66666 JN

1 5 6

2 TT EXYXXKYX ES

Movement of the caterpillar on-screen. The last segment, at 2, is erased, the old head at 7 is replaced by a segment, and the new head is placed at 8.

The actual position at which the head will be placed depends upon which control key on the keyboard is being pressed. Because we will have to rub out the caterpillar’s tail every time it moves, it is clear that we will have to store all the screen memory locations which the caterpillar occupies. Each time the caterpillar moves, the next-to-last segment will become the new tail, and we will need to know its memory location so that we can erase that new tail on the next move.

All the screen locations for the parts of the caterpillar’s body are stored in the array S( ). Whenever the caterpillar moves, an unused array value is used to store the screen position where the head now is. The caterpillar gradually travels through the array, which is why the array is set to S(900) at line 900: this also gives plenty of room for it to grow in the array. When the caterpillar reaches the end of the array, the head cycles back to S(0), (line 140).

12

Caterpillar

Every time the caterpillar hits a number, it grows by that number of segments, the growth taking place from the head. This allows you to control the caterpillar even as it grows.

The subroutine which places the numbers randomly on the screen has been placed at the start of the program to speed things up. It is a relatively simple task to introduce a few changes, such as symbols which will kill the caterpillar if it eats them. For example, the following have exactly this effect:

165 IF RND(1) >0.9 THEN N=43: GOSUB12

If you want to make the caterpillar’s task even more difficult, change line 165 above so that the deadly symbols appear even more often, for example 165 IF RND(1)>0.1 .. . is a real challenge!

Program notes

10 Key click and cursor off. 12-16 Subroutine to place numbers on-screen.

20-60 Keyboard controls using cursor keys. The caterpillar head symbol varies according to the direction in which the caterpillar is heading, so H is adjusted along with the direction.

110-170 Caterpillar move routine. 110 finds the new head position and checks that the caterpillar has not bitten itself or run into a wall. Anything else hit must be a number, so 120 adds this value to the length of the creature, and sets the number value NV to the value of the number just hit. This is so the number can be poked back elsewhere onto the screen after it has been eaten. If the caterpillar’s present length does not match its theoretical length, 130 makes the creature grow by one unit. 135 and 140 move the caterpillar through the array S(_). 145 pokes the head to its new position, pokes a body segment to the old head position, and deletes the tail. 160 pokes any eaten numbers back onto the screen by calling subroutine 12.

200-280 Game end routine. 200 makes a suitable noise when the caterpillar hits itself or the wall, and the remaining lines make appropriate comments.

13

The Atmos Book of Games

900-950 Initialisation routine. 960-1000 Offer instructions and set colours.

1100-1210 Game set-up routine. 1100 and 1105 draw the electri- fied walls making up the playing area. 1110 to 1200 draw the caterpillar in a random position on-screen. 1210 calls the sub- routine to poke the numbers 1 to 9 to the screen, and 1220 draws the caterpillar’s head.

2000-2030 User-defined character creation routine.

5000 onwards instructions.

Important variables

LP Present caterpillar length.

LS Length of caterpillar including extra units added due to numbers eaten.

MD_ My direction of movement to select a move for the caterpillar from the array D( ).

NN Number position as it is poked on-screen. NV Number value value of number eaten.

NX Random X coordinate for number.

NY Random Y coordinate for number.

S Position of caterpillar head within array S( ). SD _ Side distance inside play area.

SP Position of parts of caterpillar’s body as it is poked to the screen.

ST = Caterpillar tail position.

Character symbols

H Head of caterpillar. There are 4 head symbols, as the cater- pillar can move in 4 different directions.

NS Nine symbol character code for number 9.

OS Nought symbol code for number 0.

14

Caterpillar

SS Segment of caterpillar symbol. WS _ Wall symbol.

Arrays

D() 8compass directions from north.

S(_) Screen memory, locations of all parts of caterpilllar’s body.

10 PRINTCHRS (6) CHRS (17): G0TO900

12 NK=INT(RNO(L)#TD+L) :NY=INT(RND (1) #SD+i)

14 NN=SZ+NX-NY#LL: TFRPEER (NN) < eS27HENG2

16 FORENN,N: RETURN

20 ASSKEVE: [FAS=CHRE (11) THENMND=G:H=93

40 TFA#=CHRE(9) THENMD=2:H=94

60 ITFAS=CHR# (10) THENND=4:H=95

§0 [TFAf=CHR# (8) THENND=6:H=%5

Lig NP=SH+D (MD): P=PEER (NPs TFP=SSGRP=WSTHEN ZOU {20 NV=O: TFPs s32THENLS=LS+P-O5: NYSP

130 TFLFeLSTHENLP=LP+1:5=5+i:PING

135 S=S+i:sT=ST+is (FST s9G0THENST =6

14g TFSs900THENS=6

145 S(S)=NF:PORENP,H:PORENF-D(MD) ,S5:FQKES(ST)

a) ad

160 SH=NP: TFNVFOQTHENN=NV: GOSUBIL 2

170 GOTG2Z0

200 PLAYS,0,1,1000;S0UND3,1000,0

205 PORENP.H:PORENP-OCND) ,SS:PORES (st: ,22:Watl (300)

210 CLSO:PRINT"Hard Luck! You "s:TFRP=SSTHENFRIW T"bit yourself. ":GO0TG226

215 PRINT"bumped into a wall."

22U PRINT’ You grew to be “sLF:" units long. 280 END

990 DIMS (900): TL=£BBD2: TRe£LRBFS: BL=£BRECA: BR=ER EED:LL=40

930 OS=48:NS=287:55=91:WS=92:H=9 91S FORZ=917096: 60S5SUR2000: NEXT 920 MD=4:$5=4:LP=L$:S5=L5:57T=0 G30 D¢GP=-LLi DCL =-LLtis DC eiatiO¢ Sr =Lbe+i 940 Di4y=Lb:iD(S)=LL-i:Bt6)=-1:0(7)=-LL-i 930 OT=TR-TL:DL=BL-TL:SZ=8Lt+2*0¢1)

ur

15

The Atmos Book of Games

760 CLS:FRINT"Do you want instructions (Y/N) "3 965 INPUTA#: TFAF="¥"THENSOSUBSOOG: GOTI1LO0N

980 GOSUBSGS0

16000 CLSO:INKi: PAPERS

liga FORA=TLTOTR:FOREA,WS:FOREAtDL WS: NEXT Li05 FORA=TLTOBLSTEPLL: POKEA.,WS:FOREAtDT WS:NE Ri

L110 TD=DT-4:S0=(DL-4e#l bi fii

{170 GYSINTCRND(L)#TD+i) sSY=INTORND (CL) #5Dti): H=52+5X-Sy#LL

ii7vS TFRPEER (SH) <4 232THENII7 0

1180 S(L5)=SH:SP=SH:PORESP,H:FORA=LS-1TOLSTEF- i

1190 NP=SP+O°RD)

Ligh TFRPEER CNP) < 33 2THENRD=INTCRND (ii #6+1)260TO L196

iZ00 SF=NP:S(A)=NF:FORESP,SS5: NEXT: FORN=O05+170N 5:50S5UBRi2:NExRT

1210 SH=S(LFI:G0TGEo

2000 XX=FG0R0+Z #8: FORGHXKTORA+ 7: READU: POREOQ,U: NEXT: RETURN

2010 DATAIZ,12,18,51,51,18,12,12,463,65,43,4635.6 3,63,64,63

2020 GAIAG, GU ,0,0,35,18,12,12,0,4,60,48,48,5,4,0 5l2,12,18,55,0,9,0,4%

2030 DATAG,&,4,3,3,4,8,0

S000 CLS:PRINT" You are a smali caterpillar. Yo u?

5005 FRINT"must try to gobble up as many":FRIN T"numbers as you can. You will grow"

5010 PRINT"every time you eat a number. “:PRINT :FRINT" You begin a mere “;LF:i" units long." sc20 PRINT? Don’t Bite vourself or bang your *:P RINT* head against the wali!"

sada PRINT:PRINT*Controls - use the cursor key Se "

5050 PRINT:FRINT"Fress any key to begin. ":REFE AT:GETA#:UNTILA# =" “SRETURN

mn

16

Bomber

In this game you pilot a bomber which flies repeatedly over a number of skyscrapers and attempts to destroy them by dropping bombs. Each hit destroys one floor of a skyscraper, so the buildings gradually get lower and lower. Unfortunately your bomber also drops lower after each successive pass, and if you fail to hit the highest buildings first the plane will run into a sky- scraper and explode.

This program is an old favourite, and there are versions of it for most popular micros. The program is straightforward, but if you want to make the game harder by increasing the number of

17

The Atmos Book of Games

buildings or changing their heights or positions on-screen, just amend the data values at line 2030. These values are the screen memory locations for the top of each building. Each skyscraper is drawn from the top downwards. If you have more than 10 buildings, you must change the value of NB in line 920, as this shows the number of buildings and is used by the computer to decide how many items must be read from data.

Program notes

10 Key click and cursor off. 20 Delay loop, varying according to skill level.

30-90 Bomb drop routine. Only one bomb may be dropped at a time, so 30 checks the bomb drop flag BD. If BD=1, a bomb is dropping and no further bombs can be dropped until this one explodes. If BD=0, a bomb may be dropped by pressing ‘B’, line 40. The bomb’s first position is that of the plane, line 50. The bomb is erased, 60, and its new position calculated 65. If the new position is at ‘ground’ level, the bomb explodes, 70, as it does if it hits a skyscraper symbol, 80. Otherwise the bomb is just poked to its new position, 90.

100-120 Plane move routine. 100 erases the plane from its old position. If the plane has reached the far right of the screen, it is moved back to the left and placed one line lower on-screen. 110 checks if the new position is occupied already, in which case the plane will crash. 120 pokes the plane at its new position, and if the plane is not at ground level, the program continues.

130-180 Game end routine. Appropriate messages are delivered depending on whether the plane has landed or crashed. A score based on the skill level and number of building blocks destroyed is also given.

900-930 Initialisation routine.

960-1150 Game set-up routine. 1100 reads in the top position for each building, and 1105 draws it from the top down to ‘ground’ level.

2000-2020 User defined character creation routine. 2030 Screen memory locations for top of each building.

18

Bomber

3000 Bomb explosion routine.

5000 onwards instructions, including setting of skill level.

Important variables

BD Bomb drop flag value 1 if bomb is dropping.

BP —_ Bomb position.

HC __ Hit count count for blocks of skyscraper bombed.

NB Number of buildings to be poked onto screen.

NP New plane position.

P Present plane position.

PT Plane trip count. When PT=DT (the distance from the top left to the top right of the screen), the plane has moved across the entire screen and must be moved back to the left to begin another pass.

PV Plane velocity the higher this is set, the slower the plane moves.

TB = Screen memory location for the top of each building.

Symbols used

BS Bomb symbol.

ES Explosion symbol.

PS Plane symbol.

SS Skyscraper block symbol a building is created by stacking these on top of one another.

10 PRINTCHR# (6) CHR#(17):G0TO900

20 30 40 50 60

WAIT(PV)

IFBD=1THEN6O AS=KEYS: IFAS S"B"THENIOG BF=P;BD=1:G0T065 POKEBP,32

19

The Atmos Book of Games

65 BRP=BF+LL

70 IFRPSBLTHENBD=0: GOSUBS000: 6070100

BO IFPEEK (BF) =SSTHENBD=0: HC=HC+1: GOSUB3000: GOT

gid

90 POKEBP,ES

{og PFOKEF,32:P=P+1:PT=PT+1: TFPT=DTTHENPT=0: PHF

+LL-DT

110 NF=FEEK(P): TFNPS 332 THENISO

120 POKEP,PS:1TFRPeBLTHENZO

130 PRINT: PRINT"Wel!l done! You ianded the plan

e":FRINT"on skill level ";5L:GOTO160

150 POKEP,ES:FORQ=1TOS: INFG:EXPLODE: WAIT(IG):N

EXT: INKG:CLS

160 PRINT: FRINT"You hit “sHC;" blocks at skill level "s5L

176 PRINT"A total score of "“sHC#S5L

i6G END

900 TL=fBBD2: TR=fBRFS: BL=£BECA: BR=EBEED:LL=40

910 BS=FL:ES=92:F5=93:55=74

915 FORZ=91 7094: G0SUR20G0: NEXT

920 BO=O:HC=O:NB=10;P=TL

930 DT=TR-TL:FT=6

960 CLS:PRINT"Do vou want instructions (¥/N)";

965 INPUTA#: [FAS="¥"THENGOSUBSOOO: GOTOIO00

780 GOSUBSOS6

1ggc CLS: INKG:PAPER4

Lido FORA=1TONB:READTE

1195 FORB=TBTOBLSTEPLL:POREE,SS:NEXTB:NEXTA 1110 FORA=BLTOLBFEGSTEPLL: POREA, 1G: NEXT

1150 POREP.PS:50TG20

2000 XXS4GO0B0+7 #8: FORO=XKTOXX+7:READUS POREO,U:

NEXT:RETURN

2010 DATAO,10,4,4,4,4,0,0,68,2.32,1,16,4,0,0,16 76,56,63,4,8,16,0

2020 DATA4S,63,45,63,45,63,.45,63

2030 DATA4B8612,48653,48735,48776,48818,48700,4

8666,48746,48662,48627

2000 POREBF ES: EXPLODE: FOREBP,32:RETURN

5000 CLS:FRINT*Try to bomb all the buildings 5

o":FRINT"that your plane can land*

SGi0 PRINT*safely. Gnily one bomo can be":FRINT "dropped at a time, and no further”

SOZ0 PRINT" bombs can be dropped until the*:Pal

NT"first one expiocdes. so be accurate!

20

Bomber

MG FRINTSPRINT* Controls - B drops bomo. * oo FPRINT:PRINT"’Iaput skiii level, i, Gas. ¢ o 5, °:PRINT"hard?::TNPUTSL

n060 [TFSLALGRSL SS THENS GSS oo70 PY=46-SLinkE TURN

21

Creatures

You control a man who flees from pursuing monsters by running up and down ladders and along floors. When you have time you pause to dig holes in the floor in an attempt to trap your enemies. Any creature that falls down a hole can be destroyed if you can hit it on the head while it is trapped. It will fall through the hole and splatter on the floor below. But don’t take too long digging the hole or the creature will escape and crush you!

For the creatures it is important to record several pieces of information: their position on-screen; their current direction of movement; and what character normally occupies their position

22

Creatures

on-screen, so that this can be poked back into place when the creatures next move. These values are stored in the arrays P(_ ), M( ), and O( ) respectively.

Holes are dug on-screen by successively poking suitable characters to the hole position to give the impression of soil being removed. At present a hole is dug in 3 stages, 210-240, but this can be reduced to a single stage by deleting 210-230 and changing 240 to POKEHP,HS:GOTO10.

Program notes

10 Keyboard click and cursor off.

15-65 Creature move routine. 15 finds the creature’s present position, current movement, and the character at its old position. The last part of the line compares the creature’s position to the man’s and sets movement to up or down as appropriate. 20 finds the y co-ordinate of the creature relative to the man and checks if it has just fallen down a hole. If the creature is on a ladder, it will move up or down, 30. 40 finds its new position and checks that it is not moving to an occupied position. 50 fills in the hole if the creature has just been knocked through. 60 moves the creature to its new position.

70-190 Move man routine. 70-120 are keyboard controls. 130 finds the new position. 150 makes the man fall vertically if he has jumped through a hole, 160 prevents him from going off the end of a floor. 170 moves the man and 180 finds his y co-ordinate relative to BL: this is needed to determine the direction of creature movement. 190 ends the game if the man gets eaten.

200-240 Hole digging routine. 200 prevents a hole being dug at ‘ground’ level or on top of a ladder, 210-240 substitute different characters as the hole is dug.

300-340 Falling creature routine. 300 repairs the floor behind the falling creature, 305-310 make it fall until it hits the floor below. 315 explodes the body, and 320-340 poke a new creature to an unoccupied position.

500-510 Game end routine. 900-955 Initialisation routine.

23

The Atmos Book of Games

960-1130 Game set-up routine. 1010-1025 draws each successive floor and, except for the ground floor, 1030-1070 draws randomly- placed ladders hanging down from that floor to subsequent ones. 1080 places the man, and 1085-1130 place the creatures at random positions on a floor other than the man’s.

2000-2030 User defined character creation routine.

5000 onwards instructions and setting of skill level.

Important variables

CM Creature movement direction.

CN _ Creature’s new position.

CO Character at creature’s old position.

CP Present creature position.

CV Creature value its worth to player.

DF _ Vertical screen distance between floors.

EC Escape chance probability of creature caught in hole escaping.

F Flag for man falling through hole to new floor.

G Creature movement on ladder, if one is available.

H Half, 0.5, used in random number calculations.

HM Hole movement direction in which hole will be dug by man.

HP Hole position.

LB Ladder base position.

LD Horizontal distance between ladders on a floor.

LT Ladder top position.

M Minus one, —1.

MM_ Man’s movement.

MP = _Man’s position.

NC Number of creatures in game.

24

Creatures NF Number of floors. NH _ Number of digs to produce complete hole. NL Number of ladders between pairs of floors. NP New position for man. FE Plus one, +1.

SC Player score.

Z Zero, 0.

Symbols used

BS Blank space.

CS Creature symbol.

ES Explosion symbol.

FS Floor symbol.

HS Hole symbol for completed hole. H1, H2, H3 Holes in various stages of completion. LS Ladder symbol.

MS Man symbol.

OS Old symbol found at man’s last position.

10 FRINTCHRS (6) CHRE (17): 60TO900

15 FORA=FTONC:CF=F (A) :CH=N (Al CO=0iA)sGRLL: TFA F-CFeZTHENG=-6

20 CHBL-CP:sY=INTCRtC/LLI-M¥: TECO=HSANDFEER (CF) =HSTHENZ00

25 W=PEER(CF+CM): TFW=BSQGRW=CSTHENN (A) =-CM

30 IFCG=LSANDY*¢ :ZANDPEER (CF+G) < 2 BSTHENCH=6

40 CN=CP+CM:s PC=PEER (CN): TFRFC=CSORFC=BSORCO=SHSA NDRND( 1) FECTHENSS

30 IFCO=HSTHENCO=FS

60 POKECP,CO:FOKECN,CS:F (A) =CN: Gia =FC: (FRC=MNS. THENSOO

65 NEXTA

25

The Atmos Book of Games

70 HM=Z: AS=KEYS$: TFAS=CHR$ (11) THENMM=-LL

BO ITFAS=CHR#( 10) 0RF=FTHENMM=LL

90 IFAS=CHR# (8) THENMM=N

100 IFA#=CHR#(9) THENMM=F

lid IFA#=","THENHM=M: GOTOZ00

120 IFAS=". "THENHM=F:G0TOZ96

130 NP=MP+MM: PN=PEER (NFO: TFNPENFTHENIS

140 IFF=FANDOS< >BSTHENFH=Z

150 IFOS=HSTHENF=P:MM=LL:NF=MF+LL: PN=BS

160 IFFPN=BSANDF=ZORFN=MNSTHENIS

165 PLAY7,0,1,250:PLAY7,0,2,250

170 FOREMF, 0S: OS=PN: MP=NP:FOREMP, MS

180 J=BL- MP: MY=INTCR+0/LL): TFRNe SCSTHENIS

190 GOTGSGG

200 HF=MP+HM:H=FEER CHP): TFRE3=8LORH=LSTHENIS 205 FLAYO,7,1,250

210 S=HS:1TFH=FSTHENS=H1

220 TFH=HLTHENS=H2

240 ITFH=HZTHENS=H3

240 FOKEHF,S:GOTQIL5S

300 PORECFK,FS:FLAY1,&,2,10:50=0

205 CP=CF+LL:E=FEER (CR): FORV=S0TOSG+20: SOUND I Y,4s NEXT: 50=50+20

S10 [TFE=B8STHENPGRECF ,CS:WAIT(T):FORECP,BS:60T0 305

215 PLAYO,0,0,0:FORECP ES: EXPLODE: SC=5C+C¥

B20 COSE:CM=P:CN=TL+DFeINT (RNDG LI #NF +i TPR ADS 1) sHTHENCN=CN+DT: ase

330 FPC=FEER (CN): TFRPC=CSGRPC=BSTHENSZO

340 M(A)=CM:G0TOGS6

SG0 PLAY7,O,3,1:WAIT( 40; :PLAYG, 0,0, G:WAIT (200) S05 CLS:FPRINT*’ Your score at skili level ";SL;" was "35C

sia END

900 TLSERRD 2: TR= f£REFS: BL=€RECA: RREEBEEDS LL =a S=FSrMSF3:CS=F4:HS=9S: E594: 05=SF5 23:H2=124:H3=125

Bed poh oa BOSUBLOCOINEXT:FORZSLe3TOlegib

PNFS4:NH=4:N laa; Psisfe014s-1iH=.8

{ Oo De Se Leer eat he ba Dial ses) Sie is) nth scien ea) eli ei igi=- PRE=GES) Fad OT=TR-TL:DL=tBL-TL) /LLsDF=INT | H#DLS ANF d dd

Creatures

S55 LDS INTENT Wis ReclLb-do ee

Feu CLS:P RING Go you want instructions (ffi: 965 INFUTAS: [FAS= "2 “THENGOSUBS GOO! bo foraos S80 GOSUBSGS0

igad CLa:INk4: PAPERS

LOiv BSTL+i

1015 D=Bt+DT:FORASBTOU: (FREER (AI=LSTHENL OSS 1020 FOREA,FS

1025 NEXTA: TFRS=BLTHENIOBO

{O30 FORA=LTONL: TFASLTHENLTALT+L OD GOT Giede L085 LTHR+INTCRND CLs el ott:

i040 TFREER CLT) =LSTHENITOSS

1045 LBR=LT+DF: (FLB2D+0F THENLR=D+DF

1050 FORDSLTTOLBSTEPLLIPORED.LS:NERTO:NESTA {O70 BSB+DF:60TG1a15

BG MP=TL:GS=PEER (MP) :PNSPEER (MP +: sPOREMP, 45 fS FORASL TONG

1090 CPSMP+OF+INTURND Cd) eT +h + INT RNG CD) ® ON - yer

figd TFFEEK CR) < sFSTHENIOGO

LilG CM=PiTFRNG CL) SHTHENCM=M

Lid0 Pia SCR MCAD SCN OCA HFS: PORECR CSsNEXTSa:6 aqTaiga

2000 KASFGURO+ ZL HRs FORGSARTORS+ 7: READUS PORE, Us NEXT: RETURN

2010 GATAI2, 23,05,32,335,35,04,55,63,635,64,63,6 B,64,635,14,14,4,31,4,4,10

2020 DATAL?, o2,12,45,45,0,18,0,45,1,1,1.1,1,1, 1,i,6,2.232,1,16,4,0,9

2030 DATAL,1,1,63,68,63.,63,63,1,1,1.1,1,63,03, baylsi,gi,l,i,i-t,o4

Sugg CLO:FRINT’ You must try to kill all the":F RINT*creatures by digging holes for”

SQ05 PRINT"them and then hitting them over the “SFRINT* head while they are trapped in”

ocLG PRINT"the hole. If you leave it too long" :FRINT"the creature will escape a*d"

SuiS PRINT"eat you. Use the cursor keys ":FRIN T'to move, and the « and ? keys"

ad20 PRINT"to dig holes ta the right and lett" :PRINT"respectively. it takes ":HH

s025 PRINT"digs to compiete a hole - a hole":FP RIT“ that has only partially been dug"

S030 PRINT*will not stop the creatures, “:PRINT You may jump through a dole yourselt"

27

The Atmos Book of Games

G25 PRINT“and you wili fail unharmed to tne": PATH?" +icor Gelow,

PRINT’ Inout your skill fevel. J Tohigher numters mean that the® PRINT® creatures escape more guickiv from”

to 9 the®

28

Snailtrail

In this program you control a snail which moves around the screen at a very un-snailish speed. Every time your snail moves it leaves a slimy trail behind it and you must not bump into the trail!

Seem easy enough? Well, there is one small problem: the computer also controls a snail, so not only must you avoid hitting your own trail, but also that left by the computer’s snail. In addition you must not hit the other snail, or the walls... .

The program is comparatively straightforward, the main problem being to arrange for the computer’s snail to move in a random fashion which, at the same time, is not so unpredictable that it becomes easy to trap the snail in a small portion of the screen.

29

The Atmos Book of Games

In early versions of the program the computer’s snail moved completely at random. This proved self-defeating as the snail boxed itself in and was forced to eat its own trail.

In this version the snail only changes direction around 3% of the time, line 135, although it will always try to change direction if it is about to hit a trail, the other snail, or the wall.

If a direction change is called for, the program chooses a random direction, line 140, and if there is no obstacle in that direction, this is the way the snail will move, 145. Otherwise the program tests all other movements from the present position in an attempt to find a ‘safe’ direction. This is the reason for lines 140 and 150: REPEAT try all the directions UNTIL you've tried them all or a safe direction has been found.

Program notes 10 Keyclick and cursor off. 15 Loop for a series of games.

20-80 Keyboard controls to direct the snail.

110 Check new position of snail. If it is occupied, game to the computer!

120 Move snail to new position. 125 Pause of varying length at different skill levels.

130 Check computer snail’s new position if it carries on in its present direction.

135-150 If the new position is empty, move to it. The RND statement ensures that the snail will still change direction occasionally even when the space in front is empty.

160 Check computer snail's revised position. If it is empty, move the snail and the game continues.

170-190 Otherwise blow up the computer’s snail and start another game.

200-220 The score after a series of games. 900-950 Initialisation routine.

980-1000 Give instructions, set foreground and background colour, etc.

30

Snailtrail

2000-2020 User defined character creation routine.

3000-3010 Draw walls.

3020-3040 Place snails at their start positions and display score.

5000 Instructions and choice of skill level.

Important variables

B

Count for number of directions tried by computer’s snail in its attempt to find a safe movement.

CC Computer count score for computer in terms of games won.

CD Computer direction for snail.

CP Computer position for snail.

D Direction randomly selected by computer’s snail.

M Movement direction for snail at present.

MC My count— my score in terms of games won.

MD_ My direction for snail.

MP My position for snail.

NC Newcomputer position for snail.

NG Number of games to be played together.

NP New position for my snail.

P Peeked value found at new positions of snails. Count for games as they are played.

SL Skill level.

Symbols used

CS Computer snail symbol.

ES Explosion symbol used when a snail hits something.

MS Mysnail symbol.

WS_ Wall symbol.

31

The Atmos Book of Games

iO FRINTCHR# (6: CHRE(17):60T0900

iS FORG=1TONG: GOSUBI000

20 AS=KREY$: 1 FAF=CHRE (11) THENMD=0

49 [TFAS=CHRE(9) THENND=2

40 [TFAS=CHRE (10) THENMD=4

8G IFA#=CHRE (8) THENMD=64

110 NP=MP+D(MD}:P=PEER (NF): TFRP« s32THENPORENP,E §:CC=CC+1:G0TC1aG

120 MP=NF:FORENF NS

125 WAIT(11-5L)}

136 NC=CF+D (CDi: C=FPEER UNC:

135 LFC=S2ANDRND (1) >. Q3THENCPENC:FORECP CS: 607 G20

140 M=CD:b=0:D=SeINTCRND( Li #4) sREFEST: B=Be ii de D+2: TF Ds4THENDEG

145 [FRFEER (CP+D (0) } =S32THENN=D

{Sc UNTILB=40RH2 20D

16g NC=CR+D (Mi :CSPEER CNC): TFCHS2THENCPSNC:CO=K :PORECF,CS:G0TQ26

170 FORECF,CS:MC=MC+i

LBG EXPLODE: WAIT 200)

{90 NEXT

200 CLS:FRINT® The final score was: ":PRIWTSFCCI 3); "Computer +: “3CC

210 PRINTSPC(18)}s "You 2: o"sMe

229 END

900 TLef£BBOS:TR=£BRFS: RL=£BRECA: BR=fBEED: LL =40

F710 MS=9L:CS=92 :WS=93 E5=94

915 FORZ=9170594:G05UB2 000: NEXT

920 MC=0:CC=0:ND=0:CD=2

930 D(O)S-LL:D (ii =-LL+i:D(2)=1:D0S)=LLt1

$40 Di4;=LirD(S)=LL-1:D¢(6)=-1:0(7)=-Li-1

950 DT=TR-TL: DL=BL-TL: THEINT(OT/ 93)

S60 GOSUBSGOG

tadd CLO:iNk i: PAPERS: 607015

BOQO0 XX¥=46G80+2*#8:FORG=XXTORX+7 :READUSPOREG,U: NEXT: RETURN

2010 DATAGi2Z,12,18,51,51,18,12,12,12,39,20,63,6 2,39,12

; ) DATAG3,63,63,63,03,603,63,63,8,2,32,1,16,4

Boge CLS:FGRA=TLTOTR:FOREA,WS:POREA+DL WS: NEXT BOLG FORA=TLTGBLSTEPLL: POREA, WS: POREA+DT WS: NE AT

32

Snailtrail

SOZ0 MPSTL4THt+l Oe LL: CP=TR-THtiGeL Li NDau: cbse 3025 C#="Computer : “+STR#E(CC)rNF="You : “+STR £(MC)

303G PLOT4,24,C#:PLOT2Z5, 24,44

3G35 PLAYS,i1,4,10¢

3040 POREMP,45:POQRECF,CS: RETURN

Badg CLS:FRINT"You will leave a track behind": PRINT" you as you move. The computer”

S005 FRINT'will also leave a different track. * :PRINT"The first one to bump into a"

SdGi0 FRINT"“track loses the game. ":FRINT:FRINT® How many games do you want’;:INFUING

SOLS FRINT:FRINT"What skill level, 1. slow, to "SPRINT"IO, fast"s:INPUTSL

SGZ0 TFSLZiGRSLILGTHENSGIS

sag40 FRINT:FPRINT*Controls - use the cursor key 5050 PRINT: FRINT*FPress any key to begin. 7:REFE AT:GETA#:UNTILAFi 2" "RETURN

33

hee we

This game requires the player to try and wipe out a screen full of targets by hitting them with a ball. The game has several useful routines which can easily be incorporated into other programs.

A few years ago one of the early popular arcade games was Breakout, where the player scored by knocking bricks out of a wall. The game that follows is not a Breakout variation, but Breakout can easily be programmed using the routines given here for bouncing the ball off the walls of the playing area.

The big problem with this type of game is that writing the program to use low resolution graphics makes it impossible for

34

Wipeout

the ball to bounce at a great variety of angles. To enable the player to make different shots, the player’s bat consists of 3 symbols, and the ball bounces in a variety of ways depending where on the bat it strikes.

Program notes

10 Keyboard click and cursor off.

20-30 Keyboard controls to move bat left, 20, to stop it, 25, or to move it right, 30.

40-50 Bat move routine. 40 finds the new middle position of the bat after movement, and checks that the bat will not be off-screen or on top of the ball. 50 moves the bat to its new position.

55 Score number of crosses hit so far.

60-180 Ball move routine. 60 finds the new ball position. 65 checks if this is a cross, in which case the score is incremented. If the new position is empty ora cross, the ball can be moved to that position with no difficulty, 70. Complications arise when the ball hits a wall or the bat, as it must bounce in a different direction. 80 takes care of bounces off the top wall, and 90 does a similar job for side wall bounces. 110 is needed in case the ball is about to hit the bottom left or bottom right of the walls. Whereas normally the ball will be reflected when it strikes a wall, doing so at the very bottom edges sends the ball out of the playing area on-screen and into free memory! So if a ball is about to strike BL or BR, its movement is just reversed and it travels back along its path. The beginning of 110 can be omitted: this causes an occasional reversal of movement as the ball bounces from wall or bat. 120 and 130 determine the new ball movement if the bat is struck, 130 deflecting the ball slightly if the right or left sides of the bat have been struck. Having done all this, it is possible that the ball has just been deflected from one wall onto another, so 140 returns to the start of the ball move routine to check that the new position is clear. 150 erases the ball from its old position, and if the new position is not off the bottom of the playing area due to the bat missing the ball, the ball is drawn to its new position and the process begins again. 160 checks if all the crosses have been hit, 175 increases the ball count if the ball has gone off screen, and 180

35

The Atmos Book of Games

pauses before a new ball comes into play, 185 chooses a random start position near the bottom of the playing area to poke the new ball into play.

190-210 Score and comments at end of game. 900-950 Initialisation routine.

960-1150 Game set-up routine. 1100 draws the top wall. 1105 the side walls. 1110-1130 poke the target crosses into position on screen. 1110 sets up the start and end position of each row of crosses, EX being the amount added on so that alternate rows are staggered. 1120 counts the crosses, pokes them into place. 1130 works out the start and end positions for individual rows of crosses. Finally, 1140 pokes the bat into position in the middle at the bottom of the playing area.

2000-2020 User defined character creation routine.

5000 onwards instructions.

Important variables

BC Ball count how many balls used so far. BM _ Ball movement.

BT Total number of balls allowed when BC reaches this value, the game ends.

CH Number of crosses hit by ball.

CT Total number of crosses.

DL Distance along left of screen.

DT _ Distance along top of screen.

EP _ End position for poking crosses on screen. EX _ Extra added to stagger rows of crosses. L2 Double line length LL.

M Bat movement.

MP Position of middle of bat.

NB _ New ball position.

36

Wipeout

NP New bat position.

SP Start position for poking crosses on screen.

Symbols used

BS Ball symbol.

CS Cross symbol.

LS Left bat end symbol. MS__ Middle of bat symbol. RS Right bat end symbol. SS___ Side wall symbol.

WS _ Top wall symbol.

10 PRINTCHR$ (6) CHRE (17) 2G0TO909

FO AF=KEYS: IFAS=CHRE (6) THENM=- 1

25 IFa#=" "THENW=0

3G ITFA#=CHRE (9) THENM=1

40 NP=MP+M: TFNPS =BLORNP 2=BRRORFEER (NP +e) =BSORNF =MFTHENSS

50 FOREMP-M,32:MF=NP:POREMP-1,LS:PGRENP, MS: POR EMF+i,&5

55 PLOTZ7,24,57TR#(CH:

60 NB=BF+BM

65 PR=PEEK (NB): TFPB=CSTHENCH=CHF1

70 TFPBR=320RFB=CSTHENISG

80 [FPR=WSTHENBM=BM+L2:FLAY3,0,1,100:50UND3,1 0,0:G0T060

90 TFPB=SSTHENBN=L2*(BM/ ABS (BM? -BMEFLATS,G,1, 100:;50UND3,100,0:G0T040

110 TFRND(i)<.G5GRNB=BLORNB=BRTHENBM=-8N: 60706 is)

120 PING: BN=BM-L2: IFFR=MSTHEN6O

130 NB=BP+BM+i: IFFR=LSTHENNB=NB-Z

i4d 607065

{50 POREBF,32: RP=NB: [FRF< BLANDCH< CTTHENFGOREBP, BS:GOTQz0

load TFCH=CTTHENT9O

170 PLAY?7,0,1,1000:FORG=1TO019: SOUNDS, 0,0: NEXT

37

The Atmos Book of Games

175 BC=BCt+i: TFBC?BRTTHENIG

180 WAIT (200): BM=-LL+i: [FRND(1) >. 5THENBM=BM-2 185 FLOTI2,24,STRE(BC): BP=(BL-LLI+INT(RND Ci) ¥ OT-3)42):FO0KERBF, BS: 607020

1970 WAIT (S00)}:CLS:TFCH=CTTHENFRINT"tou got the m alii ":END

200 FRINT"You hit ":CHs" crosses aitogether."” 216 END

900 TL=fBBD2: TR=£BBFS: BL=£RECA: BR=fBEED: LL=4o 910 CS=43:B5=91:LS=92:N5=93:R5=94:95=95: W5=F6 915 FORZ=91 7096: GOSUBZ000: NEXT

920 CH=O:BC=0:BT=3:CT=0

950 DT=TR-TL:DL=BL-TL:LZ=LL#¥2:S5P=TL+LL +i: EP=8i -LZtl

G60 CLO:FRINT"Do you want instructians (Y/N) "; 965 INFUTA#: IFA="¥" THENGOSUBSO0G: GOTOLG0G

780 GOSUBSOS0

1O0G CLS:INE1L:FAPER?7

1id0 FORA=TLTOTR: FOREA,WS:NEXTA

1105 FORA=TLTGBL-LLSTEPLL: POKEA,SS:FOKREA+DT ,5S :NEXTA

{ila A=SP:B=SP+OT:Ex=-1

112¢ CP=CT+1:POREA,CS:A=At+2: [FREER (A) =32ANDPEE K(A-1)=S32THENI120

LiS0 EX=-Ex:A=SP+EX+L2:5F=A: B=At+DT: IFAS EPTHENL L2u

1i40 MPSBL+INT(OT/2):POQKEMP-1,0L5:FOREMP, MSs POR EMP+1,R5

1150 PLOTS, 24,"BALL:":FPLOTI2, 24,57R# (BC): PLOTI 9,24, "SCORE: ":GOTOGL75

2000 £¥=46080+Z2#8: FORGH=KXTGXX+7:READU: FOKEG,U: Ne): RETURS:

sGd0 CLO:PRINT In Wipeout you must try to wipe "ITPRINT out as many targets as you can"

sacs FRINT"by bouncing a ball onto them. your” :PRINT“bat moves along the bottom of”

S010 FRINT’the screen - its left side will “:PR INT"detiect a bail to the left and its"

S020 FRINT'right side detlects toe the right." PRIN? any ball missed is lost, and you"

38

Wipeout

5025 PRINT"have "“:BTs? balis to try and hit":F RINT*all the targets with."

5050 FRINT:PRINT“Controls ~- use the cursor key s to":FPRINT"move the bat ieft or right."

5055 FRINT"Press the space bar to stop the bat "SPRINT" from moving."

5040 FRINT"Press any key to begin. ": REPEAT: A#= KEY#:UNTILASS "RETURN

39

Zombies

This program turns up in many guises: the idea is that the player seeks to evade some extremely stupid pursuers by luring them into traps. In some variations, the pursuers are robots, destroyed if they strike electrified posts scattered randomly around. Here the enemies are blind, flesh-eating zombies, who can be eliminated by making them fall down potholes. Another version has the player as a swimmer fleeing sharks. The latter die if they hit each other or any of the jellyfish that float around. The pattern is clearly the same, so if the zombies do not appeal, define a few characters of your own and change the program to one of the other versions.

40

Zombies

Zombies is an enjoyable game to play, as it can either be played as a game of skill, or, with minor amendments, as a game of fast reflexes. As set up at present, the zombies will only move after the player has made a move by inputting a value at the keyboard, lines 20-100. Changing the GETA$ in 20 to A$=KEY$ and eliminating the REPEAT in 20 and deleting 100 means that the zombies will now move without waiting for a keyboard input. You will need to add: 105 IIMD>7THEN140.

One thing that confuses many people in this game is the zombie movement. Zombies always move towards you. This does not necessarily mean that they move in the same direction as you have just moved. They move so as to minimise the distance between you and them. This sometimes involves moving in the same direction, but on other occasions the zombie will move differently. After you have played a few games it will become easier to trap zombies in potholes as you will be able to tell in which direction they are going to move. Then is the time to try a higher skill level . . . or move on to the real-time game!

Program notes

10 Keyboard click and cursor off. 20-100 Keyboard controls.

115-130 Player move routine. 110 erases the player’s symbol from its old position and finds the new position. 115 checks if this position is a pothole, and 120 checks if it is a zombie. 130 pokes the player’s symbol to the new position.

140-255 Zombie move routine. 140 finds the player’s co-ordinates relative to BL. 150 picks out each zombie position from the array Z(_ ), and checks if that position is empty or a pothole. In either case the zombie has been killed and can no longer move. 160 finds the zombies’ co-ordinates relative to BL, and these co-ordinates are compared to those for the player so that the program can decide which x and y axis movements the zombies should make to bring them closer to the player, lines 170-200. 210 erases the zombie from its old position and examines the new position. 220 checks for a pothole, 230 checks if the new position is that of the player, and 240 ensures that if there is already a zombie at the new position, the other zombie does not move on top of it. 250 pokes

41

The Atmos Book of Games

the zombie to its new position, and 255 completes the loop.

260-310 Game end routine. 260 checks if all the zombies are dead. If not, provided the player is not dead, the game continues, 270. 275-310 comment on your fate and give the score.

900-950 Initialisation routine.

960-1190 Game set-up routine. 1100 and 1105 put potholes all around the screen edge. 1120-1145 poke potholes or zombies at positions depending on the outcome of RND. 1150 chooses a random position on the main diagonal for the player’s symbol, 1155 ensures there is not a zombie at that position, and 1160-1180 clear the surrounding area of the beasts. 1190 pokes the player’s symbol on-screen and the game begins.

2000-2010 User defined character creation routine. 3000-3020 Routine used when player falls down pothole.

5000 onwards instructions and setting of skill level.

Important variables

CP Chance of pothole as these are poked at start. CZ Chance of zombie as these are poked at start.

EP _ End position as potholes and zombies are poked to the screen.

MD_ My direction used to pick movement from array D( ). MK _ Man killed flag set to 1 to show death.

MP My position.

MX Myxcoordinate relative to BL.

MY Myycoordinate relative to BL.

MZ Maximum number of zombies at particular skill level. NP Mynew position.

NZ Number of zombies present in game.

R Random number less than 1.

SL Skilllevel.

42

Or XM YM ZK ZN ZP ZX ZY

Zombies Start position for poking potholes, zombies. Z movement for zombie. Y movement for zombie. Number of zombies killed. New zombie position. Present zombie position. Zombie x coordinate relative to BL.

Zombie y coordinate relative to BL.

Symbols used

MS PS ZS

5 R 10 20 30 40 90 60 70 80 90 100 110 115 120 130 140 150 =FS 140 179 180 190

My symbol. Pothole symbol.

Zombie symbol.

EM ZOMBIES

PRINTCHR$ (6) CHRE (17) :G0TO9900

REPEAT: MD=8:GETA#: IFAS="W" THENMD=0 IFAS="E"THENMD=1

IFAS="D"THENMD=2

IFAS="C"THENMD=3

IFAS="X"THENND=4

IFA#="Z"THENMD=S5

IFAS="A" THENND=6

IFA$="Q" THENMD=7

UNTILMD<8 POKEMP,32:NF=MP+D (MD): P=PEER NF) IFP=FSTHENGOSUBS000; GOTOETO IFP=ZSTHEN280

MP=NF:FORKEMP MS MY=INT((BL-MP)/LL) +12 MX=MP-BLIMY ALL FORZ=1LTONZ: ZP=Z(Z2)3:P2=PEER (ZPi: TFPZS320RF2

THENZ55 ZY=INT(CBL-ZP)/LL) +1: Z2X=ZP-BLt+ZyY#LL XM=O: TFZXSMKATHENXN=1 IFZX3MXTHENXM=-1 YM=OrTPZY<MYTHENYM=-LL

43

The Atmos Book of Games

Z00 TFZY>MYTHENYM=LE

210 ZN=ZF+XM+YMN: F=PEER (ZN): FOREZP, 32

220 I[FP=PSTHENZK=ZE+1:72(Z2)=2N:G0T0255

250 [TFP=MSTHENME=1

240 IFF=ZSTHENZN=ZP

245 SOUNDL,Z#10,0:FLAY1,9,4, (ABS (ZX-MX))

250 Z(Z)=2N: PQREZN,Z5

ggg NEAT

260 IFZK=NZTHENPLOT2,24,"Well done! There are no zombies left! "*:G0TOQ285

265 S#="Zombies killed = “+57R#(ZE):PLOTS8, 24,5

Ey

270 FLAYG,0, 0,02 TFMR=OTHENZO

273 PLOTS, 24, "The zombie crunches you up. ":S0u

NDS5S,100,0;PLAYO,1,4,100

280 WAIT(Z00) :FLAYG,9,0,0

285 WAIT (600)

290 CLO:PRINT" You killed “y;Zky;" zombies out of "INZ

300 PRINT"This is a success rate of "SINT(iO0#8

ZE/NZi3" percent”

305 PRINT®at skill level "sSL

316 END

SOG OIMZ(30):TL=£BRBD2: TRELRBFS: BL=£BECA: BR=LERKE

EC:LL=46

“910 MS=94:F5=95:728=96

915 Z=MS:GOSUBZ000: Z=PS:GOSUBZ000:; 2=75:G05U820

ag

920 TR=O:MR=O:MZ2=350:CF=,

930 D(O)S-LL:Dli=-LL+l: ae pei: D(S)=LL+l

G40 Di4)=Lbi0(S)=LL-1:D0(6)=-i:D(7)=-LL-1

950 DT=TR-TL:DL=BL-TL:SP=TL+Li +i: EP=BR-LL-1:B=

SF

Fou CLS:FRINT"Do you want instructions (ys) ";

965 INFUTA#: IFAF="Y¥"THENGOSUBSO0G: GGTOLOGeG

9680 GO5UB5050

1000 CLS: INE4:FAFERS

1i00 FORA=TLTOTR: PORKEA,FS:FOREA+DL, PS:NEST 1105 FORA=TLTGBLSTEPLL: FORER,PS:FOREA+OT PS: NE

KT 1120 FORA=BTOB+DT-2:R=RND (1) + [FRCP THENPOREA,F 1130 TER<CZANDReUFANDNZ\MZTHENNZ=NZ4+1:Z2¢NZ) =A:

POREA,ZS

44

Zombies

1i4S WEaT:B=8+ Li: (FB. EPTHEN IIo

{150 MPSSP+D (CS) #INTCRND GL) alae:

1155 IFPEER (MP) =ZSTHENLISO

Li6G FORDSOTO7:PP=MP+O (NO? : TFPEER PRO SZSTHENTZE

=Zik +1

1180 POREPP, 32: NEXT

Lif PORENP.MS:G0T026

2000 XX=GhGG0+Z2 "Bs FORG=XXTOXR+ 7: READU:POREO, Us

NEXT: RETURN

2010 ee ee (oa sscl B,12,9,4,14,21, 51,17 31.21.28

S000 FPLOTB,24,"You fail ae a pothole, BO1G FORG=1TO100:; SGUNDi,G,4:NEaT: EXPLODE S020 PLAYG,O,0,0:WAIT (S00) :RETURN

S000 CLS:FRINT" You are trapped on Zombie islan

d":FRINT' which 1s full of deep potholes,

S PRINT The zombies on the island want tao": PRINT“ eat you, and aithough they are"

SO1G FRINT"blind when vou move they will hear" :PRINT" you and rush towards you. If

S0iS FRINT* are careful you can make the ":FRIN T* zombies fall into the potholes. [¢f"

SGZ0 PRINT" you fail you will be eaten. ":FRING: FRINT'Controls - use the keys around the”

S025 PRINT"S key to move. ":PRINT:FRINTSPOC (Lei: "G W E"SPRINTSPOCL7)3"A S DOT SPRINTSPO(18)3°2 & ce

S650 PRINT: PRINT" Input your skill level, 1, ea sy, to 10, difticult";

5060 [NPUTSL: TFSL<10RSL210THENSOS0

S070 CZ=CF+SL#. G08: RETURN

45

Artificial Intelligence Program

ae lof oe oe a Fe he ks ler a |

pe Se

One of the great pleasures of computing is that the computer can be a ready made opponent in any number of different games. It is a real challenge to develop a program which enables the machine to play a game in an intelligent manner. The real test is if the program is good enough to beat its creator, and the program that follows has passed that test many a time!

In essence the game is the familiar noughts and crosses, but it is made much more challenging by being played on a 4 by 4 by 4 cube, the object being to get a straight line of four Os or four Xs in any direction:

46

Artificial Intelligence Program

A winning line when playing noughts and crosses on a 4 by 4 by 4 cube.

It would obviously be difficult to show the cube on-screen, and even more difficult to show the moves clearly, so the cube is ‘sliced’ into four sections, and these are displayed side by side. It is important to remember when playing the game that these sections are actually on top of each other, and the following diagram gives an example of a line of Xs which goes through all four sections:

Representation of the cube on-screen, showing a winning line of Xs.

If this is hard to understand, try to imagine the four sections piled on top of each other from left to right: the Xs then form a vertical line through the cube.

The method by which the program chooses its move is a complex one, but in outline the procedure is as follows.

47

The Atmos Book of Games

You make a move. The computer finds all the possible straight lines passing through the position where you have just moved. It then examines all those lines to find out the situation in each line: for example, your move might have created XXX. in one line and OX.O in another.

Every type of line has been given a value at the start of the program. XXX. would have a high value, because unless the computer stops you, you are going to win next move! The computer keeps a running total stored for every position in the cube, and it now adds the line value to the running totals for every position in the line. The running totals for all the positions which make up XXX. would now be very high, because a large value would have been added to each of them. On the other hand, the computer would rate a line like OX.O as one of little value, because neither side can make a line of four on that line. Consequently, the computer would only add a small amount to the running totals for each of these positions.

Once the computer has found all the lines affected by your move and changed all the running totals it is now ready to make its own move. It does this by looking through the running totals for every position on the cube, and picking for its move the poition with the highest running total. Any position with a high total must be on several valuable lines, for example O.OO or XXX. or perhaps at a point where two lines like OO.. cross and a single move will make both lines into OOO.

Basically, the computer chooses as its move the position which at the same time lies on several lines where it has already placed a O, and/or also lies on lines which contain several Xs. The program can be beaten, but you'll have to play very well to do it!

Program notes

10 Keyboard click and cursor off.

20-100 Move input routine. 70 allows you to delete a move if you change your mind, 80 checks that the move is legal.

105-150 Computer move routine. The move is selected as described above.

130 counts the moves in twos (for one O and one X), and 140 48

Artificial Intelligence Program

checks if move 64 has been reached, in which case the game is drawn.

200-320 Board draw routines. Each position in the cube is stored in the array C(A,B,C), positions with a value of 1 being empty, 2 being O, and 3 being X. 300-320 checks each of the array values and plots a ., O, or X in the appropriate position.

400-540 Line check routine. This finds which of the 13 lines which pass through the cube the move position lies on.

600-630 Highest total routine. The computer examines the running total for every position in the cube, and saves the highest total in H and the coordinates of that position in Al, B1 and Cl, line 620. These become the coordinates of the computer’s move, 630.

700-950 Line value routine. Once a line has been found in routine 400, the computer works out the situation on that line and adds an appropriate value to the running total for every position on the line.

1000-1050 Valuation routine. Once the type of line has been found, this supplies a suitable valuation of the situation in that line.

1100-1210 Congratulatory messages for the winner. 1800-1820 Erases abandoned or illegal moves. 1900-1980 Initialisation routine.

5000 onwards instructions.

Important variables

A$ Player’s move as a string.

C(_) Information on all positions within cube: values of 1 indicate an empty position, 2,aO, and 3,a X.

CO Count for player’s moves as they are input.

F Flag. When set to 0, sub-routine 700 multiplies together all the C(_) values in a row to find the current line situation. With F set to 1, sub-routine 700 adds the value for that line

49

The Atmos Book of Games

IL

L( )

10 20

Zc

situation to the running totals for every position held in V( ).

Line situation found by multiplying all C(_) values fora line.

Highest running total for a position.

Illegal move an attempt to move into an already occupied position.

Line number situations. G is compared to these, and when a matching situation is found, the value of that line is given by the array value P( ).

Move counter. Points for a particular line situation.

Running totals for all positions in cube.

FRINTCHR# (6) CHR$(17):G60TOS000 PLOTi1,14,"Type in your move" FLOTI3,18,"PLANE:":PLOT13,20,"ROW: ":PLOT13,

22,"COLUMN: "

30 Ag 40

59

CO=1L:K(1)=0:K (2) =0:K (3) =0: REPEAT: REPEAT: GET

UNTILAS="1"ORAS="2"ORAS="3"ORAS="4"QRAS="D" IF (A$<>"D") THENK (CO) =VAL (A$) :PLOT21,16+2#CO

,A$:CO=CO+l

40 70 80

020

90 100

UNTILCOG=40RA#="D" IFAS="D"THENGOSUBI800: GOTO20 IFC(K (1) RE (2) R13) ) FLTHENTIL=1:G0SUB1800:G0T

PING A=K(1):B=K(2):C=K(3):0(A,B,C) =3: GOSUB400: 60S

UB390:GOSUB600: GOSUB1800

110 120

FLOT11,16,"My move is:" PLOT13,18,"PLANE: ":PLOT13,20,"ROW:":PLOTI3,2

2,"COLUMN: "

125

PLOT21,18,STR#(A) :PLOT21,20,STR$(B):PLOT21,2

2,STR#(C)

30

“149

50

M=M+2:C0(8,B,C)=2:GOSUB400: GOSUB300 IFM=44THENGOSUB29000: END

Artificial Intelligence Program

150 PING: GOSUBI800:G0TOZ0 200 PLOT1,2,"1 2 3 4 1234 tea 4 i 2 5.4" 2iG FORB=iT04:FORA=1T04:FORC=i1TO4 220 GOSUBI00 240 NEXT: NEXT: NEXT 250 PLOT@,24,"Press D to deiete move" :RETURN SOQ X=C(A-i)#104+24C-1:Y=2e(B+l jp: PF=". "2 CiaC (A, ,C)sTFCL=ZTHENFS="0" 210 TFCL=3THENP$="X" 320 PLOTX,Y,F$:RETURN 40G FORV=iT03:GOSUB700: NEXT 410 IFAs *BANDB* +CANDAé CTHEN4SG 420 IFA=BTHENV=4: GOSUB7GO 430 ITFA=CTHENV=5: GOSUB796 440 TFB=CTHENV=6: GOSUB7OG 450 IFAs >5-BANDAs +5-CANDBs 2S-CTHENSSG 460 IFA=S5-BTHENV=7: GOSUB?7O0 470 IFA=S-CTHENV=8; BOSUB700 480 ITFB=S-CTHENV=9: GOSUB700 490 [FA=BANDA=5-CTHENV=10: G05UB700 S00 [FA=CANDA=S-RTHENV=i1:505UB700 Sid TFA=5-CANDB=CTHENV=12: GOSUB7I0 S30 IFA=BANDB=CTHENY=13:G0S5UB700 540 RETURN 600 H=0:FORA=1704:FORB=1T04:FORC=i1704 610 J=ViA,B Cir TFC(A, B,C} si ORG2HTHENAS0 620 ITF JSHGR GI=HIANDRND (i) >. 5THENH=J:A15A: B1=8: ciac 630 NEXT: NEXT:NEXT:A=Al:B=8i:C=C1l: RETURN 7OO FORT=1TO4:A1=A: BL=B: CL=C: ONVGGSUB8S0,869,8 70 765 [FV<4THEN720 710 ALST:ONV-23G05UB860,870,880,890, 700,910, 720 730,946,959 PO TFFS=1THENViAL, BL, CLiaV(ALL BL, Ciit+2 IFFOTHENG=B4C (Al, BiL.Ci) NEXT: (FPSGTHENF a1: GO5UBi9Ga:G0TO7o0 FeO ;RETURN Ai=T:RETURN ) BisT: RETURN i C1=T: RETURN Al=A:BisT:Cist: RETURN 1 BLSS-T: RETURN

oO CO Oo ht a mot oO Lh on

Pasa

om

51

The Atmos Book of Games

FOG CLsa-T:RETURK

Jit: AL=A:BL=aT:CisS-TsRETUR

F290 BLST:Ci=S-T:RETURN

S30 BlSS5-TiCl=T:RETURN

540 Biss-T:Cis=S-T:RETURN

F5t BlaT:Ci1=T: RETURN

GOGO TFG=L&éTHENGOSUBS50: GOSUBLi90: END TFO=8)THENGOSUBSO0: GOSUB1 2600: END IF (G=6) ANDC{A, B,C) =ZTHENZ=-10:G=1:RETURN TFo/C(A,8, Ci=6THENZ=0:G=1: RETURN

i040 FORN=LTO9: IFG=L(N) THENZ=F (N) 1050 NEAT:G=1: RETURN Lida GOSUBISGO:FORX=1TOSOSTEP7: FORY=16TG245TEF

L120 FLOTA,¥,"i WIN! "“SNEXTSNEXTSEXPLODE: RETUR

1200 GOSUBIBQ0:FORK=1TOSOSTEPS: FORY=147TO24S5TEF 2rPLOTX,¥,"¥GU WI! *

{210 NEXT: NEXT:EXPLODE: RETURN

1800 IFIL=1THENIL=0:PLOT11,146,"ALREADY OCCUPI

ED "s SHOOT: WAIT (S500) 18i0 FLOT13,16," "sPLO 721,18," "PLOT? pies E 7

1820 PLOT21,22,"

1830 RETURN

1900 DIMC(4,4,4) ,V(4,4,4)

1910 G=1:FORA=17T04:FORB=17T04: FORC=1T04

1920 V=0: IFA=BANDA=CTHENV=10

1930 IFA=CANDA=S-RBTHENV=10

1940 IFA=5-CANDB=CTHENV=10

1950 IFA=BANDA=S-CTHENV=10

1960 V(A,B,C)=ViC(A,B,C)=LeNEXT: NEXT: NEXT

1970 FORN=1T09:READL(N) ,F(N) NEXT: CLS: GOSUB200

:GOTO20

1980 DATAZ,19,2,14,9,98,4,100,27,700,8,1000,4,

-14,18,-98,12,-100

5000 CLs: INK7: PAFERO:PRINTSPC(13);"3D Os and X :PRINTSPC (13); "s==sss==="

$010 FRINT:PRINT"In this game you must try to

get":PRINT"4 Xs in a line to win."

5020 FRINT"The game is played on a 4x4x4 cube"

:PRINT"“and each plane of the cube is"

5030 FRINT"shown on the screen. To type in":PR

INT"a move, you must type first the"

52

Artificial Intelligence Program

5040 PRINT"PLANE, then the ROW, and finaliy":F RINT"the COLUMN where you want to"

5050 PRINT"place vour G. Tf you change your":F RINT"mind about a move, press D0 for"

5060 PRINT*DELETE. There will be a pause":FRIN T'of a few seconds after your move”

su70 FRINT"before GRIC makes its reply.”

50680 PRINT"Good luck - you'll need iti ":FRINT" Fress C to continue.”

sooo GETA#: FFAS. F "°C "THENSOTG

sido BoTO1900

53

Sheepdog Trial

This program is based (not surprisingly) on a sheepdog trial. The sheep move at random until the dog gets within a certain distance: from then on the sheep always move directly away from the dog. You must use your dog to guide the sheep into the pen within a time limit.

If the sheep are allowed to wonder completely at random throughout the field, they can end up against a fence or jammed into a corner. As the sheep move away from any nearby dog, the player would have no choice but to retire his canine counterpart to some distance from the sheep, and hope that random movement will at some point bring the sheep out into a position where they can once more be herded.

54

Sheepdog Trial

The program therefore ensures that the sheep move no closer than one character position from the fence surrounding the field. It is then always possible for a dog to get ‘behind’ the sheep and herd them.

It is very difficult to herd more than two or three sheep into the pen. The captive sheep seem to possess an irresistable urge to wander back out of the pen just as your dog rounds up another!

The game is easily converted to run in real time by omitting the REPEAT from line 20 and changing line 100 to IFDD>8THEN140. Line 110 provides the shepherd’s whistle as the dog is instructed to move in different directions. If this proves too irritating, just omit the line!

Program notes

10 Keyboard click and cursor off.

15-140 Dog move routine. The dog moves faster than the sheep: this is achieved by enabling the dog to move two or three times when the sheep only move once, and is the reason for the loop running from 15-140. The keyboard control routine runs from 20-100, 105 makes the dog face right or left according to its movement, 110 gives the shepherd’s whistle, varying slightly for different directions of movement. 120 checks that the dog’s new position is not occupied, and 130 moves the dog.

150-220 Sheep move routine. 150 finds the dog’s x and y co- ordinates relative to BL, and 160 does similarly for the sheep. 165 finds the sheep’s distance from the dog in terms of x and y displacement, and if the sheep are out of range they move randomly. Otherwise 170-180 find the appropriate movement which will take the sheep directly away from the dog. 185-190 find the random movement for sheep out of range, and 200 checks the new position for all sheep to make sure that the new position is unoccupied and not adjacent to a fence. 210 moves the sheep and 220 completes the loop.

230-270 Lines 230-250 check the pen to see if all the sheep are in yet. If not, and the time has not run out, the dog has another chance to move, 260. When the time runs out 270 checks if all the sheep have been rounded up.

3D

The Atmos Book of Games

280-440 Any dog rounding up all the sheep within the time limit is congratulated, 280. Other dogs are disqualified, 300-310. 350 saves the number of the best dog and its time. If all the dogs have taken part, 370, the winner is announced at 400. Otherwise the next dog is called to the field, 380. If no dog rounded up all the sheep, the game finishes with an abusive message, 410-420. 900-950 Initialisation routine.

960-1180 Game start routine. 1050-1090 draw the fence around the field and the pen fence. 1110-1150 randomly position the sheep within the field, 1115-1120 making sure they are away from the fence, and 1130-1140 ensuring they are not placed in the pen. 1150 pokes the sheep into their selected positions. 1160 chooses a random position for the dog, 1165 keeping it out of the pen, and 1170 ensuring the position isn’t already occupied. 1180 pokes the dog to the screen.

2000-2020 User defined character routine.

5000 onwards instructions, selection of number of sheep to be rounded up during the trials.

Important variables

BC Bottom corner inside pen.

BD Number of best dog in competition. BT Time for best dog.

DC Dog count gives dog number.

DD Dog direction of movement: used to select movement from array D( ).

DN Dog number— how many there are in the competition. DP __ Dog position on-screen.

DR Dog rounding-up distance. Sheep further away than this move randomly.

DV ___ Dog velocity. High values of DV mean the dog moves many times every time sheep move once.

DX Dog x coordinate relative to BL. 56

Sheepdog Trial

DY Dog y coordinate relative to BL.

LB Left bottom pen corner.

LT Left top pen corner.

ND New dog position.

PL Distance along left side of pen.

PT Distance along pen top.

SD Sheep direction of movement: used to select movement from D( ).

SN Sheep new position.

SP Sheep present position.

SR = Number of sheep rounded up so far.

ST Total number of sheep to be rounded up.

SX Sheep x coordinate relative to BL.

SY Sheep y coordinate relative to BL.

TC Top corner inside pen.

X1 Xcoordinate difference between dog and sheep.

XN X movement when sheep is within dog rounding-up range.

Y1 —_ Y coordinate difference between dog and sheep.

YM Y movement when sheep is within dog rounding-up range.

Symbols used

DS Dog symbol, either facing left or right.

FS Fence symbol.

PS Pensymbol.

SS Sheep symbol.

57

The Atmos Book of Games

iG PRINTCHRE (4) CHRE(171:5070900

15 FORD=1TODYV

20 REPEAT: DU=8:GETAS: IFAS="W"THENDD=0

30 TFAS="E"THENDG=1

4G [TFA="D"THENDO=2

a0 LFAF="C*THENDD=3

60 IFAS="K" THENDD=4

70 TFAS="Z"THENDD=5

BO IFA$="A"THENDO=6

90 TFA#="G"THENDD=7

95 TaT+is TH=STRE(TISPLOT22,25,74¢

100 UNTILDD<6

105 DS5=91: TF DD<4THENDS=95

110 FORG=iTG3:FORU=DDTO30: SOUNDI ,U,S:NEXT: NEXT :SGUND1,0,G

120 ND=DF+D (DD): TFREER (ND) © s32THENL 4G

120 POREDF,32:0F=ND:FPOREDF,0S5

140-NEXT

150 DY=INTCCBL-DP) /LiLi+1: DX=DP-BL+DY#LL

160 FORS=1TOGST:SP=S(S):SV=INT(CBL-SPi/LLI+i:sk =SPF-BL+SY#Lb

165 YL=S¥-Oy:k1=SX-Dk: TFABS (V1) sDRORABRS (KI) DR THENIGS

170 KM=O: TFAL4 sOTHENXM=X1/ABS(X1)

175 YM=Or:TFY1l< sOTHENYM=YL/ABS(Y1)

180 SN=SP+XKM-YM#LL: SA=SN+XMN-YMELL: GOTOZ00

L8S SD=INTIRND CL) #t 2): TF SOs? THENZ 20

170 SN=5F+0(50):5A=5N+0(50)

200 TFRPEER (SN) < 23 20RPEER (SA) =FSTHENZ ZC

210 PORESP,32:5(95)=SN:POKESN,SS5

) NEXT

i SREQ:R=LT+LL +i: C=BR+PT-2 FORA=BTOC: IFFEEK (A) =SSTHENSR=SR+1

200 NEXT: B=B+LL: TFBCLRTHENZ40

260 IF¢(TA TEI AND(SR¢ST) THENIS

270 ITFSReSTTHENSO0

280 CLS:PRINTD#(DC);" rounded up ";5T:" sheep in time "3T

290 6670350

S00 PRINTD#(0C);" is disqualified."

2iQ PRINT"With his timing he d be no good as a "SPRINT watchdog.

350 [TFT< BTTHENBT=T: BD=0C

370 WATT (200): IFDC=ONTHEN4OG

58

Sheepdog Trial

380 FRINT:FRINT:PRINT"The next dog should now proceed to":FRINT"the field."“:G0TO1040

400 TFET TETHEN4 30

410 CLS:PRINT"These ";DN;" dogs were of such": PRINT“poor quality that no rosettes"

420 PRINT"can be awarded. ":END

430 PRINT"The winner was ";D#(RD)3;" in time “3; RT

440 END

900 TL=£BBRD2: TRe£BBFS: BL=£BECA: RR=LBEED: LL =40 905 LCTSTLt+374:RTHLT +S

910 OS91:FS=o2:P5=93:55=94

915 FORZ=9iTO9S: GOSUBZO0G: NEXT

y20 DCsO:DVe2:TESZ00:; RT=TE: DR=2:RD=0:08¢RD) ="

PAG Didss-lirBilss-LbLti:1 di 21:03) = Le +1

740 G44 SLL GsSietL~-i:b¢es-i: hiv i =-LL-i 950 OT=TR-TL:DL=BL-TL:LB=LT+3# Loi PTaRT-LTs PLease B-LT 960 CLSO:PRINT"Do you want instructions (y/Hi"; S65 [NPUTAS: TFAF="F"THENGGSUBSO9G: GOTO19040 S60 SO5UB5050 1640 T=a:;DCHDC+1i: PRINT "What 1s this dog s name “sr TNPUTDS (DC: i045 CLS: INRG:PAPERZ 1050 FORA=TLTGTR:FOGREA,FS:FPOREA+DL,FS:NEXTA 1o60 FORA=TLTGBLSTEPLL: FOREA,FS:FOREA+DT,FS:NE ATA 1o80 FORASLTTORT:POREA,PS:POREA+PL,PS:NEATA 1O90 FORA=LTTOLBSTEPLL:FOKEA,PS:FOREA+PT ,PS:NE ATA 1095 FPLOTO,23,1:PLOT1,23, "BEST OF (ED) i096 FPLOT23,23, "BEST TINE: “:88=STRECBTISPLOTS4 yin, BF 1097 TaOrPLOTI6,25,°7iMEs " 100 A=LT+INT CPT’ 2) :FGREAR, 32 L105 TCHLT+ iL +i: BCL B-LL+ti rs DLSOL iL L116 FORS=iTG57 L115 CHOrSeaCNTCRND (Lie (DT-3) 7 :S¥=INTCRND (Lie DL-3)) 1iZ0 SF=BL+Sk-cSY#Lit+2e (LL-1) 3: TF PEER (SP) < e32T HENLILS 1130 [TFSP=TC+CORSP=BCH+CTHENIIGS

OGG: "sPLOT11,23

59

The Atmos Book of Games

bi40 CeC+i:LFCiF S5:5 (

ce 1150 FOKESF.SS: i160 DX=INTCRN P=BLt+DxX-DY*LL 11465 TF CDPSLTIAND(DP¢LB} THENIi40 1i70 IFFEEK (OP) < s32THENI 160 1189 FOREDP,DOS:BL=DL#LL:G0TO015 2000 XX=460604+Z248:FORG=KXTOXK+7: READU: FOREQ,U: NEXT:RETURN 2010 DATAO,9,16,49,17,31,17,17,168,18,63,18,18, 63,18,18,0,9,63,18,12,12,18,63 2020 *ATAG,12,18,33,18,12,18,9,0,0,2,3,34,62,3 4,44 soo0 CLS:FRINT"In Sheepdog Trial your dog must "SPRINT"round up sheep within the time" SO1G PRINT"Limit. When your dog gets":PRINT"cl ose”to the sheep they will" S020 PRINT*move away and can be herded into":F RINT®the pen." S030 PRINT: PRINT"Controls: use the keys around

the S:" S040 PRINTSFC(16)3"G W E"SPRINTSPC(1i7);"A 5S rPRINTSPCCLBis "2 X C* S050 PRINT:FRINT"How many dogs are taking part (1-9) "9: INFUTDN

5G55 IFDN¢ LORDNS9THENSOSO s06G PRINT"Total number of sheep to be rounded “SPRINT"up, trom i to 9"3: INPUTST s065 TFST<LORSTs9THENSOAO s070 TE=TE+5T#40: RETURN

iTHENLI 3G }=SP:NEXTS #OT+i) 2 DY=INTCRND CL} ¥DL+i3:0

60

Adder

In this game you control a tank which moves continuously around a rectangular playing area. Every time the tank hits one of the numbers dotted about the screen, that value is added to your score.

Sometimes in a game it is useful to have a shape whose direction of movement is clear from the way the shape looks. Common characters like this include arrows, spaceships, and, of course, tanks.

It is difficult to create 8 distinctive tank shapes on the Oric

61

The Atmos Book of Games

because a 6 by 8 matrix is used, so in this game a tank is constructed from two individual symbols.

Each tank consists of a tank body, which is a ‘block’, and a tank gun. The gun symbols are stored in an array G( ). They just consist of single lines, with each line corresponding to an array value D(_ ). So if the tank is to move up the screen, its movement is given by D(0) and the tank gun G(0) is a vertical line which will be poked above the tank body. Similarly, D(3) indicates movement east, so G(3) is a horizontal line which will be poked east of the tank body. This is why the array values for G(_) in lines 910 and 915 repeat the same line is used in two different positions to indicate a gun, the only difference being that it is poked onto a different side of the tank body in each case.

It is now easy to rotate the tank. To rotate clockwise the old gun is erased, 1 is added to the array values D( ) and G( ), and the new gun symbol G( ) is poked onto the tank body in the correct position by using D( ). Rotating anticlockwise is a similar process, except 1 is subtracted from the array values. In both cases checks must be made to ensure that the array value has not gone out of bounds.

Only three keys are needed to control the tank: one to move it, and the other two to rotate it clockwise or anticlockwise respectively. The resulting routines can be used in a variety of games, from tank battles to racing games where it is important to know which way you’re going!

In the game that follows the tank moves automatically because this was found to be much faster than putting its movement under keyboard control. The player therefore can only control rotation of the tank, although it can be stopped by running it into a wall!

Program notes 10 Keyboard click and cursor off.

20-40 Number poke routine. 20 selects a random position on screen where the number will be poked, 30 checks the position is empty, and 40 pokes the number there.

50-80 Keyboard controls to check for tank rotation. 80 checks to see if there has been no direction change in which case the next section is omitted.

62

Adder

90-130 Tank rotate routine. 90 and 100 ensure that the array value has not gone out of bounds, 110 calculates the new gun position and checks that it is not a wall. 120 adds the number to the score if the new position contains a number. 130 erases the old gun and then draws a new one.

150-180 Tank move routine. 150 calculates the position two steps away from the tank body in the direction of movement, and checks that the position is not a wall. 160 adds the number to the score if the new gun position contains a number. 170 erases the old tank body and draws tank at its new position. 180 calls the subroutine which pokes numbers on screen if a number has just been erased by movement or rotation.

240-265 Score and time routine.

270-360 270 averages out your score to see if you qualify for a replay. Otherwise various comments are made on your success (or lack of it).

900-955 Initialisation routine.

965-1120 Game set-up routine. 1100 and 1105 draw walls around the screen edges, 1110 pokes all the numbers from 0 to 9 into random screen positions, and 1120 pokes the tank body plus gun into its start position at top left.

200-2020 User defined character creation routine.

5000 onwards instructions.

Important variables

D Gives present direction of tank movement used to select appropriate value from array D( ).

DL Distance along left of screen.

DT _ Distance along top of screen.

N Character code for number to be poked onto screen.

ND Newdirection of tank movement.

NG New gun position after rotation or movement.

PN _ Position of number on screen.

63

The Atmos Book of Games

PP Present position of gun.

R Replay number indicates how many replays have been made.

RN _ Replay number the number of replays allowed before the game ends.

RS Replay score this must be averaged on each game to get a replay.

2 Score. Time.

TE Time end ifa replay score has not been achieved by this time the game ends.

Symbols used

NS Nine symbol character code for number nine.

OS Nought symbol character code for number zero.

TS Tank body symbol.

WS _ Wall symbol.

G(0) to G(7) Gun symbols. Each symbol is a single line, either

10 20 30 40 50 60 80 90 100 114 120 130 1590 160 170

vertical, horizontal, or diagonal.

PRINTCHR$ (6) CHR#(17):G0TO900 NX=INTCRND(L) #TD+L) sNY=INTCRND (1) *#SD+1) PN=SP+NX-NY*LL: IFPEEK (PN) < 332 THENZO FOKEPN,N: RETURN N=O:ND=D: AS=KEY#: IFAS=CHRS$ (9) THENND=Dt1 IFAS=CHR#(8) THENND=D-1

IFND=DTHENIS0

IFND>7THENND=0

IFND< OTHENND=7 NG=PP+D(ND):PG=PEEK (NG): IFPG=WSTHENIS0 TFPG< 3S2THENS=S+PG-05: N=P6

POKEPP+D(D) ,32:D=ND:POKEPP+D iD) ,G(D) NP=PP+2*D(D) :PG=PEEK (NP): IFPG=WSTHENI80O IFPG¢ >32THENS=S+PG-0S: N=PG

POKEPP, 32: PF=PF+D(D):POKEFF,TS:POKENF,G(D)

180 IFN¢ S0THENGOSUB20

240 PLOTSC-7,24, "SCORE: ":FLOTSC,24,S5TR#(5): THT +1:PLOTTI-6,24,"TIME:"

245 PLOTTI,24,STR#(T)

265 IFT< TETHENSO

270 R=R+i: 1FS/R>=RSANDRARNTHENT=0: G0T050

280 CLS: ONRGOTO2Z90,230,320, 340

290 ITFSSRS/4THEN3SO0

295 PRINT"Back to your knitting granny! ":G0TG3 50

300 IFSSRS/2THENSIGO

305 PRINT"You're no tank driver - a hearse RINT"suits you! ":GOTO350

310 IFSSRS-10OTHENS20

315 PRINT"Keep trying - that’s not too bad! ":6 OTG350

320 PRINT"Tough luck - you almost got a replay '":60TO350

330 PRINT"Well done - that’s a great score! ":6 gTO350

340 PRINT"Fantastic! Perhaps it’s even a recor qt

350 PRINT" Your score was "35

360 END

500 TL=£BBD2: TR=£BBFS: BL=£BRECA: BR=£BEEC: LL=40 905 SC=13:TI=25

910 NS=57:05=48: TS=91:WS=92:6(0)=93:6(1)=94: 6% 2)=95:6(3)=96

915 G(4)=93:6(5)=94:6(6)=95:6(7)=96

920 2=TS:GCSUB2000: Z=W5: GOSUBZO0G: FORZ=937T0%6: BOSUBZ00G; NEXTZ

925 D2: T=0:5=0:R=0; TE=400; RS=1 70; RN=4

930 D¢(GI=-LLIDCLS-LLtL (2s: DCS) =LL4l

940 D(4)=LL:D¢(S)SLL-i:B(6)=-1:D(7)5-LL-1

950 BR=BR-LL:8L=BL-LL:OT=TR-TL: DL=BL-fi: TOHbT- 1:5D=(DL-LL)/LL

955 PP=TL+LL+i:SP=BL-LL-1

960 CLS:FRINT"Do you want instructions (¥sNo"; G65 INFUTAS: TFAS="¥"THENGOSUBS00G: GGTUiGO0

960 BOSUBSGSG

{060G CLS:INKG:FAPERS

Lida FORA=TLTOTR: FPGKEA,WS:POKEAtDL ,WO:NERT 1105 FORA=TLTOBLSTEFPLL: FOREA,WS:FGREA+D7 .WS:NE XT

it ha

iP

Adder

65

The Atmos Book of Games

s 3

Lil FORN=SOGS+1T TONS: S0S5UB20:NERTNSPLAYO,1,3,80 ileo FOREPP To:ruekerrto(G: ,o.0) :GoToae

2000 Xx=do0G0+72#8:FORG=a,x TOR e+7:REAGU: POREG,U:

NEXT:RETURN

2019 DATA63,62,63,63,4

phen aleve 6. §,.8,8.8,

2020 CATAG,O,1,2,4,8,16,52,9,0,0,63,0,0,0,0,32 216,68,4,2,1,0,4

scgdad CLS:FRINT’ In this game you must try to ad

qd to"

2003 PRINT" your score by hitting numbers on"sF

RINT"screen by running into them with”

s010 PRIAHT"your tank or hitting the numbers"sP

RINT "as you swing the tank's gun."

SULS FRINT"T# you cet an average score of "3RS5 :FRIAT“in time “;TE;" you will be"

S020 FRINT"given a replay and timing will ":PRI

MT" begin again from zero. A continued®

s025 PRINT’ average of "sRS;" gives up to7:FRIN

TAM?" repiays."

s05G% PRINT:PRINT"Controls are: left cursor key to":FRINT"rotate tank anticlockwise, and"

S060 PRINT’ right cursor key to rotate it":PRIN Ticlockwise. Fress any key ta"

S070 PRINT" begin. ":REPEATZSAS=KEYS:UNTILAS C3":

RETURN

‘-

iv git + gr TR + 3,65,65,65,65,55,455,35

66

Minefield

In Minefield you have to find your way across a minefield riddled with potholes. You have a little help from your mine-detector, but its batteries are limited, so you must be decisive...

The mines on the field are randomly placed at the start, and their positions saved in the array M( ). Whenever a move is made, all nearby mine positions are examined, line 130, and checked to see if they correspond to positions directly surround- ing the little man the player controls. The number of mines around the present spot is then displayed on-screen, although the player will have no idea in which direction the mines lie.

67

The Atmos Book of Games

By comparing the number of mines surrounding one position to another adjacent spot, it is sometimes possible to deduce the mine locations. When this proves difficult, backtracking to a less dangerous path may be wisest, or you can always take the risk!

A trail of markers is left to show the safe path. Sufficiently skilled or reckless players may prefer to do without them, by changing the start of line 190 to POKEMP,32.

Program notes

10 Keyboard clock and cursor off.

20-100 Keyboard controls to move man in 8 compass directions. This loop repeats until a direction of movement is chosen.

110-190 Player move routine. 110 finds the new position, and checks if it is a pothole. Lines 130-180 check all the mine positions to see if any are adjacent to the present position, 140 counting all the mines around the new position. 170 checks in case the man has just trod on a mine, 190 pokes a safety marker to the previous position and draws the man at his new position.

200-240 200 checks if the top left has been reached, in which case the minefield has been crossed safely. 210 counts the number of times the detector has been used: it stops working after a certain period. 220 and 230 display the number of mines surrounding the present position.

260-310 Game end routine. It is always interesting to see how close to success you were, so after the explosion lines 260-280 reveal the locations of all the mines. 285 puts a marker at the last position, while 290 and 300 comment on the manner in which death came to pass.

900-955 Initialisation routine.

960-1210 Game set-up routine. 1100 and 1105 draw the edge of the minefield, while 1120-1140 randomly distribute potholes and mines about the playing area. 1170 clears away mines from the start and finish positions, otherwise it may be impossible to cross the minefield at all. 1190-1210 poke an exit at the top left of the minefield and place the man at his start position.

2000-2015 User defined character creation routine. 68

Minefield

3000-3010 Routine when man falls down pothole.

5000 onwards instructions plus setting of skill level.

Important variables

DC Detector count how many times it has been used.

DE Detector end detector gives out when DC reaches this value.

EP _ End position on minefield just in from BR. Last position at which mines can be placed.

MA _ Mines about present position their number.

MD_ My direction used to select movement from array D( ).

MM_ Maximum number of mines that can be placed on the field.

MP My position.

NM_ Number of mines count used as mines are placed at game-start.

NP New position after movement.

SP Start position on minefield just in from TL. First position mines can be placed.

PF Pothole flag. Set to 1 if a fall takes place.

PM Probability of mine used as mines are placed at game- start.

Symbols used

ES Explosion symbol.

HS Human symbol.

MS Mine symbol.

PS Pothole symbol.

SS Safety marker symbol.

10 PRINTCHRE (6) CHR# (17): 60TOF00 20 REPEAT: MD=8:GETAS: IFAS="W"THENMD=0 30 TFAS="E"THENND=1

69

The Atmos Book of Games

40 [TFAS="D"THENND=zZ

SG LFA#="C"THENMND=3

60 IFAS="X"THENMD=4

7G LFA#="2"THENMDRS

80 TFAS="A" THENMD=6

9Q TFAS="G" THENMD=7

1g0 UNTILMB<& 110 NR=MP+O(MD): TFPEER (NP) =FPSTHENPFRL: GOTOZa0 130 MA=O:;FORA=LTONM: CaN (Ars LFCANFTD (7) GRO eNP +o (3) THENI 8G

140 FORDSGTO7: TFC=NP+O (0) THENMARNA+1

159 NEXTD

170 [FC=NFTHENZ40

160 NEXTA

190 FOKEMP,55:MP=NP:POREMF,HS

200 [FMF=TL+LL+LTHENFLOTI0,24," You escape! ":B0TG260. 210 DC=DC+: >DETHENNC=SC-1:S$=" DETECTOR F

AILS ee a

220 S$=STR#(MA)

230 PLOTMC,24,S#

240 GOTO2Z0

260 FORA=1TONM: IFM(A)=-10RM(A) =NPTHEN280

270 POKEM(A) MS

280 NEXTA

285 POKEMP,SS: IFMP=TL+LL+1THEN310

290 IFPF=1THENGOSUB3000: END

400 PLOT46,24,"You stepped on 6 mine. ":PORENF,E Sr EXPLODE

SiG END

700 DIMM (20): TLSfeCAds TRAfBCBU: BL=£ BEB 4: BREERE FurLba4u

910 MS=42:HS=91irPS=92:55=93:ES=94 915 2=HS:GOSUBZ000: 2=F 5: GOSUBZO0G: 2285: GOSUBZ6

00: Z2=E5:G0SUR2000

$20 DC=0:MA=0:NM=O0:PF=E0:MM=10:FR=.07:F*=,2

930 D(G=-LLIDCLP=-LL4i:D(2)=1:0(3)=LL+1

740 OC 4=LbLeDtSs=Lb-1:0(6)=-1:1007)=-LL-1

950 GT=TR-TL:GL=BL-TL: SF=TLtLLt+i:EF=BR-LL-1:5C

=id

G35 MC=SC+id: R=SPF:s MP=EP

960 CLO:FRINT"’Do you want instructions (¥/Ne"; 965 INFUTAS: IFAS="¥"THENGOSUBSO0G: GOTOLO00

960 GOSUBRSOS0

70

Minefield

1000 CLO: INK2:FAPERO

iig@ FORA=TLTOTR:POREA,.FS:POREA+DL PS: NEXT 1105 FORA=TLTOGBLSTEPLL: POKEA,PS:FOREAtDT ,FS:NE XT

1120 FORA=BTGB+DT-2:R=RND(1):S=32: TFROPPTHENS= F5:G0T0ii140

1125 [FNN=WMTHENII4¢0

LidG ITFPRAPNTHENNM=NM+1i: MN (NM? =A

ii4d0 POREA,S:NEXT:B=B+LL:i (FB. SEPTHENLI2¢

1170 FORA={TONM:C=M( A): FORZ=0TO7: 1FC=MP+Di2)0R C=SF+D( 2) THENN (A) =-1

L180 NEXT:NEXT

1190 PLOTSC,24, "MINES PRESENT"

1200 FORETL, 32: FOQRESP,32: PORK EMF ,HS

iZiG GOTGZ290

ZOO0 XX=460G0+Z249:FORG=XXTOX A+ 7s READUS FOREGO: NEXT: RETURN

2010 DATAI4,14,4,31,4,4,10,17,12,18,33,335,18,1 2,0,0,0,48,40,36,40,48,32,32

2015 DATAZ,32,7,47,8,3,33 2016 DATA?

S000 PLOTS,24,"You fell into a pothole”

S010 FORG=1LTOL00:SOUNDL,@,4:NExTiPLAYG,0,0,0:R ETURN

S000 CLS:PRINT"You are trapped in a minetieid" rFRINT"fuléd ot potholes. Try ta"

5005 PRINT"escape through the exit at the’:FRI NI"top left. Your mine detector teils”

5010 FRINT"you how many mines are directly” S015 FRINT"around you. But its batteries":FRIN T'can run out - so be quick! When you"

S020 PRINT*move, safety markers are left": FRIN T'behind. "

S030 PRINT:PRINT"Controls - to move, press the "SPRINT“*keys surrounding the § key:"

S040 PRINT:PRINTSPC(16)3"°G WE’ SPRINTSPO.G7):" AS D":FRINTSPOCiB); "2 & C"

Su45 PRINT"To move north, for example, press’: FRINT"W."

S050 PRINT:PRINT’ Input your skill level, i ta LO, ":PRINT" 1 gives few mines, iG. many":

S060 ITNPOTSL

SO7G TFSLALORSLeLOTHENS Sou

S080 MM=MN+SL:0E=DT+ (DL LLIt5L I RETURN

71

Alien Attack

You are fighting to save earth from the alien hordes that fall from the skies. The monstrous invaders cannot survive the touch of earthly skin, and shatter into a thousand fragments if you touch them. But any aliens that fall to the ground encyst themselves ina toughened shell, and once that pile of shells reaches over your head, you will DIE!

This is a relatively brief program, but the game is great fun to play. The aliens are poked randomly to the screen using sub- routine 10, and the number of aliens that fall at any one time can be varied just by changing the value of BN, line 5070. For a really

72

Alien Attack

tough game, try playing with 3 aliens dropping down at once you have to be very quick to get them all!

Program notes 5 Keyboard click and cursor off.

10-20 Alien placement routine. 10 picks a random position along the top of the screen, 20 saves that position in the array B(_ )so the alien can be moved later.

30-80 Alien drop routine. 30 finds the alien’s current position and checks that the alien is still there: it might have been destroyed in the previous move. 40 finds the alien’s new position and erases it from its old position, while 60 turns it into a shell body symbol if it is about to strike the ground or another alien corpse. 70 checks if the alien has hit the man, and 75 moves it into its new position if that position is empty. 80 completes the loop which moves all the aliens.

90-120 Keyboard control routine. 90-100 check if the man is being moved left, right, or kept stationary. 110 finds the man’s new position, and 120 draws him at that position.

125-140 Game end routine. The score is based purely on the length of time for which the man survives.

900-920 Initialisation routine.

960-1100 Game set-up routine. 1050 ensures that the foreground colour at the lower part of the screen is red, so all the alien cysts are suitably gruesome.

2000-2020 User defined character creation routine.

5000 onwards instructions and setting of skill level. Important variables

BP Body position for alien where it is in screen memory. ML_ Man left furthest left man may move on-screen. MP Man position. MR Man right furthest right man may move on-screen. NB New body position for alien. 73

The Atmos Book of Games

NP New position for man.

PB Value found at new position of alien body.

Symbols used

BS Body symbol for alien. ES Explosion symbol when alien strikes man. MS Mansymbol.

WS _ Worse body symbol used when alien becomes a cysted corpse.

5 PRINTCHR# (6) CHR#(i7):60TO900

10 PSTL+INT(RND (i) *#(TR-TLI +1): DFPEER (FP) =BSTHEN 10)

20 BCAISP:RETURN

36 FORA=1TOBN: BP=BRi A): TF PEEK (BP? © SBSTHENGOSUE: O:BF=B(A)

40 NB=BP+LL:PR=PEER (NB): POREBRP, 32: 1FPBR=WSANDBF cMRTHENF=1

60 TFNR?BRORPS=WSTHENFORERF WS: PR=WS

70 TFPR=MSTHENFING

73 IFPR=S32THENB (A) =NB:PORENB, BS

aG NEXT:RETURN

90 REPEAT: AS=EEYS: [FAS=CHR# (8) THENN=-1

95 IFA#=" "THENN=G

100 TFA#=CHR#¥(9) THENN=I

110 NP=MP+N:FORKEMP, 32: IFNF<MLORNP eMRTHENNP=AP 120 MP=NF:PORENP,MS:GOSUB30:1T=T+i:FLOTI7, 24,57 R#(T) :UNTILF=1

125 DORX=1TOS: FING: NEXT

120 CLO:PRINT"You lasted for time ":T:FRINT"TH is was at skill level "35L

i4G END

900 TLSfBRD7: TR=£RBFO: BL=£BRED1: BR=£LBEF I: LL=40 910 M5=93:BS5=94:WS=95:ES9=56

915 Z=MS:G0SUBZ000: 27=85:G0S5SUBR2000; Z=WS: GOSUB20 G0:Z5E9:G0SUB2000

720 THO; F=0:;ML=TL+1oeL oi: MR=TR+16#LLiMP=MNL+16 960 CLS:PRINT"Do you want instructions (Y/N)"3

74

Alien Attack

765 INPUTA#: IFAS="¥" THENGOSUBSOGO:G0TO1000

780 GOSUBRSOSO

Logg CLS: INK4: PAPERS: PLOTI1,24, "TINE: "

1050 FORZ=ML+39TORLSTEPLL: FPORKEZ, i: NEXT

Lido GOSUBLIO:FOQREMP ,MS:G0TO90

2000 XX=46080+248: FORG=XXTOXX+7: REAGU: POREG,U: NEXT: RETURN

2010 DATAI4,14,4,31,4,4,19,17,90,51,18,19,63,45 ,65,65

2020 DATA63,33,33,353,35,35,48,63,98,2,32,1,16,4 ; aw

5000 CLO:FRINT"You must try ta stop the aliens "!PRINT"¢rom falling to the bottom"

5005 FRINT"af the screen by popping them by":F RINT"oiacing your man underneath"

SOL0 PRINT"them. If you don’t stop the aliens’ :PRINT"their corpses will form a pile®

SO15 FRINT"which will build up until it":PRINT “reaches you and buries you, then"

5020 PRINT'’the game ends. ":PRINT:PRINT"Use the cursor keys to move the man"

S030 FRINT"ieft and right.”

S040 PRINT: FRINT“Use the space bar to stoo." PRINT:PRINT" input your skill level, from S,":FPRINT"L, easy, ta GS, difficuit": INPUTSL: TFSLE LORS’ sSTHENS OSG

BNSSL:RETURN

75

Grave Robber

Here, you must try and collect as much gold as possible while avoiding the poison arrows which fall from the ceiling above. As if this wasn’t enough, you must be very quick before the descending ceiling crushes you to death!

To make this game a little easier, protective bases are placed across the screen so that the man can seek shelter from the shoals of falling arrows. The horizontal and vertical dimensions of the walls and their number are determined in line 925. More confident players can eliminate the protective walls completely by adding 1101 GOTO1150.

76

Grave Robber

Program notes

10 Keyboard click and cursor off.

15-25 Arrow explosion routine. When an arrow hits the man or the floor, 15, it explodes, 20, and a new arrow is created to replace it;.29.

30-60 Move arrow routine. 40 checks if the arrow has hit anything or reached floor level, 50 pokes the arrow to its new position.

70-80 Keyboard control routine.

90-140 Player move routine. 90 checks that the present position is occupied: if it is empty the man has been destroyed by an arrow and the game is over. 100 ensures the man does not move off- screen left or right. When the side of the screen is reached, a gold bar is removed from the pile, and the gold bar flag GB is set to 1, 110. When the bar is deposited on the left side of the screen, GB is rest to and a gold bar is added to the pile on that side, 120. 130 checks if all the bars have been collected, if not 135 exmines the new position of the man to check if there is an arrow there. 140 moves the man to the new position.

150-160 If the maximum number of arrows is not yet falling, 150 may add a new arrow, while 160 loops back to begin the whole sequence again.

170-240 Game end routine. Various messages are given depending on the success or failure of your robbery.

900-960 Initialisation routine.

961-1190 Game set-up routine. 1100 draws the floor, 1105-1140 place the protective walls above the floor: these are gradually destroyed as arrows hit them during the game. 1150 pokes the pile of gold bars to the right of the screen. 1190 calls the routine that lowers the ceiling, and the game begins.

1200-1220 Lower ceiling routine. This is called every time a gold bar is removed from the pile.

2000-2020 User defined character creation routine.

5000 onwards instructions and setting of skill level.

77

The Atmos Book of Games

Important variables

AN Newarrow position.

DW Distance between protective walls.

GB Gold bar flag set to 1 when gold bar is taken. GC Gold bar count.

GN Number of bars collected by player.

GP Gold bar position on right.

GV __ Value of bar in pounds.

G1___ Top left gold bar position.

HW __ Horizontal dimension of protective walls. MA Maximum number of arrows to be dropped at one time. ML Man’s leftmost allowable position.

MM _ Man’s movement.

MP Man’s position.

MR Man’s rightmost allowable position.

NA _ Number of arrows presently dropping. NG _ Number of gold bars altogether.

NP New position for man.

NW_ Number of protective walls.

PA Position of arrow.

SL _ Skilllevel.

VW _ Vertical dimension of protective walls. WP Wall position.

WU _ How far walls are up from floor. Symbols used

AS Arrow symbol.

ES Explosion symbol.

78

Grave Robber

FS Floor symbol. GS Gold bar symbol. MS Mansymbol. WS_ Wall symbol.

10 PRINTCHR$ (46) CHR$(17):GOTO900

15 $=32: IFAP=FSTHENS=FS

20 POKEAN,ES:WAIT(S):POKEAN,S

25 P(A) =TL+INT(RND (1) #RA+2) RETURN

30 FORA=1TONA: PA=P (A): AN=PA+LL: AP=FEER (AN) s FOE EPA, 32

40 IFAP< >320RAN>BLTHENPING: GOSUB15: GOTO60

SO POKEAN,AS:F (A) =AN

60 NEXT

70 AS=KEY$: [FAS=CHR$ (9) THENMM=1

75 IFA$="" "THENMM=0

BO IFAS=CHR$(8) THENMM=-1

B5 T=T+l:T#=STRE(T) +" "SPLOT2Z2,24,7#:1FT=7ET HENT=0: GOSUB1200

90 PM=PEEK (MP): TFPM=32THENI 7%

100 NF=MP+MMs [FNP<MLORNP ?MRORNFEMPTHENI SG

110 IFNF=MRANDGB=OTHENGR=i1:FOREGP,32:GFP=GF+LL: GOSUBI200 \

120 [FNP=MLANDGB=1THENGB=0:FORKEG1,GS:G1=51-LL: GN=GN+i

130 IFGN=NGTHENZO0

135 IFPEEK (NP) =ASORTREMPTHENEXPLODE: WAIT (S00): GOTO70

140 POKEMP,32:4F=NP:POREMP,MS

150 IFRND(1)<SLANDNA<MATHENNA=NAtTiLP (NA STL+IN TCRND (1) #RA+2)

160 GOTO30

170 CLS:PRINT:PRINT"You perished from the pois on at the":FRINT"tip of the arrow, but your” 180 PRINT"grateful relatives ";

190 IFGNSOTHENPRINT"got "sGN#GV;-" thousand oou nds for the gold. ":G07T0240

195 IFGN=OTHENFRINT"“sold your clothes tor a + ew pounds. ":GOTO240

200 CLS:PRINT:PRINT"You return home having col lected"

79

The Atmos Book of Games

205 PRINTGN#¥GV;" thousand pounds worth of qoid 240 END

900 TL=f£BRBD2: TRe£BBFS: BL=£RECA: BR=£BEED:s LL=R4o 910 AS=9FL:ES=972:F5=93:65=94:M5=95:W5=96 915 FORZ=917096: GOSUBR2000: NEXT

920 NG=6:GN=0:NA=4: MA=NA:GC=0:GBR=0: WU=3:T=0:TE =50

925 HW=3:VW=2:NW=

950 DT=TR- TL: RA=DT- 2:DW=INT((DT-NW#HW) / (NWH1)) 955 WR=BL+DW-WU4LL

960 ML=BL-LL:G1=ML-LL:MP=NL:MR=BR-LL:GP=BR

Gél CLS:FRINT"Do you want instructions (¥/Ni" 965 INFUTA#: IFAS="¥"THENGOSUBSC0G: GOTOLGGG

580 GOSUBS9S6

1000 CLS:INKi:FAFER?7

1100 POREBL-1,0:FORA=BLTOBR:POKEA,FS:NEXT:POKE MEMS

{105 FORA=iTONW: FORH=GTOHW-1:FORV=CTOVW-1

LiiG PSWRtH-V#LLsPOREP,WS:NEXTV:NEXTH

1146 WP=WP+HW+DWs NEXT

1156 GC=GCti: IFGCs =NGTHENGP=GF-LL:FPOREGF,65:60 TO1150

1146G PLOTIS,24,"TIME:"

11960 GOSUBI1200:G0TO30

1200 FORA=TL-LLTOTR-LL: FPOREA, 32: NEXT

1205 TL=TL+Lb: TRETR+LL

1210 FORA=TL-LLTOTR-LL: FOREA,FS:NEXT

220 RETURN

2600 XX=46080+7#8:FORG=XXTORX+7:READUs POREO,U: NEXT: RETURN

2010 DATAB,6,6,8,6,42,25,6,8,2,32,1,16,4,0,0,6 3,63,63,65,63,65.63,65

2020 DATA63,33,: 33,33,33,4635,14,14,4,31,4, 4,10, iF Dia ocr, 42,21, 42,21 ,42@

sodg CLO:PRIAT"As a grave robber you risk deat n"sPRINT*to snatch gold bars trom"

S005 PRIANT"ancient tombs. There are many traps "?PRINT*in the tombs, and only the "

S010 PRINT*most skilled robbers can evade the" tPRINT"poisan arrows which tali trom’ nQO20 PRINT" above. The gold bare are so heavy": FRIANT"that you can only carry one at” So30 FRINT*a time. fou must drop the bar near”

=

80

Grave Robber

rFRINT*the exit. which 15 on the left,”

S035 PRINT"betore returning ta the right ¢+or’: FRINT" more bars. ©

S040 PRINT*’Watch cut tor the cescerding ceilin q!

SGd5 FRINTS PRINT’ Controls - use the cursar key

to":PRINT"meve right or iert.*

BG FRINGSPRIGt "How seilled a robber are you, i, "SPRINT" hopeless, to 3. master crook";

5060 INPUTSL:ITFSLe i ORSLSSTHENS O50

Sa7G TESTE-S#5L:MA=MA+SL:GV=SL#2: SL=SL#, 02: RET

URN

81

Manhunt

You are a madman who has seized a poorly-guarded tank and gone on the rampage. With no thought for others you mow your victims down under the huge treads of your machine. How many more will perish before you are caught?

Although Manhunt is a completely different program to Adder, it once again makes use of the tank as the player’s symbol. By careful program writing, part of the Adder program can be used as the basis for a new game.

In Manhunt the aim of the game is to run down as many randomly moving victims as possible in a given time. The game is made more difficult by the fact that any man hit by the tank is

82

Manhunt

buried on the screen beneath a cross, through which the tank cannot move. Manoeuvring thus becomes harder as the game progresses. The number of men is kept at a reasonable level by replacing the ‘dead’ men elsewhere on the screen.

To save programming time, it is possible to load Adder, delete lines 300-360, and then type in just the following lines which differ in the listings: 40, 50, 110, 120, 150, 160, 180-220, 265-290, 905-925, 1000, 1110, 2010 onwards.

As the programs have a number of lines in common, the program notes describe only those lines which differ, and the reader is referred to Adder for a full description of any other sections.

Program notes

40 This pokes a man to a random position on-screen, saving that position in the array M( ).

50 Keyboard control routine.

110 Checks tank’s new position. The tank will not move if it hits a wall or a cross.

120 The only other object the tank can hit must be a man, and this line pokes a cross to the man’s position.

150 Gun rotate routine. If the swinging gun hits a man he is replaced by a cross.

160 If the gun hits anything else, it can’t move.

180-220 Man move routine. 180 checks if there is now a cross at the man’s position, in which case he must be dead, and should be placed elsewhere on-screen by calling sub-routine 20. 185 ensures that the man moves less frequently for less skilled players, and 190 calculates a random movement for him. 200 checks to see if the man has blundered into the tank or gun during his random cavortings, otherwise 210 erases him from the old position and draws him at the new one. 220 completes the loop to move the remaining men.

265-290 Game end routine. Gives the score. 1110 Places the men randomly on-screen at the start of the game. 83

The Atmos Book of Games

2000-2030 User defined character routine.

5000 onwards instructions and setting of skill level.

Important variables

The only new variables introduced in Manhunt are: MN Number of men to move around.

MT _ Total number of men to be killed in time limit TE.

Symbols used

The only symbols which differ from those in Adder are: CS Cross symbol. N Man symbol.

10 FRINTCHR$ (6) CHR$(17):GOTO900

20 NXSINT(RND(L)#TD+1) sNY=INTCRND( 1) *SD+1) 30 PN=SP+NX-NY#LL: IFPEEK (PN) < 232THEN20

40 M(A)=FN:POKEPN,N: RETURN

SO ND=D:AS=KEY#: IFAS=CHR$ (9) THENND=D+i

60 IFAS=CHR¥$(8) THENND=D-1

80 ITFND=DTHENIS9O

90 TPND?7THENND=6

100 TFND<OTHENND=7

110 NG=FP+D(NDI:PG=FEEK (NG) s TFRG=WSORFG=CSTHEN

150 iZO TFPG<232THENPOKENG,C5: 6070150 136 POREFP+D(D) 32: 0=ND0:POREFP+D (Di G60)

150 NP=PP+2*D(D): 1FPEER (NF) =NTHENPORENPF CS: G0T

0180

1o0 IFPEEK (NF) < >32THENI8«@ {70 POREPP,22:PP=SPP+0 (0) :POREPP, TS: POGRKENF GD; 180 FORA=iLTOMN: TFPEER (MN (A) 7 =COTHENS=5+1:G0S5U82 Q

165 PN=SM(A): TFRND(1) 2SLTHENZ20

{90 M=INTCRND (1) 48) ¢NM=PN+D (CM) PS PSPEER (NM) 200 TFP=TSORF=6 (D0) THENPOGREPN,C5:G0TG220 210 TFP=32THENPOREPN, 32:4 (A) =NMiPORENM,N 220 NEXTA

84

Manhunt

246 PLOTSC-7,24, "SCORE: ":FLOTSC,24,5TR#(Si: 7ST t+i:PLOTTI-6,24,"TIME:"

245 FLOTTI,24,5TR#(7)

265 IFS¢MT ANDT<TETHENS®

270 CLS:PRINT’The mad driver kiiled °;5;" men” rPRINT"before his petrol ran out. This"

260 FRINT"was at skill level "y5L#10:FRINT"A ¢ otal score of “;TE-T+SL#5#i0

290 PLAYG,O,0,0:END

900 TLS£BRD2Z: TRE£RBFS: BL=£f£RECA: BR=£REECS LL a4 505 SC=15:TL=25

910 CS=43:TS=FL:WS=92s GG H9S:G Ci a94s G02) 295 Gid)=F96:N=36

915 G4) =FS:G(5) 94:66 ass Gi7=946

920 FORZ=91TO96:GOSUBZOUG: NEXT: Z=N: GOSUBZ000 925 D=2:T=0:5=0:TE=400:MN=S:MTH15

930 DCOPS-LLIDCLIS-LL+i:b(2) st: DtSrsletl

946 D(4)SLbL:D(5)=LL-1:0(6)s-1:0t7)=-LL-1

550 BR=BR-LL:8L=BL-LL: DT=TR-TL: BL=8L-TL: TD=DT- 1:5D=(DL-LLI/LL

955 PRSTL+LL+i:SP=BL-LL-i

960 CLS:FRINT"Do you want instructions (Y/N)"; 965 INPUTAS: LFAF="¥" THENGOSUBSO09: GOTILO06

980 GOSUBSO50

{G00 CLSO:INKL: PAPERS

1100 FORA=TLTOTR:POKEA, WS: PFOREA+DL WS: NEXT 1105 FORA=TLTOBLSTEFLL: POKEA,WS:FOKEAt+DT ,WS:NE XT

1ii0 FORA=1TOMN:GOSUB20:NEXTA

1120 POKEPF,TS:FOREPF+D(D) ,G(B):FLAYG,1,3, 80:6 a7o50

2000 Kx=46080+7#8: FORG=XXTOXX+7:READU: POKEO,U: NEXT:RETURN

2010 DATA63,63,63,63,63,63,63,63,63,33,35,33,3 eve 8, 8,6,5,8,6,8 2020 DATAG,0,1,2,4,8,16,32,9,9,0,63,9,0,0,9,

516,8.4,2,1 0, , Z2U30 DATAL4, 14, 4.51,4,4,19,47 S000 CLS:FRIAT"In Man Huat you are a lunatic # no":FRINT"has managed to Seize a tank." S005 PRINT'Fortunately, it has no ammunition,” rFRiWT but you can still cause havoc” SOLO PRINT"by running aver any passers-by":FR1I NT"or hitting them with vour gun."

85

The Atmos Book of Games

SOLS PRINT"Dead men will be buried beneath":FR INT’ crosses - you cannot drive over"

S020 PRINT "these. Your petrol will run out":FR INT™in time “;TEs" although if you"

S025 PRINT"kiLi "sMT:" men your treads will “:F

RINT"probably be unable to move due to"

s030 FRINT"’the bones jamming them.

a050 PRINT: PRINT*’Controls are: left cursor key to":FRINT“rotate tank anticlockwise, and" s060 FRINT"right cursor key to rotate it":PRIN T"clockwise. Flease input"

S070 PRINT*your skill level, 1, easy, ta 1a, A ard"::TNFUTSL

S060 IFSLELORSL?10THENSOSO

S090 SL=5L/10:RETURN

86

Cin Wh e-

The shrewd gambler can clean up on this one: with a careful look at the form, it’s not too hard to select a likely looking winner for the next race. Then it is sit back and cheer your choice on as the horse sprints towards the finishing line!

Every horse which takes part in the races has a movement number associated with it. This is generated by the computer equivalent of throwing two dice: two random numbers from 1 to 6 are found and added together. This value is stored in the array H( ).

When a race is run, a second random number is generated in exactly the same way. If this matches the movement number in

87

The Atmos Book of Games

the array H( ), the horse is moved forward. Obviously horses with certain movement numbers are at a severe disadvantage. A number like 12 is not going to come up very often! Their poor chances are reflected in the odds given at the beginning of each race. The odds are thus a good guide to the form of the horses, but a random element is always included so that the odds are not a direct reflection of a horse’s chances. An interesting idea to extend the program would be to run a number of races internally and produce these as a form guide. Some horses might be penalised according to ground conditions, and so on. There is plenty of scope here for experimentation.

Program notes

10 Keyboard click and cursor off

15-90 Horse movement routine. 15 generates a random number, and 20 compares this to the horse movement number. If the two do not match, the horse does not move. Any horse moving has its new position checked in 30, to see if it has reached the finishing line. If so, the flag F is set to 1 to indicate a winner, and line 80 then ensures that the loop terminates with this horse. There are thus no dead-heats, as movement ends as soon as a horse crosses the line. 40 calculates all the new positions for parts of the horse’s body, based on the position of its front leg, and 50 erases the horse. 60 finds the new positions, and the last part of the line ensures that the legs are straight and at an angle on successive moves. 70 draws the horse at its new position, 80 ends the loop early if the horse has just won, otherwise 90 continues the race.

100-170 Winnings and losses routine. 105 checks if you picked the winner. If you did, 110 calculates your winnings and 115 displays them. If you are broke, 120 ends the game. Otherwise, 130 checks if you have reached the winnings target, and you are given the option of continuing or retiring gracefully, 140. 150 sets up anew race, 160 and 165 giving various messages depending on whether you gave up betting or ran out of money.

900-920 Initialisation routine.

960-1070 Game set-up routine. 1005 adds one to the race number and picks a random number of horses to run in the next race. 1010

88

Derby Day

picks a random name at which to start reading the names of the horses to run in the race. 1015 generates horse movement numbers and 1020 saves that number and the horse’s name to the arrays H( ) and H§( ) respectively. 1040-1070 find the odds for each horse, the very slow ones having their odds increased by 1050! 1060 adds or subtracts a random amount from the odds, the latter only when the horse has a very good chance of winning.

1080-1190 Start race routine. 1090-1150 print out information about the race, and takes and checks your bet. 1160 picks each horse position, going up the screen with 4 lines between each horse this can be amended to bring them closer together or to spread them out. 1170-1180 calculates the positions for different parts of the horse’s body, and pokes it on-screen. 1190 pokes the finishing line into place.

2000-2030 User defined character creation routine. 3000-3010 Horse name data.

Important variables

DV Dice value used to pick movement number for each horse.

F Flag set to 1 when a horse crosses the finish line.

HB Horse back leg position.

HF Horse front leg position.

HH __ Horse head position.

HN Horse new front leg position after movement. HT Horse torso position.

LH Largest number of horses in race.

NH _ Number of horses in race.

OD Odds for horse.

PH _ Screen position of horse’s front leg at start of race. R Race number.

SH = Smallest number of horses in race.

89

The Atmos Book of Games

SP __ Start position for poking horses on-screen at beginning of race.

T1, T2 Tab positions to align horse names and odds on-screen. TH Total number of horse names available.

TM Target money to be won by player.

WH_ Winning horse number.

YB =“ Your bet.

YH Your chosen horse.

YM Your present money.

YW = Your winnings.

Symbols used

Bl Set equal to BD or BS, the back leg symbols. BD Back leg diagonal.

BS Back leg straight.

Fl Set equal to FD or FS, the front leg symbols. FD Front leg diagonal.

FL Finish line symbol.

FS Front leg straight.

HS Head symbol.

OS Nought symbol— symbol for number zero. TS Torso symbol.

10 PRINTCHR#(6)CHR$(17):G0TO900

15 FORA=1TONH:H1=INTC(RND(1) #6+1) SHZ2=INT(RND (1) #6+1)

20 IFH(A)< SHI+H2THENDO

30 HF=F(A):PF=PEEK (HF) :HN=HF +i: IFPEEK (HN) =FLTH ENF=1

40 HB=HF-2:HT=HF-LL-i:HH=HF-LL¥2

90

Derby Day

50 POKEHB,32:POKEHT,32:POKEHF, 32: POKEHH, 32

60 HB=HB+1:HT=HT+1:HH=HH+1:B1=B5:Fi=F5: TF PF=FS THENBI=BD: F1=FD

70 POKEHB,B1:POKEHT,7T5:POKEHN,Fi:POREHH,HS: P(A )=HN

BO IFF=1THENWH=A: A=NH

90 NEXTA:IFF=OTHENIS

100 PRINT: FRINT:PRINT"The winner was horse num ber "“s;WH;H# (WH)

105 IFYH*« s>WHTHENI20

110 YW=YB#O (WH)

115 PRINT"You get E“svWsy"."sYM=YMtYWs GOTO1S0 120 YM=YM-YB: TFYM=OTHENL45

130 IFYM>=TMTHENISO

{35 PRINT"You now have €"3¥M;". *

i4g PRINT"Go you wish to continue betting "sii FUT AS

150 IFAS="Y"THENF=0:G0TOiO00

160 FRINT*You have finished with #"syMy"."

170 END

900 TL=£BRBD2: TREEBRBFS: BL=£RECA: BR=EZBEED: LL=40 910 HS=91:TS=92:BS=93:F S94: BD=i23 FP bte4:F lal 25:05=468

915 FORZ=917094:GOSUBZ000: NEXT: FORZ=1237T9125:6 OSUB2000: NEXT

920 YM=200: TM=2000: SH=2:LH=5: TH=B:R=0: Tas: t2= 20

960 CLS:PRINT"Do you want instructions (¥/N)"; 965 INFUTAS: IFAS="¥"THENGOSUBSOGO

1000 CLS: INKO:PAPER2

1005 R=R+i:NH=INT(RND(1)#(LH-SH)+SH)

1010 NA=INTCRND(1)#(TH-LH)):FORB=iTONA: READAS: NEXT

1015 FORA=iTONH:HI=INT(RND (1) #641) :H2=INT(RND: 1) #6+1)

1020 H(A) =Hi+H2: READA$:H$ (A) =AF

1040 DV=H(A): IFDV>7THENDV=14-DV

1050 OD=10-DV: IFDV<4THENOD=OD#2

1060 EX=INTCRND(1)*0D):TFRND(1) 30. SANDDV?4THEN EX=-EX

1070 O(A)=OD+EX: NEXTA: RESTORE: FORA=17T054:READA :NEXT

1080 CLS

1090 FRINT"Race number "sR:PRINTNHs" horses ru n."

91

The Atmos Book of Games

1i0G PRINTTAB(T1);"Name";TAB(T2);"Gdds" 1105 FORA=TLICGBRLSTEPLL: POREA,WS:FOREAtOT WS:NE AT 1110 FORA=1TONH:PRINTA;H#(A);sTAB(T2) sGiAiy "to 1":NEXTA 1iZ0 PRINT"What number horse will you back"y:l NPUTYH 1130 ¥H=INT(YH): TFYHALORYH?NHTHENII20 1140 PRINT"How much will you bet";:INFUTYE 1150 YR=INTCYBR): TF YM-YB<OORYHsNHTHENI120 i*6O CLO:SP=BL-LUL+3: FORA=1TONH: FH=SPF-(A-1) #4 4L L:P(A)=PH 1170 HF=PH:HB=HF-2:HT=HF-LL-1:HH=HF-(LL#2):N=H B-1 1180 POREHB,&5:POREHT,TS:POKEHF,FS:POKEHH,HS:P OREN,GS+A 1190 NEXTA:FORB=TRIGBRSTEPLL:FPOKEB,FL:NEXTB: G60 TOS 2000 XX=4OO0R04+72#8: FORG=AXTOXX+7:READUSFOREO,U: NEXT: RETURN 2010 DATAGO,9,0,0,42,32,56,56,1,1,1,1,63,635,63, 63,1.1,1,1,1,1,6,0

920 DATAS2,32,32,52,32,52,0,0,1,2,4,8,16,0,0, ( 116,8,4,2,0,0,0 2030 DATAIZ,12,12,0,0,12,12,i2 3000 DATA" RED FRED "," BULLET “." STAR ",." EA NGARGG " 2010 DATA" SHOREY ",*° GUTSY °," THE FLIER "," SLOWCGACH " S000 CLO:FRINT" You have £";¥Ms "to bet. You"rFR INT’ must arm toa end up with" 5010 PRINT'E": TMs * or more. The adds given":FR INT"for each horse are a guide to its" S020 FRINT "chances, but outsiders can wini" 5030 PRINT:FRINT*’Press any key to continue. ":6 ETX#:RETURN

92

Starship Warrior

As the captain of a fleet of starships you seek to bring vital supplies to an orbiting space station. But every movement of your ships is fraught with danger, for the space station is menaced by constant asteroid showers. One by one you despatch your ships will any of them survive?

The only problem in this program is caused by the asteroid movement. 260-290 create a random diagonal movement which is assigned to all the asteroids, so that they move as a body across the screen. The asteroids are moved in lines 14-18, and line 14 moves asteroids going off the top of the screen back to the

93

The Atmos Book of Games

bottom. Line 16 moves asteroids going off the bottom back to the top. Line 17 is necessary because the left hand side screen locations are used by the Oric to define the foreground and background colours for that particular line. If an asteroid moved into these locations, the background and foreground colours for that line would be lost, and the entire line would turn black. Line 17 thus checks that the next memory location does not contain a character code lower than 32, as a number in this range must be the code fora colour. Any asteroids about to strike these locations are instead shifted across the screen to new positions.

Program notes

10 Keyboard click and cursor off. 14-18 Asteroid move routine, as explained above.

20 pokes the space station back into position in case an asteroid has just moved over it, and checks that the present starship position is not occupied by an asteroid.

30-90 Keyboard control routine.

150-230 Starship move routine. 150 omits this section if no key has been pressed. 160 checks the new position for asteroids or the space station. 170 dooms any ship with no fuel to drift helplessly while the asteroid shower continues. 180 ensures the ship does not move off-screen, 200 erases the ship from its old position and 210 draws it to its new one. 220 reduces the fuel and plots its amount on-screen, 230 completes the loop.

250-305 Game set-up routine. Used at the start of the game or whenever a starship is destroyed. 260 selects a random move- ment for the asteroid shower, 270-290 randomly position the asteroids on-screen and save their locations in the array A( ).

300-350 Game and routine. Various comments are offered and a score is given.

900-950 Initialisation routine.

960-1000 Offer instructions and clear screen for game start. 2000-2020 User defined character creation routine.

5000 onwards instructions and setting of skill level.

94

Starship Warrior

Important variables

AD

Asteroid direction of movement to select value from D( ).

AM _ Asteroid movement one of the 4 diagonal moves from D( ).

AN _ Asteroid’s new position after movement.

AP _ Asteroid’s present position.

AX _ Asteroid’s x coordinate relative to BL at game-start.

AY _ Asteroid’s y coordinate relative to BL at game-start.

FF Full fuel supply starship fuel units at game-start.

MD_ Mysstarship direction to select value from D( ).

MP Mystarship position.

NA Number of asteroids.

NP My new starship position after movement.

SD _ Starships destroyed.

SF Starship fuel—units remaining.

SP _—_ Space station position.

ST Starship—number of starships that can be used.

Symbols used

AS _ Asteroid symbol.

ES Explosion symbol.

MS Mysymbol—a starship.

SS ____ Space station symbol.

10 FPRINTCHRS (6) CHR#(17):G0TO900

14 FORA=1TONA: AF=A(A) :AN=AP+AMN: TFAN: TLTHENAN=A N+OL*LL

16 IFANSBLTHENAN=AN-DL#LL

17 IFPEEK (AN) < 32THENAN=ANFLL/ 2

18 POKEAF,32:A(A) =AN: POREAN, AS: NEXT

95

The Atmos Book of Games

20 POKESP,SS:P=PEER (CMP? : TFRs @MSTHENFOREMP.ES:6 OTO240

30 AF=KEYS:MND=8: [TFAS="W"THENND=0

395 IFA#="E"THENMD=1

40 [FAS="D"THENMD=2

50 LTFA#="C"THENMD=3

60 IFAS="K"THENMD=4

70 TFA="Z"THENMD=5

BO IFAS="A"THENMD=64

90 TFA#="Q" THENMD=7

150 IFMD=8THENNF=MP:GOTO170

160 NP=MP+D (MD): N=FPEERK (NP): TFN¢ SSZANDNe GSSTHEN POKEMP,ES:EXPLODE: GOTOz40

170 IFSF=QTHENI4

180 ITFNF« TRORNP BL THEN2 20

200 POKEMP, 32: TFN=SSTHENPOKENF NS: GOTG320

210 MP=NP:POKEMP,MS SF=SF-1:S#=STR#(SF}:FLOTI7, 24,5¢

GOTOL4

S5D=SD+i: 1TFSD=STTHENS10

PLOTS,24, "Spaceship destroyed": WAIT(Sa00) BD=Z*INTCRND (1) #4) +1: 1F BD=1 THENBRP=BL

270 CLS: FORA=1TONA:AX=INTCRND (Li #DT) AYSINT CRN Diid*DL)

260 IFRED=STHENEF=TR

290 AN=BL+AR-AY4#LL:FOREAN, AS: ACA) SAN: NEST

295 SPHTL+4#Di 3): POKESP SS:FLOTLi, #4, "Fuels" S00 AD=Z*INTCRND (1) #4) +1: AN=0 (AD) :SF=FF:MP=RR- Li-i

$05 POREMF,MS:G0TO14

310 CLS:PRINT"You failed to reach the space st ation. ":G070350

S20 CLS:PRINT*Well donei You reached the space "SPRINT"station with ship ";50+1

330 PRINT"using "“sFF-SF;" fuel units. This was "SPRINT" at skill ievel "sSL

340 FRINT"This is a total score of ";SL#(ST-SD )#5F

350° END

S00 DIMA(Z0):TL=£bRO2: TR=£BRFO: BL=£RECA: BR=LBE EU:LL=40

FiO AS=GLSES=92:M5=93:55=74

FiS FORZ=FiTO94: GOSUBZOGG: NEAT

920 S0=0:9T=3:FF=300

ha PJ bo Bo po Ob Cee

a) oO on Rent an

96

Starship Warrior

P30 DAGS-LLI Dili a-LbL+i: Bigs st Dis

$40 Did =LLiB(Siali-i:O(6is-iibi7i=-LL-1

$90 DTSTR-TL:DL=(BL-TL) LL

960 CLS:PRINT"Bo you want instructions iy/N)"; 565 INPUTA#: TFAS="Y¥"THENGOSUBSGOO: GOTOiGeL

jag SOSURSOS0

{G00 CLS: TNRG:FAPER4: GOTO246

2000 Xk=4o080+748:FOROSfX TOR A+ 7 READUS PORE, Us NEXT:RETURN

POLO DATAI4,31,62,34,30,60,26,6,9,2,52,1,16,4, O,O,L2,f2,12,12,12,63,45,45

2020 DATAO,12,18,63,68,16,12,6

5000 CLO:FRINT"+ou must try to iand on the soa ce'sPRINT"station by guiding vour ship”

S005 PRINT"through the asteroid showers. You :PRINT’begin at the bottom right, and*

SOLO FRINT"the space station 1s near the tap": FRINT' eft. You have "s5T;" ships each”

S20 PRINT with "sFFr° units of tuel. The": FRI NT"number of asteroids depends an "“

S030 FRINT’skill level."

5035 PRINT:PRINT"Controls - use the keys aroun d the":FRINT“Letter &:"

5Od0 PRINTSPC( to), "G WES PRINTSPC(i7) 3 "A SG" rFRINTSPC(LSi:"2 x 0"

S050 PRINTIPRINT" input your skill devel, 1, ea sy, to":PRINT’LO,nard’:

5060 (NFUTSL: CFSLALORSLSLOTHENSOSO

SO7G NA=SL#E:RETURN

i

97

Trap

You control a little man who must constantly keep on the move. Any time he pauses too long in one place, blocks begin to appear around him. If he is too slow, he will be completely surrounded and unable to move.

This is definitely the game for those who fancy they have quick reflexes! One part of the game which might tend to slow things down is the necessary routine that checks if the man is completely surrounded, in which case we want the game to end. It might seem that we must look at all 8 positions surrounding the man at every ‘turn’, but this is not the most efficient method. It will be quicker if the positions around the man are only examined untila space is found. If there is a space nearby, the man can still escape, and the game continues. Lines 160-190 carry out this procedure,

98

Trap

and by only looking at the surrounding positions until a space is found, the game is speeded up.

Program notes

10 Keyboard click and cursor off. 20-100 Keyboard control routine.

110-115 Player move routine. 110 checks if the new position is a wall or block, and 115 pokes the man to the new position if it is clear.

125-140 Block position routine. 125 omits this section if the skill level is too low, 130 chooses a random position for the block, and 140 pokes it next to the man if the skill level is high enough.

160-200 Man surrounded routine. Each position around the man is checked until a space is found. If no space is found 200 will terminate the game.

220-230 Time and pause whose length depends on the skill level. 250-280 Game end routine, including the score. 900-950 Initialisation routine.

960-1110 Game set-up routine. 1100-1105 draw the walls around the playing area, 1110 pokes the man on-screen.

2000-2010 User defined character creation routine.

5000 onwards instructions and setting of skill level.

Important variables

CM Computer movement used to pick movement from D( ).

CV Computer velocity high values give slow games.

MD_ Man direction used to pick movement from D( ).

MP Man position.

NC _ New block position.

NP Man’s new position.

99

The Atmos Book of Games

Symbols used

BS Block symbol. MS Mansymbol. WS Wall symbol.

1G FRINTCHR# (17) CHRE (6): G0TO900

20 MD=B:A=KEV$: TFA#="W"THENMD=0

30 [TFAS="E"THENMD=1

40 TFAS="D" THENMD=2

50 [FAS="C"THENND=3

60 TFA$="*X"THENMND=4

70 [TFAS="Z"THENMDHS

60 IFA#="A"THENMND=6

90 [FAS="O"THENMD=7

Loo TFMD?7THENLSe

110 NP=MP+i (NO): PSPEER CMP): TFRPEWSORPHBS THEN 30

115 POKEMP,0S:MP=NF:O0S=P:FOKEMP,MS

125 TFRNG(L) sSLTHENZ ZO

130 CHEINTCRND C1) #8) sNCEMP HD (CH)

140 IFRND¢ Li SUTHENPORENC ,BS

1460 A=0

170 CN=D (A): NC=MP+tCM: CN=PEER OND)

f60 [FCN=32THENE2O

190 [FAs ?THENAFAt1: 6070170

200 GOTGE5a

220 THTt+isPlLoTia8,24,57TR#iT)

e450 WAIT(CY) :G0TO20

250 ClLS:FRINT* your time to blockade was "yT 2?7G FRINT’ At skill levei "Slee

efa PRINT*A total score of "SLe10#T

260 END

G0 TLetbRO2:; 7R=£ERRFS: BL=£BECA: BREZBEEC:LL=4

P10 MSs91:8Sss7e2W5s99

SiS FORZS91 7093: G05UB2 000: NEXT

S20 TeOQ:NBbed: TRazo

FRU DCO;S-LEr DC S-Lbel OC e2ieir GS) elle

P40 SCF) SLL GCS ell -isbiese- Lid (7ie-Lb-l

FO OT=TR-TL:DL=BL-TUrCPaTL tint (OTs 2) +6" P=BR-LL-1

100

Trap fod CLS:PRINT"Do you--want instructions (Y/N)

Jo5 INPUTAS: I FAS="¥ "THENGOSUBS5S000: GOTOLO0G 966 GOSUBSOSG

Jono CLS

1100 FORASTLTOTR: SOKEA, WS:FOREAtDL WSs NEXT 1i05 FORA=TLTGBLSTEPLL: FOKEA WS: FPOREA+DT WS: NEAT

L110 PLOTLe. 24, "TIME: ": FOREMP Mo: b0TO20

eUU AASFOUBUC LHR FORGERATGAA +t? READULPOREG, UrtE ats RETURN

2010 DATAI4.,14,49,21,.4,4,.10,17,68,33,33,353, 38 35 ,35,6463,65,65,65,63,65,635,63,63

S000 CLStPRINT"In Trap you must try to escap eorFRINT "walls which will surround vou"

BOL PRINT" (4 vou linger tan long in one’sFR INT’ spot. dry to keep free for as long"

S020 PRINT"as possible. When you are":FRINT" completely surrounded the game ends.”

S980 PRINT: PRINT "Controls - use the keys are und the"sPRINIT’S key to moves"

HO60 PRINTSFO (lols "GQ WE": FRINTSPCO(17)3"A 5 BM aPRIWTSPOCL Bia "2 RC"

SOTO FRING: PRINT Input vour skill level, J, gasy"TPRINT"to LO. harg’ ss TNFUTSL

Said (PSL TOR SL? LOTHENS O50

S090 C¥eil-SirSteS5l/ lor Re TURN

101

Ratkiller

Way ae ae

GE GZ LZ “Uy Ss ZB ZZ Zp Se A AA ZL Az Ze ZA

SX

EN \ mat \

iif Lj, ‘|

<1 Ai! y) A % # \\" Up, 4 Y £ \ .

\ {hi Uff SS \ \

= wi, Ty il

E A

a,

In this game you are a snake and you must try to kill a rat by running into it and biting it with your venomous jaws. However,

the snake is continually moving, and you will perish if you bite yourself or touch the electrified walls surrounding you...

In this game the parts of the snake’s body are stored in an array, the tail being stored as S(1) and so on. The highest array value thus contains the present position of the snake’s head. Whenever the snake moves the tail position is erased and a new segment is added on at the snake’s head, thus keeping the snake a constant 102

Ratkiller

length. As in the earlier program, Caterpillar, the snake is moved through an array to keep a constant record of positions of all parts of the body. Note that if you choose a long snake to make hunting the rat easier, you will find it moves very fast and you will often miss your target.

Program notes

10 Keyboard click and cursor off.

20-80 Keyboard control routine. Horizontal and vertical move- ments only are catered for.

110-160 Snake move routine. 110 finds the new snake position and checks if you have bitten yourself. 120 checks if you have got the rat, and 130 checks for hitting the electrified wall. 135-145 move the snake to its new position, 150 updates the time, and 160 decides on the basis of skill level whether or not the rat should move this time.

170-190 Rat move routine. 170 selects a random movement from the array D(_ ), and checks that the new position is not a wall, or the snake, 180. 190 pokes the rat to its new position.

200-280 Game end routine. Various messages are given depending on the outcome of the game, as well as the score.

960-1210 Game set-up routine. 1100-1105 pokes the electrified walls to the screen, 1110-1120 choose a random position for the rat and poke it to the screen. 1170 picks a random position for the snake’s head, and 1175 checks that this is empty. 1180 pokes the head and the rest of the snake’s body on-screen, continuing in that direction until a position is occupied and a new direction for the body must be found, 1195. 1210 begins the game.

2000-2030 User defined character creation routine.

5000 onwards instructions, selection of snake length and setting of skill level.

Important variables BS Biggest snake length allowed.

LS Selected snake length. 103

The

Atmos Book of Games

MD _ My direction of movement to select a value from array

D( ). NP New head position for snake. RM _ Rat movement to select a value from array D( ). RN Newrat position. RP Present rat position. RX __ Rat’s x coordinate relative to BL. RY _ Rat’s y coordinate relative to BL. ST Snake tail position. SX Snake’s x co-ordinate relative to BL. SY Snake’s y co-ordinate relative to BL. TS Tiniest snake length smallest selectable snake length. Symbols used H Snake head symbol, varying with movement direction. RS Rat symbol. SS Snake symbol. WS _ Wall symbol. {GO PRINTCHR# (6) CHR¥ (17): 60TS 900

20 4a 60 BO Lid 120 i346 135 140 145 154

1690

104

AS=KEYS: TFAS="W"THENMD=0; H=93 IFA$="D"THENMD=2:H=94 IFAS="X"THENMD=4:H=95 IFA#="A"THENMND=6: H=96 NP=SH+D (MD) :P=PEER (NP): PFP=SSTHENZI0 IFF=RSTHEN2Z30 IFP=WSTHENWH=1:G0T0270 S=S5+i:ST=ST+ii TF ST? 7Q0THENST=0 IFS>900THENS=0 S(5})=NP:PORENP,H:PORENP-D(ND) ,SS:PORES (ST)

T=T+isPLOTi7,24,STRE(7) SH=NFiTFRND (i) *SLTHENZO

Ratkiller

170 RM=INT(RND(1)#8):RN=RP+D (RM): REPEER CRNI: TF R=WSTHENZO

180 IFR=SSTHENZ30

190 POKERP,32:RP=RN:FORERP, ARS: TFTA TETHKENZO

200 PLAYO,0O,0,0:WAIT(390):CLS:FRINT* Your time has run out. ":G0T0270

210 PLAYO,0,0,0: WAIT (300)

220 CLO:PRINT"In your excitement you bit yours elf":PRINT"and died. ":GOTOQ276

230 PLAYO,3,1, 1000: WAIT(300):CLO:FRINT "you sei ze the rat in your poisan"

235 PRINT"fangs and inject it with poiso*"

240 FRINT"in time "3T;" at skill level ":SL#ilu 265 PRINT"A total score of “s;iTE-T) #5L#10

270 ITFWH=LTHENCLS:PRINT"You blundered into a w all and killed":PRINT"yoursel¢."

280 END

900 DINS(900):TL=£BBD2: TRe£BRFS: BL=£BRECA: BR=£K EED:LL=40

910 RS=91:95=92:H=95: WS=125

915 FORZ=917096:GOSUBZO00: NEXT: Z=WS: G05UBZ000 920 T=0:TE=400:MD=4:RD=0: T9=4: 85=19:5T=6

930 DIO) S-LLIDCLiH-LLtis Di 2} =1:DCS)=LLti

940 0(4)=LL:0(5) =LL-1:D(6)}=-1:D(7)=-LL-1

950 DT=TR-TL:DL=BL-TL:SZ=BL+24*D(1)

960 CLS:PRINT"Do you want instructions (¥/N}"; 965 INPUTA$: IFAS="Y¥"THENGOSUBS000: GOTOL00G

980 GOSUBS050

1006 CLS: INKO:FAFERZ

1100 FORA=TLTOTR: POKEA, WS: POKEAtDL WS: NEXT 1105 FORA=TLTOBLSTEPLL: POKEA,WS: FPOREA+DT WS: NE XT

1110 TD=DT-4:S5D=(DL-4*#LL)/LL:RX=INTCRND (i) *#TD+ 1}

1120 RY=INTCRND(1)#5D+1):RP=SZ+RX-RY*LL: PORERP yR5S

1170 SX=INTCRND (1) *TD+1):SY=SINTCRND (i) #5D+10:5 H=5Z+SX-SY#LL

1175 IFPEEK(SH)<232THENII70

1180 $(LS}=SH:5P=SH: FORESF,S5:FORA=LS-LTOISTEF -1

1190 NF=SF+D (RD)

1195 IFPEEK (NF) < s32THENRD=INTIRND (i) #84+1):60T0 1196

105

The Atmos Book of Games

1200 SP=NP:5(A)=NF:POKESP,SS:NEXT 1210 SH=S(LS):PLAVG,1, 4,100: 607020 2000 XX=46080+2*6:FORO=KXTOXK+7:READU: FOREC,U: NEXT:RETURN 2010 DATAIB,30,12,63,12,12,30,51,12,12,18,51,5 1,16,12,12,0,0,0,0,33,16,i2,12 2020 DATAQG,4,6,48,48,8,4,0,12,12,18,33,90,0,9,0 999864555 4,8 ld 2030 DATA463,63,63,63,63,63,63,65 5000 CLS:FRINT"You are a hungry snake chasing” :FRINT’a rat. Your poison i5 5a deadly” 5005 PRINT"that even to touch your skin is":FR INT"fatal - so don’t bite yourself!" S019 FRINT"You must catch and kill the snake": PRINT"in time ";TE S015 PRINT"Long snakes can encircle the rat"sF RINT"more easily but you are more” S020 PRINT"likely to bite yourself." PRINTIPRINT"Avoid hitting the walls - at "SPRINT "speed you're maving hitting! 35 PRINT’ your head will probabiy be fatali" O40 PRINTIPRINT"’Controls - use the keys aroun Sr":PRINTSPO (ial y “w” FRIANTSPO (la): 7A De sPRINTSPO OLB) Ox" FRINT?:FRINT"How long de yeu want to te, ¢ ram’aPRINTTS:" units ta “y8Ss FRINT units s:iNPUuTLS PFLS< TSGRLS?BSTHENSOSO GO FRIQTSPRINT* input skill levei, i tor siow rats":PRINT"up to 1% for very fast"; waGc INPUTSL: 1 FSLS iGRSLeLOTHENS OBO ai0G S=LS:SbLe5bl/10:RE TURN

106

Catch

In Catch numbers bounce around the screen and off obstacles. If you can catch the numbers they are added to your score. At the higher skill levels there are an awful lot of obstacles and things can get very difficult!

Programming the movement of the number as it bounces off obstacles is fairly straightforward, because to make the number harder to catch its movement should be unpredictable. A number must sometimes bounce in a different direction if it hits the same obstacle more than once, otherwise a player need only ‘lie in wait’ for the number to catch it. Line 160 thus chooses a completely

107

The Atmos Book of Games

random movement for the number ball whenever it strikes an obstacle.

For similar reasons the number’s initial appearance on-screen must be unpredictable, and lines 260-290 ensure that it appears randomly from one of the four corners of the playing area.

Program notes

10 Keyboard click and cursor off.

20-100 Keyboard control routine. The player tries to catch the number by moving in any of the 8 major compass directions.

110-130 Player move routine. 110 finds the new position and checks that it is not a wall. If it is not, it must be either a space ora number, and 120 adds this number to the score if necessary. 130 pokes the player’s symbol to its new position.

150-210 Number move routine. 150 finds the new position and erases the number from its previous position. 160 picks a random direction of movement when an obstacle is hit. If the number hits the player’s symbol, the number value is added to the score, 170. 180 moves the ball to its new position, 190 shows the time taken so far, 200 is a pause whose length depends on the skill level, and 210 ensures that the whole procedure is repeated until the time limit is exceeded.

220-230 Game end routine, giving the score.

250-320 Ball serve routine. 250 checks that not all the balls have been used, 260 chooses a random diagonal movement for the number, and the remainder of 260 and lines 270-290 pick the appropriate corner from which the number is ‘served’. 300 finds the number’s new position and 320 places it there.

900-950 Initialisation routine.

960-1160 Game set-up routine. 1100-1105 draws the sides of the playing area, 1120-1150 pokes random obstacles on-screen, their number depending on the skill level. 1160 pokes the player’s symbol on-screen.

2000-2010 User defined character creation routine. 5000 onwards instructions and setting of skill level.

108

Catch

Important variables

BD

Ball direction of movement used to choose value from D( ).

BV Ball velocity. High values slow ball.

MD _ My direction of movement used to choose value from D( ).

MP My position.

NB Number ball new position.

NP My new position.

NW_ Number of obstacle walls.

S Score.

WP _ Wall position for obstacles.

WX Wall x coordinate relative to BL.

WY Wall y coordinate relative to BL.

Symbols used

BS Number ball symbol set to character code for numbers 0-9.

MS Mysymbol.

OS Zero symbol character code for number 0.

TS Top symbol character code for number 9.

WS __ Wall symbol used for both walls and obstacles.

10 FRINTCHR# (6) CHRE (17): 6070900

ed

REPEAT: Af=KEY#:NDRGs LFAS="W"THENMD=0

30 ITFAS="E"THENMD=1 40 TFA="D"THENMD=2 50 IFA#="C"THENHD=3 60 TFAS="X"THENND=4 7O TFA="Z2"°THENMD=5 BO ITFA#="A"THENMD=6é 90 TFAS="Q"THENND=?

109

The Atmos Book of Games

100 LTFND?7THENLSG

110 NF=MP+D (HD) :P=PEER (NP): IFRPSWSTHENIOO

i270 [FPé 232 THENS=S+5L*(F-OS) :FORENP,32:G0T0250

120 FOREMF,32:MP=NP:POREMF MS

150 NB=BP+D(BD):B=FEER (NB): FORERP, 32

160 IFRB=WSTHENBD=2*INTCRND(1)#474+1:G0T01590

{70 [FR=NSTHENS=5+SL#(BS-05) :607TG25u

180 BF=NB:FOKERF,BS

190 THTt+i:PLoTi?,24,STR#(T)

200 WAITCBY)

210 UNTILT?=TE

220 CLS:PRINT" You scored "35:" points at skill levei "35.

25Q END

250 PING: IFBS<TSTHENBS=85+1

260 BD=2*INT(RND (1) #4) 41: TF BD=1LTHENBP=BL

270 TFBD=3THENBPETL

280 IFRED=STHENBFE=TR

290 [FBD=7THENBF=BR

200 BP=BP+D (BD): TFPEER (BP) < 2 S2THENZ OO

320 POREBF,BS:GO0TOZ0

900 TL=fBBD2: TREEBBFS: RL=£BECA: BR=fBEED: LL a4

910 05-48: 75=57: BS=OS:N5=9i:WS=92

G15 FORZ=917TO92: GOSUBZ000: NEXT

920 S20: 7T=0: TE=200

930 DCQ)=-LLID (dy =-LLti: De 2s =i DCS) aLLti

940 D4) SLL: D(5)=LL-i:0(6)=-1:D¢7)=-LL-1

$50 DT=TR-TL:DBL=BL-TL:MFP=BL-LL+ti1

960 CLS:FRINT"Do by want instructions «i¥/N)";

965 INFUTAE:TFAS="¥"°THENGOSUBSOO0:GOTO1004

980 GOSUBSGSG

igoo CLS

1100 FORA=TLTOTR: POKEA,WS:FOKEA+DL, WO: NEXT 1105 FORA=TLTOBLSTEFPLL: FOKEA,WS:POKEAt+DT WS: NE XT

1120 DT=BT-6:DL=(DL/LLI-6:FORA=1TONW

LidG WKEINTCRND (i) #DT+3) :WY=INTCRND CLI ¥OL +3) Ww

P=BL+Wk-WY FLL

1140 IFFEEK(WF)< F32THENLTI30

1150 FOREWP, WS: NEXT

1155 PLOTLi,24,"TIME:"

1160 POREMP,MS:G0T0250

ZO00 KX=46080+2468:FORG=XKTOXX+7:READU:FOREC,U:

NEXT: RETURN

mt

110

2010 DATA6S,51,45,30,30,45,51,63,63,63,63,63,6 3,63,63,63

S000 CLS:PRINT"You must try to catch the numbe rs":FRINT"bouncing on the screen.”

5005 PRINT"The first number is I: after that": FRINT"numbers increase by 1 until 9 is”

5010 FRINT"reached. To make things harder, the "SPRINT"speed of the ball and the"

S20 PRINT*number of obstacles on screen also” rPRINT® vary with the skill level."

Suga PRINTSPRIN? "Controls ~- use tne keys aroun d the":FRINT"S to moves!

SO4G FRINTSPC(16);"Q W E":PRINTSPC(i7)3"A 8S 0" :PRINTSPCiiBiy"2 x C"

5050 PRINT: PRINT"Input your skill level, 1, ea sy, to“:PRINT"10,hard";

5060 [NFUTSL:TFSL¢LORSLe1OTHENSOSO

S070 NW=SL#2:BV=11-SL:RETURN

Catch

111

Canyon Bomber

Bae Weer.

In this game you must drop bombs into a canyon filled with numbers. Each number hit is added to your score. Bombs fall at an angle, and the game becomes quite difficult when there are just a few numbers left, as you are only allowed a limited number of bombing runs which produce no addition to your score.

The setting up of the canyon is a complex matter, as it is randomly drawn each time, and the screen locations for the top and bottom of the canyon must be determined. The canyon must also not contain any ‘blind’ spots which cannot be bombed.

112

Canyon Bomber

As the canyon is constructed in subroutine 3000, a column of numbers is drawn over each position. As the bombs fall at an angle, it is easy to knock the middle out of a column of numbers. To leave the remaining numbers hanging in the air would be unattractive, to say the least!

So every time a bomb strikes, line 140 moves all the numbers above the strike position down one line. This involves a lot of peeking and poking, so in this program a running score is omitted to help speed things up. A final score is, however, given at the end.

Program notes

10 Keyboard click and cursor off.

20-50 Plane move routine. 20 finds the plane’s new position and checks if it has reached the right or left of the screen. If so, 25 reverses the flying direction, and the appropriate plane symbol is picked, the remainder of 25, and 26. 30 checks to see if the previous run across the screen produced a scoring hit. 40 adds one to the bomb misses if necessary, and checks if the allowable miss total has been reached. 50 then pokes the plane to its new position.

60-110 Bomb drop routine. BF is the bomb flag, if in 60 this is 1, a bomb is dropping and another may not be dropped until this one explodes. 70 is a keyboard control to see if you wish to drop a bomb. 80 sets the initial bomb position to that of the plane, and 90 moves the bomb to a new position and checks if the canyon wall has been hit. 100 draws the bomb at its new position and then erases it. If the bomb has moved to an empty position, the program loops back to move the plane again, 110.

120-150 Rearrangement of numbers plus scoring routine. 120 adds the number hit to the score, and notes that the number hit is now one more. 140 moves down all the numbers above the one hit so that the empty space is filled, 150 continuing the movement until all the numbers in that particular column have been moved down.

155-170 Score: this is doubled if all the numbers have been hit, 155.

113

The Atmos Book of Games

900-1005 Initialisation of variables. This section is longer than usual because it involves the random determination of the positions of the left and right cliff-top sections of the canyon, plus the left and right canyon bottom positions. 1000 makes sure the canyon bottom is not off-screen.

1010-1100 Game set-up routine. 1020-1100 draw the canyon, all using sub-routine 3000 to draw different parts of the canyon. 1080 gets rid of two excess numbers introduced in the process, 1100 pokes the plane to its start position and play begins.

2000-2020 User defined character creation routine.

3000-3050 Draw canyon subroutine. This also puts a number stack above each part of the canyon. First the canyon floor is poked into position, 3000. 3005 and 3010 between them randomly determine the first number to be poked onto this part of the canyon. Successive numbers poked above this will be of lower value. 3030 counts the numbers as they are poked onto the screen, and calculates the position and value for the number to be poked above the present one. If this value is one or more, and the position is not above the right-hand cliff top, this number can also be poked to the screen, 3040. Otherwise the program will move to the next position along the canyon and repeat the process, 3050.

5000 on instructions.

Important variables

BD Bomb direction of movement diagonally left or right. BF Bomb flag set to 1 when bomb is dropped.

BH Bomb hit flag set to 1 when hit is made.

BM __ Bomb miss count.

BP Bomb present position.

BT Total bomb misses allowed.

CB Biggest depth canyon can have. This cannot exceed half the distance between the two cliff tops, otherwise it becomes difficult to join the bottom of the canyon to the other cliff top.

114

CD CL CM CR DC DT LB LM LE LS ML

MR

NB NC NH NP PM PN PP

RB RM RE RS

Canyon Bomber

Canyon depth.

Canyon base left position.

Minimum canyon depth.

Canyon base right position.

Distance vertically of canyon top from TL. Distance between top left and top right of screen. Biggest length cliff top on right can have. Minimum length cliff top on left can have.

Left end position of cliff top.

Left start position of cliff top.

Canyon left side slope, as well as bomb drop movement when plane moves left to right.

Canyon right side slope, as well as bomb drop movement when plane moves right to left.

New bomb position.

Count for numbers poked at start.

Count for how many numbers have been hit. New plane position.

Plane movement.

Position one above NB.

Plane position.

Score.

Biggest length cliff top on right can have. Minimum length cliff top on right can have. Right end position of cliff top.

Right start position of cliff top.

115

The Atmos Book of Games

Symbols used

BS Bomb symbol.

OS Nought symbol— character code for number zero. NS Nine symbol character code for number nine. PS Plane symbol either to right, P1, or left, P2.

WS_ Wall symbol used for cliff top and canyon sides.

1G PRINTCHR# (6) CHRE (17): 60TO900

20 NPSPP+PM: TFNP? 3>TLANDNF« ¢TRTHENSO

29 PRS-PM:BD=2*LL-8D: TFPMe OTHENPS=F2

26 TFPMPQTHENPS=PF i

20 ITF BH=iTHENBH=0:G0TG54

40 BMSEM+i: TFRM=BTTHENCLS:6CTO1S0

a0 POREPP,32:FP=NP:POREPP.PS

60 [FBF=1THENDO

70 AF=KREVS: [FASE E"B"THENZE

80 BP=PF:RF=i: 08=8D

90 NB=BP+DR:PR=FEER ONB} : TFPB=WSORPEER (NE-LL) =u STHENBF=O: EXPLODE: GOTOES

100 BP=NB:PORERP, BS: WAIT (i) :POKERF, 32

110 [FPB=32THENZC

120 $=9+PR-05: BH=1:NH=NH+1: IFNH=NCTHENS=S#2: 50 TOLSS

14G PN=NB-LL:PB=PEER (PN): PORENB,PR: TFPR=S32 THEW ZO

iSd NE=PN:GOTOL40

155 CLS;FRINT"You hit them all and double your "SPRINT"score, "

160 FRINT"You scored ":S;"points.”®

170 END

GOG TL=f£BCGA: TR=£BCRD: BL=£RECA: BR=£BEED:LL=49 910 GS=46:NS=S7:P1=91:RBS=92:WS=93:P2=942 PS=P i 915 FORZ=91 7094: GOSUBZ000; NEXT

S20 S=0:RBM=O:NH=G:BT=3:LB=5:LM=i:RB=SiRM=1:0C= 1:CM=?

943 PP=TLiPN=1:BD=LL+1:; BF=0: BH=G

FOO OTSTR-TL:iLS=TLt+LL #00: LESLS+INT ( (LC B-LM) #RND (1.4L)

G60 RESLS+DT: RS=RE-INT((RE-RM} #RND (CL) +RM)

S70 MLELL ti: MR=LL-i:LaTL+OC#ML: R=TRt+OC#eMNR: TFLE eLITHENLESL

116

Canyon Bomber

580 IFRS?:RTHENRS=R

G0 CBHINT(CRS-LEI/2)

1000 CD=INTC(CB-CNI SAND (Li +CA) s TFLE+CDRLL GY BLTH ENLOGO

1005 CL=LE+CD#Mh: CRERS+CD#NR

1910 CLS:PRINT"Bo you want instructions (¥eNi®

L015 [NFUTA#: IFAF="¥ "THENGOSUBSGGG

fo2O INKO:PAPER4: CLS: B=LS:C=LE:ST=i:G05UB3000

1040 B=LE:CeCL:ST=ML: GOSUBRS000

{O50 BSCL+i:CeCR-i:ST=1:G05UR 2000

i060 BSRS:C=CRrST=MNR: GOSUBSO00

LG70 BERS: C=RE:ST=1:GOSUB3000

1080 PORELE,32:FORERS,32:NC=NC-2

1100 BD=ML:POREPP,FS:G0To2¢

2000 ¥k=46080+72"6:FORO=XK4TOXR E+ 7s READU: POE

MEXT?: RETURN

2010 0ATA16,8,36,63,4,8,16,0,0,10,4,.4,4,4,0,0,

63,63,63,63,63,63,63,635

2020 DATAZ,4,9,63,8,4,2,9

2000 FORA=BTOCSTEPST: TS=NS:F=A:FPOREAt+LL WS

$005 IFC=LEQRCSREGRFEER CF i< #32 THENSGSG

AGLO LFRND(L?<. STHENTS=TS-i

SO20 [TFRND(1)4,. SANDTSsO5+1 THENSO10

BORG NC=NC+L:FOQREP,TS:1F 7S2G5+iTHENPS=P-LL: TSS7

a4

3040 [FTS>GS+1ANDFERSTHENSOSG0

3050 NEaT:RETURK

S000 CLO:FRINT "You cantrol a bomber flying ave

reaPRIN?"a canyon. fin each pass yau"

BOLO PRINT must mit at least ane number int :FR

INT"the canyon, whose value will"

SG PRINT"added to vour score, You may miss":

PRINT"just ";BT:" times, then the game’

anes FRIANT“ends. You may oniy droog ane bomb at rFRINi "a time, and no others can te"

O40 PRINT dropped while that one is in tiight

RINT The bomb will faii at an angle’

5050 FRINT"Controis - press & toa drop a fomb. *

:FRINT"Press any key to begin.”

S050 REPEAT: GETAS:UNT ILA. o" "SP RETURN

uu:

rey

ae

117

Other titles available from Micro Press: THE MICRO MAZE: A GUIDE TO PERSONAL COMPUTING Wynford James

0 7447 0000 0

20 GAMES FOR THE ORIC-1 Wynford James

0 7447 0003 5

QUALITY PROGRAMS FOR THE BBC MICRO

Simon

0 7447 0001 9

QUALITY PROGRAMS FOR THE BBC MICRO (Cassette) Simon

0 7447 00116

15 GRAPHIC GAMES FOR THE SPECTRUM

Richard G. Hurley

0 7447 0002 7

MASTERING THE TI-99

Peter Brooks

0 7447 0008 6

ADVANCING WITH THE ELECTRON

Peter Seal

0 7447 0012 4

QUALITY PROGRAMS FOR THE ELECTRON

Simon

0 7447 0004 3

MAKING THE MOST OF YOUR SPECTRUM MICRO DRIVES Richard G. Hurley

0 7447 0005 1

GRAPHIC ADVENTURES FOR THE SPECTRUM 48K

Richard G. Hurley

0 7447 0013 2

THE SPECTRUM OPERATING SYSTEM

Steve Kramer 0 7447 0019 1

EDUCATIONAL GAMES FOR THE BBC MICRO

lan Soutar

0 7447 00167

SPECTRUM SUPERGAMES Richard G. Hurley

0 7447 00175

THE COMMODORE 64 BOOK OF SOUND AND GRAPHICS Simon

0 7447 00159

QL SUPERBASIC: A PROGRAMMER’S GUIDE John Wilson

0 7447 0020 5

THE QL HANDBOOK

P.C. Sturgess and

M.J. Laverick

0 7447 0021 3

THE QL BOOK OF GAMES Richard G. Hurley

0 7447 0022 1

THE ATMOS BOOK OF GAMES

The twenty programs in this book cover diverse and highly eYahcciat-lialiare Mer-laatcsomel=s-}(e]al-10me)m tal-m Ola (ow -WN\ Ole mm Mal-y a aal- 1. dc full use of all the machine’s facilities.

There are popular arcade games such as CATERPILLAR and BOMBER, as well as more intellectual challenges as in the ARTIFICIAL INTELLIGENCE PROGRAM.

aM al-u-) cq (cid0la-Mo)m-t-[elame)geyele-lanmi-MiUliNVa->.4e)(-]lal-re ml damale)(cs-ne) a) what each section does. A complete list of variables is also relae) vale |=re Pm =)vam avg ©) [ale Milam dal-s-- o] cele] e-]aal-emn (al-Mg-t-[e(-]@rer-lamer-lia) Taksite|al am ialcomm cal-mr-10] ale] mt-mm olaeolele-laalaaliarem ccceialalle leita ellare| aliaam Come(-\YZ1 (0) oMall-me)Zam olaelele-laamu cal clare p

The Author

Wynford James writes educational material (including Yous ns'-1:) mice) ae; Mm ant-) (el muaal(ergelere)anleleic-1mevolanl ey-la)’am ma (elm coment) he was a technical author for ICL. He has also taught mathematics and was actively involved in the development of (rola) olUjcc1mr-j ce lel [-t-magicele le) arelel mall-w-xelalele) B

6B # NET +005-495 ISBN 0-7447-0018-3

| | |

9 *780744"700183

| THE ATMOS BOOK OF GAMES James