Micro­power

  

Volume 1 · Number 4 · December 1981

Page 31 of 33

10                             RINGS OF HANOI
20               BY S.HEAD, JUNE 1981
30 REM
40 CLEAR 500: DIM A(12,2), TR(2,1)
50 REM
60 REM **. . . . . . . Print out rules . . . . . . .
70 CLS: GOSUB 800: PRINT
80 PRINT "The object of the game is to move"
90 PRINT "the rings from pile A to pile B or C
100 PRINT: PRINT "Only the top ring ";
110 PRINT "can be moved."
120 PRINT:PRINT "Larger rings cannot be ";
130 PRINT "put over smaller rings.
140 PRINT:PRINT:PRINT "PRESS ENTERWHEN READY.";
150 INPUT IN$
180 REM
190 REM**. . . . . . . . . Initialise . . . . . . . . .
200 CLS
210 FOR I = 0 TO 10
220 A(I,0) = 1:A(I,1) = 0:A(I,2) = 0
230 NEXT I
240 TR(0,0) = 1:TR(0,1) = 1
250 TR(1,0) = 11:TR(1,1) = 10
260 TR(2,0) = 11:TR(2,1) = 10:MC = 0
270 GOSUB 600
280 GOSUB 800
290 SCREEN 6,15
300 PRINT "PILE A", "PILE B", "PILE C";
310 REM
320 REM ** . . . . . . . . . Input move . . . . . . . . . .
400 GOSUB 920: SCREEN 2,2: PRINT "MOVE FROM ";
410 INPUT N$ 420 GOSUB 1300:TF = IN:IF TF < 0 THEN 400
430 IF A(10,TF) <> 0 THEN 470
440 SCREEN 1,1
450 PRINT "NO RINGS ON THAT STICK CHUM"
460 GOTO 400
470 GOSUB 920:SCREEN 2,2:PRINT "TO PILE";
480 INPUT IN$
490 GOSUB 1300:TT = IN:IF TT < 0 THEN GOTO 470
500 GOSUB 1000
510 GOTO 400
580 REM
590 REM ** . . . . . . . Initialise graphics . . . . . . .
600 CLS: IT = 0: IP = 14:GOSUB 630
610 IT = 1:IP = 42: GOSUB 630
620 IT = 2:IP = 70: GOSUB 630: GOSUB 800
630 FOR I = 0 TO 32
640 FOR J = 0 TO A(I/3,IT)
650 SET (J + IP, I+9)
660 SET (IP –J, I+9)
670 NEXT J
680 NEXT I:RETURN
780 REM
790 REM ** . . . . . . . Print title . . . . . . .
800 TL$ = "TOWERS OF HANOI MOVE "+STR$(MC)
810 FOR I = 1 TO LEN(TL$)
820 POKE 3029+I,ASC(MID$(TL$,I,1))
830 NEXT I
840 RETURN

Page 31 of 33