image of READY prompt

Wang2200.org

Listing of file='TOWER' on disk='vmedia/games_vol_3.wvd.zip'

# Sector 343, program filename = 'TOWER'
0001 REM % TOWER OF HANOI - GRM
0020 DIM C$1,D$(9)20,L(9),G(11,3),I$1,K$5,L$1,M1$60,M2$60,M3$60,R$20,T$1
0030 PRINT HEX(06)
   : PRINT HEX(0202020F)
   : K$=HEX(020402000E)
0040 D,L,C=0
0050 PRINT HEX(03)
   : PRINT AT(2,20);HEX(020402040E);"WELCOME TO THE TOWER OF HANOI";HEX(0F)
   : PRINT
   : PRINT "   The object of this puzzle is to transfer all the discs in the '
     TOWER'"
   : PRINT "   on the left hand side of the screen (ie Tower A) and form an id
     entical"
0060 PRINT "      tower on the right hand side of the screen (at tower C)."
0070 N=4
   : T=VAL("A")-64
   : GOSUB 510
0080 PRINT AT(17,3);"Any disc may be moved to any tower, any number of times.
      However, you"
   : PRINT "   can only move one disc at a time - from the top of one tower to
      the top"
   : PRINT "   of another tower.  You can not transfer a larger disc on to the
      top of"
0090 PRINT "   a smaller disc."
0100 PRINT AT(22,20);"Any key .. ";
   : KEYIN T$
   : IF T$="0"THEN 230
   : PRINT AT(22,20,20)
   : PRINT
   : PRINT AT(22,5);"  PLEASE NOTE:  To terminate the game, key '0' at any inp
     ut."
   : PRINT
   : PRINT "       You can play with any number of discs between 4 and 9,  but
     "
0110 PRINT "       remember, the more discs there are, the longer it takes !!"
   : PRINT
   : PRINT
0120 PRINT AT(23,7);"How many discs would you like in the tower (4 to 9) : ";
   : KEYIN T$
   : IF T$="0"THEN 230
   : CONVERT T$TO N
   : ERRORPRINT HEX(07);
   : GOTO 120
0130 IF N=0THEN 230
0140 IF N>3AND N<=9THEN 150
   : M1$="I don't believe it! - I thought choosing a number between"
   : M2$="4 and 9 would be easy enough!"
   : FOR I=1TO 3
   : PRINT
   : NEXT I
   : GOSUB 360
   : PRINT "     If you can not decide, you had better key zero '0'"
   : PRINT
   : PRINT
   : D=1
   : GOTO 120
0150 D=0
   : IF C>0THEN 160
   : IF L<NOR L=9THEN 160
   : PRINT
   : PRINT "Come on chicken.  You've already played with ";
   : IF L=NTHEN PRINT "that many discs before."
   : ELSE PRINT "more discs than that"
   : PRINT TAB(11);"How about a bit of a challenge and try more discs"
   : C=1
   : GOTO 120
0160 PRINT
   : T=VAL("A")-64
   : K=0
   : GOSUB 450
0170 REM  NOW READY TO PLAY !!!!!
0180 REM  DO LOOP BEGIN
0190 GOSUB 280
   : GOSUB 300
   : IF R2=1THEN 190
   : GOSUB 310
   : IF O=0THEN 190
   : GOSUB 320
   : IF S=1THEN 190
0200 GOSUB 410
   : GOSUB 250
   : GOSUB 260
   : GOSUB 270
   : IF D0=1THEN 220
0210 IF F=1THEN GOSUB 240
   : GOTO 180
0220 GOSUB 420
   : IF T$="Y"THEN 120
0230 PRINT HEX(0202000F)
   : LOAD T"GAMES"
   : ERRORLOAD T"START"
0240 M1$="Ha Ha You think you've finished don't you - Don't be a fool"
   : M2$="You have to move the discs to tower \C3 not tower \C2 !!"
   : GOSUB 360
   : RETURN
0250 PRINT AT(14-N2,T0*20-2-(LEN(D$(M))-1)/2);D$(M)
   : G(N2+1,T0)=M
   : L(M)=T0*100+N2
   : K=K+1
   : PRINT AT(16,67);K
   : RETURN
0260 C$=BIN(F0+64)
   : R$=" "
   : STR(R$,10,1)=HEX(86)
   : PRINT AT(14-R,F0*20-11);STR(R$,,18)
   : G(R+1,F0)=0
   : RETURN
0270 D0,F=1
   : FOR I=1TO N
   : IF G(I+1,2)<>N-I+1THEN F=0
   : IF G(I+1,3)<>N-I+1THEN D0=0
   : IF F=0AND D0=0THEN I=N
   : NEXT I
   : RETURN
0280 PRINT AT(18,48,30);
   : KEYIN T$
   : PRINT AT(18,48);T$;
   : IF T$="0"THEN 230
   : M=VAL(T$)-48
   : IF M>0AND M<=NTHEN 290
   : M1$="Life's hard enough without making me go round the bend"
   : M2$="looking for discs that don't even exist !"
   : GOSUB 360
   : GOTO 280
