K/&
a-z ({)()Fro"p"rof"q"uo"r"uof"u"]cof"f"co"e" cofinitia"DPSFCBA"cl"E""H"9( a(,)"Y"( )( )m2 hi(),hit(),(),p(,),p(,),p(,),p(,),nam(),(,),()(< h read names, etc into arrays F cl Titles etcP 7Z Set (or reset) values of various variables)d Computer positions its ships n cl Draw grids'x Player positions his ships Play Play again? clco"menu# Computer positions its ships '(}) ," Vertical'(}
) (}
) p(,)"D" p(,)"P" p(,)"S" p(,)"F" p(,)"C" p(,)"B" p(,)"A" " 9 p(,)() Horizontal'"(}
) ",(}
)6 p(,)"D" p(,)"P" p(,)"S" p(,)"F" p(,)"C" p(,)"B" p(,)"A" ""@ 69J p(,)()T,^ Reading ships' names, etc into arrays#h nam()5r ()(initia,,)'| (,)"*"A (,)()O dinghy,patrol boat,submarine,frigate,cruiser,battleship,aircraft carrierq Fatal,Severe,Non-recoverable,Untrapped,Unexpected,Online,Memory,Illegal,Processor,Remote,Terminal,Global,*m file,monitor,diagnostic,integer,input/output,retrieval,stack,bitstream,increment,mantissa,CPU,system,*} format,error check,verification,modulation,lookup,consolidation,sequencing,assignment,status,buffering,register,load,*| deficiency,failure,corruption,violation,overflow,error,shutdown,underflow,limit exceeded,breakpoint reached,aborted,*! Player positions his ships1 a(,)"All my ships are in position.+ a(,)"Now you position yours.N"I will ask you where on the grid you want to put your various vesselsL"and if they fit there you will see them appear before your very eyes!,"Press a key to continue." u"" K a(,)"Where would you like to position your "nam()"?":"X co-ordinate (0 to 9) ?"; x :&"Y co-ordinate (0 to 9) ?"; x g0 "Do you want it horizontal or vertical (H/V) ?";an"HV" (an,,): DN Vertical'X b p(,)"D" p(,)"P" p(,)"S" p(,)"F" p(,)"C" p(,)"B" p(,)"A" "l b=v p(,)() Horizontal' p(,)"D" p(,)"P" p(,)"S" p(,)"F" p(,)"C" p(,)"B" p(,)"A" " 7 p(,)() z '"Your" ? a(,)()"It won't fit there. Try again." l Draw grids$ a(,)ro(Y)rof9 a(,(Y(titl)))rotitlrof, a(,)ro" YOUR GRID "rof% a(,)"X"a(,
)"Y"+ a(
,)3* a(,) p+4 a(,6)ro" MY GRID "rof&> a(,-)"X"a(,:)"Y",H a(
,.).R a(,0)I\ a(
,1)":" ,%f"My"H Jp a(
,)":" ,`z p(,)"" a(
,)p(,) ,$ Show computer's ships on grid h p(,)"" a(
,1)":" a(
,1)p(,) ," Clear bottom part of screen a(,)"J" Your go or computer's go?F a(,)"I may be a very powerful computer, but I have beenE"programmed by an idiot. So I am going to have the first shot. :gsunsunk sun sunk9gg g(g) `$Q. sun a(,)()"You have sunk all my ships. I surrender!"8 sunk a(,)()"I have sunk all your ships. Surrender, you worm!" l"Would you like to see where all my ships were? (Y/N)"an"YN" BLV Your go=`"Type the co-ordinates of the spot you want to blast.7j"X co-ordinate (0-9) ?"; x 7t"Y co-ordinate (0-9) ?"; x ~ sin""hi""l p(,)"" a(,)()"You have already tried that position. Pick another." `&p(,)p(,)V p(,)"" p(,)"*" a(,)"Splash! You missed! U p(,)() hinam()hi()hi()E hi"" a(,)"Bang!!! You hit my "hi"." b hinam() hi() ()"Glug...glug...glug......You have sunk my "hi"."sin%(x(hi,)) b E sin"" p(,)sin p(,)"$" ,Q
sin"" sinw(initia,sin) a(sin,H) ()
Fz hi() hi() hi() hi() hi() hi() hi() sun.( a(,)"Now it's my turn."2'< Show hits etc on computer's gridF HP p(,)"" a(
,1)p(,)Z ,dn INKEY$ routinexan"0123456789"2"" ""%(u)w(an,)& Set values of various variables@ hi()hit()(dow Tp(,)""p(,)""p(,)""p(,)"" ,; l a(,)"Do you want to play again? (Y/N)Ian"YN" "Please wait while I marshal my fleet. Computer's gochec H chec z ,B"x(}
)y(}
) p(x,y)"" F,"I am aiming a shot at your grid position X"x", Y"y"."'6"Is it a hit or a miss? (H/M)"&@"" ""|J p(x,y)"" a(
x,y)":" b a(
x,y)p(x,y) bT p(x,y)"" a(
x,y)ro":"rof b a(
x,y)rop(x,y)rof b+^%(u)w("HM",) ph """Please confirm: I have missed. (Y/N)"an"YN" 6 r (| k "" 0 hit(k)hit(k)A "Have I hit or missed anything? (H/M)" @0 "hit" p(x,y)"#" hit(k) - "" p(x,y)"*" < sunk a(,)"Now it's your turn.) What has the computer hit or sunk?""hit""What have I hit? 4 "nothing" nam(),%(x(,))|(,()) ();") ";B "Type the number corresponding to the vessel I have hit. ";/an"12345678" k D& a(,)"Please confirm: I have missed. (Y/N)0 hit(k) ()"Don't be a silly billy. Your "nam(k)" is at the bottom of the sea!" l W: a(,)"Please confirm: I have hit your "nam(k)". (Y/N)%Dan"YN"
N
X Delaysb l v- Print computer's hits etc on your grid G p(,)"" a(
,)p(,) ,9 Procedure for when the computer has sunk somethingH a(,)()"Hee hee.....I have sunk your "nam(k)"!"(dow : p(,)(k) p(,)"$" ,% a(k,) () hit() hit() hit() hit() hit() hit() hit() sunk$ List of ships afloat at start` a(,)uo" ships"uofa(,)uo"still afloat:"uofL nam()%(x(,))|(,())'* a(,)4> Check if any hitsH *R p(,)"#" chec\ ,f(p Calculating move after hit scoredz dow E
xy p(x,y)"" h p(x,y)"#" x
y p(x,y)"" F x y p(x,y)"" E
yx p(x,y)"" h p(x,y)"#" y
x p(x,y)"" N yx p(x,y)"" dow
Titles etcP titl" B A T T L E S H I P S "title" a game of wit and strategy "H (title)l(Z) (l)ro()rof, (l)ro()titl()rofD$ (l)rotitlerof (l)ro()rofP. "This is a computer implementation of the traditional 'Battleships' gameP8 "in which you are invited to pit your wits against me, the mighty Amstrad.GB "We shall each have seven ships - (in descending order of size) -L *V ()"an "; ()"a ";` nam()" - ";&j ();t "," "."~ L "I will first marshal my fleet, and then ask you to position yours. "Then the fun will begin.R "We shall fire lethal missiles at each other until either your fleet or mine "is destroyed.= "I promise I will not cheat by 'looking' at your ships.[ "Please be very careful with your responses. A mistake could jeopardise the program., "Press a key to continue." u""1 "Please wait while I marshal my fleet." Error message generator erro"" ; erroerro(,(}()))" "J
a(,)()roerro"in line"(`
(}
))"."rof
co(,(}()))" "J
a