Towers of Hanoi 2068 (Syntax)

Developer(s): William Andrews
Date: 1984
Type: Program
Platform(s): TS 2068
Tags: Game

The TS2068 version of the Towers of Hanoi from the same article as the ZX81 program, with colored platforms and blocks. Press the number of the platform to move from, then the one to move to. Putting a larger block on a smaller one flashes *NO-NO* and THAT’S NOT LEGAL!, and tells you to move it back. Finish with all five blocks on platform 3; the program shows how many moves you took. GOTO 760 saves it with an instruction screen.

As printed, lines 590 and 615 go to lines 650 and 1000, which are not in the listing; the TS2068 carries on at the next lines (659 and 1010), so the game works as intended.

Published in Syntax October 1984 (Towers of Hanoi).

Image Gallery

Source Code

   4 PAPER 6
   6 FOR N=0 TO 21
   7 PRINT INK 6;AT N,0;"                                "
   8 NEXT N
  10 BORDER 4
  30 LET E$="         "
  40 DIM N$(10,23,9)
  50 DIM A$(5,9)
  60 DIM P(10,23)
  70 LET A$(1)="███▌1▐███"
  80 LET A$(2)="███ 2 ███"
  90 LET A$(3)="██  3  ██"
 100 LET A$(4)="█   4   █"
 110 LET A$(5)="    5    "
 120 LET S=0
 130 LET N=1
 140 LET R=11
 150 FOR C=1 TO 23 STEP 11
 160 PRINT PAPER 5;AT R,C;"█▀▀▀▀▀▀▀█"
 170 PRINT PAPER 5;AT R+1,C;"█   ";N;"   █"
 180 PRINT PAPER 5;AT R+2,C;"█▄▄▄▄▄▄▄█"
 190 LET N=N+1
 200 NEXT C
 210 LET C=1
 220 FOR R=6 TO 10
 230 LET P(R,C)=1
 240 NEXT R
 260 GO SUB 870
 270 FOR R=6 TO 10
 280 FOR C=1 TO 23 STEP 11
 290 IF P(R,C)=1 THEN LET N$(R,C)=A$(R-5)
 300 PRINT INVERSE 1; INK 1;AT R,C;N$(R,C)
 305 IF P(R,C)=0 THEN PRINT INK 6;AT R,C;"         "
 310 NEXT C
 320 NEXT R
 330 PRINT AT 15,11;"                  "
 340 PRINT FLASH 1;AT 15,14;"MOVE"
 350 PRINT AT 17,8;"FROM- ";
 360 PAUSE 0
 370 LET F$=INKEY$
 372 IF F$<>"1" AND F$<>"2" AND F$<>"3" THEN GO TO 360
 375 LET F=VAL F$
 390 PRINT F;" TO- ";
 400 PAUSE 0
 410 LET T$=INKEY$
 412 IF T$<>"1" AND T$<>"2" AND T$<>"3" THEN GO TO 400
 415 LET T=VAL T$
 420 IF T>3 OR T=F THEN GO TO 400
 430 PRINT T
 440 LET S=S+1
 450 IF F=1 THEN LET C=1
 460 IF F=2 THEN LET C=12
 470 IF F=3 THEN LET C=23
 480 FOR R=6 TO 10
 490 IF P(R,C)=1 THEN PRINT AT R,C;E$
 500 IF P(R,C)=1 THEN LET Z$=N$(R,C)
 510 IF P(R,C)=0 THEN GO TO 540
 520 LET P(R,C)=0
 530 GO TO 550
 540 NEXT R
 550 IF T=1 THEN LET C=1
 560 IF T=2 THEN LET C=12
 570 IF T=3 THEN LET C=23
 580 FOR R=10 TO 6 STEP -1
 590 IF P(R,C)=1 THEN GO TO 650
 600 IF P(R,C)=0 THEN LET N$(R,C)=Z$
 610 PRINT INVERSE 1; INK 1;AT R,C;N$(R,C): INVERSE 0
 612 IF R>=10 THEN GO TO 620
 615 IF Z$(5)>N$(R+1,C,5) THEN GO SUB 1000
 620 LET P(R,C)=1
 630 IF R=6 THEN GO TO 660
 640 GO TO 740
 659 NEXT R
 660 BORDER 2
 665 PRINT  AT 15,14;"    ";AT 17,5;"YOU DID IT IN "; FLASH 1;S; FLASH 0;" MOVES"
 670 PRINT AT 21,4;"WANT TO TRY AGAIN? (Y/N)"
 680 IF INKEY$="" THEN GO TO 680
 690 IF INKEY$="Y" THEN RUN
 700 CLS
 710 PRINT AT 10,14;"BYE-"
 720 PAUSE 0
 730 STOP
 740 PRINT AT 17,8;"                   "
 759 GO TO 330
 760 SAVE "TOWERS" LINE 780
 780 CLS
 785 GO SUB 870
 790 PRINT AT 4,0;"OBJECT OF THIS GAME IS TO MOVE"
 800 PRINT ,,"FIVE BLOCKS FROM TOWER 1 TO",,,"TOWER 3 IN THE SAME ORDER."
 810 PRINT ,,"A SMALLER BLOCK MAY BE PLACED ON",,"A LARGER BLOCK BUT NEVER A LARGE",,"ONE ATOP A SMALLER ONE."
 820 PRINT ,,"THAT COSTS EXTRA MOVES."
 830 PRINT ,,,,"NUMBER OF MOVES WILL BE SHOWN",,,"WHEN YOU FINISH THE GAME."
 849 PAUSE 0
 850 CLS
 860 GO TO 4
 870 PRINT INK 2;AT 0,8;"▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄"
 880 PRINT INK 2;AT 1,8;" TOWERS OF HANOI "
 890 PRINT INK 2;AT 2,8;"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀"
 900 RETURN
1010 PRINT AT 15,14;"    ";AT 17,7;"               "
1020 PRINT INK 2; FLASH 1;AT 15,13;"*NO-NO*"
1030 PAUSE 150
1040 PRINT AT 17,9;"THAT'S NOT LEGAL!"
1050 PAUSE 150
1060 PRINT AT 15,11;"MOVE IT BACK"
1070 PRINT AT 17,9;"                   "
1080 PAUSE 150
1090 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.