0290 PRINT AT(20,39,40);
   : KEYIN T$
   : PRINT AT(20,39);T$
   : IF T$="0"THEN 230
   : T0=VAL(T$)-64
   : IF T0>0AND T0<4THEN RETURN
   : PRINT AT(22,12);K$;"Got the directions, I think that tower is in Timbucto
     o !!";
   : PRINT AT(23,12);"How about a little closer to home?  ---> Like A,B or C."
     ;HEX(0F);
   : GOSUB 390
   : GOTO 290
0300 R2=0
   : F0=INT(L(M)/100)
   : R=L(M)-(100*F0)
   : IF F0<>T0THEN RETURN
   : M1$="Oh boy.  Got a right one here.  You want me to move"
   : M2$="from tower "&T$&" to tower "&T$&"     BIG DEAL !"
   : GOSUB 360
   : GOSUB 410
   : R2=1
   : RETURN
0310 O=1
   : IF G(R+2,F0)=0THEN RETURN
   : M1$="   No can do.  Union rules say one at a time"
   : M2$="Besides,  it might hurt my back!"
   : O=0
   : GOSUB 360
   : GOSUB 410
   : RETURN
0320 S=0
   : FOR I=1TO N
   : IF G(I+1,T0)>0THEN 350
   : IF G(I,T0)>M THEN 330
   : M1$="HELP!  You would squash me!  Leave that steaming"
   : M2$="     great disc where it is."
   : GOSUB 360
   : S=1
   : GOSUB 410
   : GOTO 340
0330 N2=I
0340 I=N
0350 NEXT I
   : RETURN
0360 PRINT AT(22,7);HEX(020402000E);M1$
   : PRINT AT(23,12);M2$;HEX(0F);
   : IF D=0THEN 390
0370 PRINT
   : PRINT
   : PRINT ,"So I was wrong.  It was too hard!"
   : PRINT
   : PRINT ,"This game will be TOO hard for you."
   : PRINT ,"  I suggest you try another game."
   : PRINT
   : PRINT
0380 PRINT AT(23,23);HEX(02040B020E);"* * WAIT A MINUTE * *";HEX(0F);
   : GOSUB '40(10)
   : GOTO 230
0390 GOSUB '40(5)
0400 PRINT AT(22,0,79)
   : PRINT AT(23,0,79);
   : RETURN
0410 PRINT AT(18,48,30);AT(20,39,40);
   : RETURN
0420 L=N
   : PRINT AT(18,1,79);AT(20,1,79);
   : M3$="Join the happy club.  You've joined the majority of players."
   : IF K<=2^NTHEN M3$="I can see you've done this before (or else you're very
      lucky.)"
0430 IF K>2^(N+1)*.75THEN M3$="I'm glad that's over - I was beginning to think
      it wouldn't end!"
   : IF K>=2^(N+1)THEN LET M3$="     A new world record for the number of move
     s !"
   : PRINT AT(19,8);M3$
0440 C=0
   : PRINT AT(21,5);"Would you like to try another round ";
   : KEYIN T$
   : IF T$="0"THEN 230
   : PRINT
   : RETURN
0450 PRINT HEX(03)
   : PRINT AT(2,31);"TOWER OF HANOI"
0460 FOR J=1TO 3
   : G(1,J)=10
   : FOR I=2TO 11
   : G(I,J)=0
   : NEXT I
   : NEXT J
0470 FOR I=1TO N
   : L(I)=N+1-I+T*100
   : G(I+1,T)=N+1-I
   : NEXT I
   : GOSUB 510
0480 PRINT AT(16,6);"A perfect game with";N;"discs requires";2^N-1;"moves.";TA
     B(56);"Moves made = 0"
0490 PRINT AT(18,5);
   : PRINTUSING "Which disc do you want to move (1 to #) : ",N;
   : PRINT AT(20,10);"To which tower (A,B or C) :"
0500 RETURN
0510 FOR J=14TO 15
   : FOR J1=6TO 71
   : PRINT AT(J,J1);HEX(FF);
   : NEXT J1
   : NEXT J
0520 FOR I=18TO 58STEP 20
   : L$=BIN((I+2)/20+64)
   : FOR J=13-NTO 14
   : PRINT AT(J,I);
   : IF J=14THEN PRINT L$;
   : ELSE PRINT HEX(86);
   : NEXT J
   : NEXT I
0530 FOR I=1 TO N
   : CONVERT ITO I$,(#)
   : STR(D$(I),,1)=I$
   : STR(D$(I),1,2*I+1)=ALL(HEX(CF))
   : STR(D$(I),I+1,1)=I$
   : NEXT I
0540 FOR I=NTO 1STEP -1
   : X=T*20-2-(LEN(D$(I))-1)/2
   : PRINT AT(13-N+I,X);D$(I);
   : NEXT I
   : RETURN
0550 DEFFN'40(Y)
   : SELECT P3
   : FOR I=1TO Y
   : PRINT HEX(070D);
   : NEXT I
   : SELECT P0
   : RETURN