10 REM   WUMPUS II  FROM THE LAWRENCE HALL OF SCIENCE
20 REM   TRANSFERED TO SOL EBASIC BY DAVID FOX
30 REM   REVISED FOR TRS-80 LEVEL II BASIC BY DOUG BENEDICT
40 CLS :PRINT @282,"WUMPUS  II"
41 PRINT @409,"COPYRIGHT BY"
42 PRINT @470,"CREATIVE COMPUTING"
43 PRINT @536,"P.O. BOX 789-M"
44 PRINT @593,"MORRISTOWN, NEW JERSEY 07960"
45 FOR I=1 TO 2000:NEXT I
50 DIM  I$(6),L(6),M(6),P(5),S(20,3)
60 CLS :PRINT  @ 390,"";
70 PRINT  "* * *  T H E  G A M E  O F  W U M P U S  II  * * *"
80 PRINT  @ 896,"";:INPUT  "WOULD YOU LIKE INSTRUCTIONS";Z$
90 IF   LEFT$(Z$,1)="N"  THEN  120
100 IF   LEFT$(Z$,1)<>"Y"  THEN  80
110 F3=1: GOSUB  2580
120 REM   CHOOSE AND SET UP CAVE
130  GOSUB  1890:F3=1
170 REM   LOCATE L ARRAY ITEMS
180 REM   1=YOU,2=WUMPUS,3&4=PITS,5&6=BATS
190 FOR  J=1  TO  6
200 L(J)= RND(20)
210 M(J)=L(J)
220 NEXT  J
230 REM   CHECK FOR CROSSOVERS (IE L(1)=L(2),ETC)
240 FOR  J=1  TO  6
250 FOR  K=J  TO  6
260 IF  J=K  THEN  280
270 IF  L(J)=L(K)  THEN  J=7:K=7: GOTO  190
280 NEXT  K
290 NEXT  J
300 REM   SET # ARROWS
310 A=5
320 L=L(1)
330 REM   RUN THE GAME
340 REM   HAZARD WARNINGS & LOCATION
350  GOSUB  660
360 REM   MOVE OR SHOOT
370  GOSUB  830
380 ON  O  GOTO  400,440
390 REM   SHOOT
400  GOSUB  920
410 IF  F=0  THEN  370
420  GOTO  460
430 REM   MOVE
440  GOSUB  1480
450 IF  F=0  THEN  350
460 IF  F>0  THEN  510
470 REM   LOSE
480 PRINT  "HA HA HA - YOU LOSE!     ";
490  GOTO  530
500 REM   WIN
510 PRINT  "HEE HEE HEE - THE WUMPUS'LL GETCHA NEXT TIME!!"
520 PRINT 
530 FOR  J=1  TO  6
540 L(J)=M(J)
550 NEXT  J
560 INPUT  "WANT TO PLAY AGAIN";I$:CLS 
570 IF   LEFT$(I$,1)<>"Y"  THEN  2300
580 PRINT 
590 INPUT  "SAME SET-UP";I$
600 PRINT 
610 IF   LEFT$(I$,1)="Y"  THEN  310
620 INPUT  "SAME CAVE";I$
630 PRINT 
640 IF   LEFT$(I$,1)="Y"  THEN  190
650  GOTO  120
660 REM   PRINT LOCATION & HAZARD WARNINGS
670 PRINT 
680 FOR  J=2  TO  6
690 FOR  K=1  TO  3
700 IF  S(L(1),K)<>L(J)  THEN  770
710 ON  J-1  GOTO  720,740,740,760,760
720 PRINT  "I SMeLL A WUMPUS!"
730  GOTO  770
740 PRINT  "I FEEL A DRAFT"
750  GOTO  770
760 PRINT  "BATS NEARBY!"
770 NEXT  K
780 NEXT  J
790 PRINT  "YOU ARE IN ROOM";L(1);
800 PRINT  "    TUNNELS LEAD TO";S(L,1);",";S(L,2);"AND";S(L,3)
810 PRINT 
820 RETURN 
830 REM   CHOSE OPTION
840 INPUT  "SHOOT OR MOVE";I$
850 PRINT 
860 IF   LEFT$(I$,1)<>"S"  THEN  890
870 O=1
880 RETURN 
890 IF   LEFT$(I$,1)<>"M"  THEN  840
900 O=2
910 RETURN 
920 REM   ARROW ROUTINE
930 F=0
940 REM   PATH OF ARROW
950 INPUT  "NUMBER OF ROOMS";J9
960 PRINT 
970 IF  J9<1  THEN  950
980 IF  J9>5  THEN  950
990 FOR  K=1  TO  J9
1000 INPUT  "ROOM #";P(K)
1010 IF  P(K)>0  THEN  IF  P(K)<21  THEN  1040
1020 PRINT  "   ENTER ROOM NUMBERS FROM 1 TO 20 ONLY."
1030  GOTO  1000
1040 PRINT  "  ";
1050 NEXT  K
1060 PRINT 
1070 REM   SHOOT ARROW
1080 A=A-1
1090 A9=L(1)
1100 FOR  K=1  TO  J9
1110 F1=0
1120 FOR  K1=1  TO  3
1130 IF  S(A9,K1)=P(K)  THEN  F1=1
1140 NEXT  K1
1150 IF  F1=1  THEN  1190
1160 REM   NO TUNNEL FOR ARROW
1170 A9=S(A9, RND(3))
1180 F1=2
1190 ON  F1  GOSUB  1310,1320
1200 IF   ABS(F)=1  THEN  K=J9+1: GOTO  1290
1210 NEXT  K
1220 PRINT  "MISSED"
1230 PRINT 
1240 REM   MOVE WUMPUS
1250  GOSUB  1400
1260 REM   AMMO CHECK
1270 IF  A>0  THEN  1290
1280 F=-1
1290 RETURN 
1300 REM   SEE IF ARROW IS AT L(1) OR L(2)
1310 A9=P(K)
1320 IF  A9<>L(2)  THEN  1370
1330 PRINT  "AHA!  YOU GOT THE WUMPUS!!  HE WAS IN ROOM";L(2)
1340 PRINT 
1350 F=1
1360 RETURN 
1370 IF  A9<>L(1)  THEN  RETURN 
1380 PRINT  "OUCH!  ARROW GOT YOU!!"
1390  GOTO  1280
1400 REM   MOVE WUMPUS ROUTINE
1410 K= RND(4)
1420 IF  K=4  THEN  1470
1430 L(2)=S(L(2),K)
1440 IF  L(2)<>L  THEN  1470
1450 PRINT  "TSK TSK TSK - THE WUMPUS GOT YOU!":PRINT 
1460 F=-1
1470 RETURN 
1480 REM   MOVE ROUTINE
1490 F=0
1500 INPUT  "WHERE TO";L
1510 PRINT 
1520 IF  L<1  THEN  1500
1530 IF  L>20  THEN  1500
1540 FOR  K=1  TO  3
1550 REM   CHECK IF LEGAL MOVE
1560 IF  S(L(1),K)=L  THEN  K=4: GOTO  1620
1570 NEXT  K
1580 IF  L=L(1)  THEN  1620
1590 PRINT  "NOT POSSIBLE - ";
1600  GOTO  1500
1610 REM   CHECK FOR HAZARDS
1620 L(1)=L
1630 REM   WUMPUS
1640 IF  L<>L(2)  THEN  1710
1650 PRINT  "... OOPS!  BUMPED A WUMPUS!"
1660 REM   MOVE WUMPUS
1670  GOSUB  1410
1680 IF  F=0  THEN  1710
1690 RETURN 
1700 REM   PIT
1710 IF  L<>L(3)  THEN  IF  L<>L(4)  THEN  1830
1720 CLS :P1=110
1730 PRINT   CHR$(28);"Y";: GOSUB  5000:PRINT  "Y";: GOSUB  5000:PRINT  "Y": GOSUB  5000:P1=100:PRINT  "      Y": GOSUB  5000
1740 P1=90:PRINT  "         Y": GOSUB  5000:P1=80
1750 PRINT  "          Y": GOSUB  5000:P1=70:PRINT  "           Y": GOSUB  5000
1760 PRINT  TAB(11);"I";: GOSUB  5000:PRINT  TAB(30);"FELL IN A PIT!!"
1770 FOR  I=1  TO  4:P1=70-I*10:PRINT  TAB(11);"I": GOSUB  5000:NEXT  I
1780 FOR  I=1  TO  2:P1=30-I*10:PRINT  TAB(11);"E": GOSUB  5000:NEXT  I
1790 FOR  I=1  TO  18:PRINT  TAB(11);".": GOSUB  5000:NEXT  I
1800 F=-1
1810 RETURN 
1820 REM   BATS
1830 IF  L<>L(5)  THEN  IF  L<>L(6)  THEN  1880
1840 PRINT  "ZAP--SUPER BAT SNATCH!  ELSEWHEREVILLE FOR YOU!"
1850 FOR  Q=1  TO  500:NEXT  Q
1860 L= RND(20)
1870  GOTO  1620
1880 RETURN 
1890 REM   SELECT CAVE
1900 IF  F3=1  THEN  1930
1910 PRINT  @ 896, CHR$(30):PRINT  @ 960, CHR$(30);
1920 PRINT  @ 901,"";
1930 INPUT  "CAVE # (0-6)";N
1940 IF  N>=0  AND  N<=6  THEN  1970
1950 IF  F3=1  THEN  PRINT 
1960  GOTO  1900
1970 CLS 
1975 PRINT   CHR$(28);:IF  N<6  THEN  PRINT  "THE WUMPUS IS HIDING."
1980 IF  N=6  THEN  2060
1990 RESTORE 
2000 IF  N=0  THEN  2040
2010 FOR  X9=1  TO  N*60
2020 READ  I9
2030 NEXT  X9
2040  GOSUB  2230
2050  GOTO  2070
2060  GOSUB  2080
2070 RETURN 
2080 REM   INPUT OWN CAVE
2090 FOR  J=1  TO  20
2100 PRINT  "ROOM #";J;
2110 INPUT  "IS CONNECTED TO :";S(J,1)
2120 INPUT  "AND";S(J,2):INPUT  "AND";S(J,3)
2130 PRINT 
2140 F5=0
2150 FOR  K=1  TO  3
2160 IF  S(J,K)>0  THEN  IF  S(J,K)<21  THEN  2190
2170 PRINT  "ERROR** ENTER ROOM NUMBERS FROM 1 TO 20 ONLY!!"
2180 F5=1
2190 NEXT  K
2200 IF  F5=1  THEN  2100
2210 NEXT  J
2220 RETURN 
2230 REM   INPUT CAVE
2240 FOR  J=1  TO  20
2250 FOR  K=1  TO  3
2260 READ  S(J,K)
2270 NEXT  K
2280 NEXT  J
2290 RETURN 
2300 PRINT  @ 401,"THANK YOU FOR PLAYING WITH ME!"
2310 REM  RUN "MENU"
2320 PRINT :PRINT "TO LOAD ANOTHER PROGRAM, TYPE 'CLOAD'.":PRINT :END 
2330 REM   DODECAHEDRON
2340 DATA  2,5,8,1,3,10,2,4,12,3,5,14,1,4,6,5,7,15,6,8,17,1
2350 DATA  7,8,9,10,18,2,9,11,10,12,19,3,11,13,12,14,20,4,13
2360 DATA  15,6,14,16,15,17,20,7,16,18,9,17,19,11,18,20,13,16,19
2370 REM   MOBIUS STRIP
2380 DATA  20,2,3,19,1,4,1,4,5,2,3,6,3,6,7,4,5,8,5,8,9,6,7
2390 DATA  10,7,10,11,8,9,12,9,12,13,10,11,14,11,14,15,12,13
2400 DATA  16,12,16,17,14,15,18,15,18,19,16,17,20,2,17,20,1,18,19
2410 REM   STRING OF BEADS
2420 DATA  2,3,20,1,3,4,1,2,4,2,3,5,4,6,7,5,7,8,5,6,8,6,7
2430 DATA  9,8,10,11,9,11,12,9,10,12,10,11,13,12,14,15,13,15,1
2440 DATA  6,13,14,16,14,15,17,16,18,19,17,19,20,17,18,20,1,18,19
2450 REM   HEX NETWORK
2460 DATA  6,10,16,6,7,17,7,8,18,8,9,19,9,10,20,1,2,15,2,3,1
2470 DATA  1,3,4,12,4,5,13,1,5,14,7,16,20,8,16,17,9,17,18,10
2480 DATA  18,19,6,19,20,1,11,12,2,12,13,3,13,14,4,14,15,5,11,15
2490 REM   DENDRITE W/ DEGENERACIES
2500 DATA  1,1,5,2,2,5,3,3,6,4,4,6,1,2,7,3,4,7,5,6,10,8,9
2510 DATA  9,8,8,10,7,9,11,10,13,14,12,13,13,11,12,12,11,15,16
2520 DATA  14,17,18,14,19,20,15,17,17,15,18,18,16,19,19,16,20,20
2530 REM   ONE WAY LATTICE
2540 DATA  5,4,8,1,5,6,2,6,7,3,7,8,8,9,12,5,9,10,6,10,11,7
2550 DATA  11,12,12,13,16,9,13,14,10,14,15,11,15,16,16,17,20,13
2560 DATA  17,18,14,18,19,15,19,20,1,4,20,1,2,17,2,3,18,3,4,19
2570 REM   INSTRUCTIONS
2580 CLS 
2590 PRINT  "  THE WUMPUS LIVES IN A CAVE OF 20 ROOMS.  EACH ROOM HAS 3"
2600 PRINT  "TUNNELS LEADING TO OTHER ROOMS.":PRINT :PRINT  "HAZARDS:"
2610 PRINT :PRINT  "BOTTOMLESS PITS - TWO ROOMS HAVE BOTTOMLESS PITS IN THEM.  IF"
2620 PRINT  "YOU GO IN THERE, YOU FALL INTO THE PIT AND LOSE!":PRINT 
2630 PRINT  "SUPER BATS - TWO OTHER ROOMS HAVE SUPER BATS.  IF YOU GO THERE,"
2640 PRINT  "A BAT WILL GRAB YOU AND TAKE YOU AWAY TO SOMEWHERE ELSE IN THE"
2650 PRINT  "CAVE WHERE YOU COULD RUN INTO THE...": GOSUB  3410
2660 PRINT  "WUMPUS:":PRINT 
2670 PRINT  "THE WUMPUS IS NOT BOTHERED BY THE HAZARDS (HE HAS SUCKER FEET"
2680 PRINT  "AND IS TOO BIG TO LIFT).  USUALLY HE IS ASLEEP.  TWO THINGS"
2690 PRINT  "WAKE HIM UP:  YOUR ENTERING HIS ROOM OR YOUR SHOOTING AN ARROW."
2700 PRINT  "IF THE WUMPUS WAKES, HE MIGHT MOVE ONE ROOM OR STAY STILL."
2710 PRINT  "BUT IF HE IS WHERE YOU ARE, HE EATS YOU UP AND YOU LOSE!"
2720 PRINT :PRINT  "YOU:":PRINT 
2730 PRINT  "EACH TURN YOU MAY MOVE OR YOU MAY SHOOT A CROOKED ARROW."
2740 PRINT  "MOVING:  YOU CAN GO ONE ROOM (THRU ONE TUNNEL)."
2750  GOSUB  3410
2760 PRINT  "SHOOTING:  YOU HAVE 5 ARROWS.  YOU LOSE WHEN YOU RUN OUT."
2770 PRINT  "  EACH ARROW CAN GO FROM 1 TO 5 ROOMS.  YOU AIM BY TELLING THE"
2780 PRINT  "  COMPUTER, FIRST THE NUMBER OF ROOMS YOU WISH THE ARROW TO"
2790 PRINT  "  TRAVEL THRU AND, SECOND, THE ROOM NUMBERS IN THEIR ORDER OF"
2800 PRINT  "  OCCURRENCE.":PRINT 
2810 PRINT  " EXAMPLE:  YOU ARE IN ROOM 2; TUNNELS LEAD TO ROOMS 1, 3 AND 10"
2820 PRINT  "  AND YOU THINK THE WUMPUS IS IN ONE OF THEM.  YOU CHOOSE TO"
2830 PRINT  "  SHOOT AN ARROW THRU FOUR ROOMS.  WHEN THE COMPUTER ASKS"
2840 PRINT  "  'NUMBER OF ROOM?', YOU TYPE 4.  THEN THE COMPUTER WILL SAY"
2850 PRINT  "  'ROOM #?'.  YOU THEN TYPE THE ROOM NUMBER.  CONTINUE THIS"
2860 PRINT  "  PROCESS UNTIL 4 ROOMS HAVE BEEN ENTERED.": GOSUB  3410
2870 PRINT  " NOTE:  THE FIRST ROOM IN THE SEQUENCE MUST BE AN ADJOINING"
2880 PRINT  "  ROOM, THAT IS, ONE THAT HAS A TUNNEL CONNECTING IT WITH THE"
2890 PRINT  "  ROOM YOU ARE IN, EACH SUCCEEDING ROOM MUST ALSO BE CONNECTED"
2900 PRINT  "  TO THE PREVIOUS ROOM BY A TUNNEL.  IF THERE IS NO CONNECTING"
2910 PRINT  "  TUNNEL BETWEEN PARTICULAR ROOMS YOU SPECIFY, THE ARROW" 
2920 PRINT  "  RANDOMLY CHOOSES ONE OF THE THREE TUNNELS FROM THE ROOM IT"
2930 PRINT  "  IS IN AND GOES ITS OWN WAY UNTIL IT HAS TRAVELED FOUR ROOMS."
2940 PRINT :PRINT  "IF THE ARROW HITS THE WUMPUS, YOU WIN."
2950 PRINT  "IF THE ARROW HITS YOU, YOU LOSE."
2960  GOSUB  3410:PRINT :PRINT  "WARNINGS:":PRINT 
2970 PRINT  "WHEN YOU MOVE TO WITHIN ONE ROOM OF THE WUMPUS OR A HAZARD,"
2980 PRINT  "THE COMPUTER SAYS:":PRINT :PRINT  "WUMPUS - 'I SMELL A WUMPUS'"
2990 PRINT  "BAT - 'BATS NEARBY'":PRINT  "PIT - 'I FEEL A DRAFT'":PRINT 
3000 PRINT  "BE CAREFUL!  THE WUMPUS MAY SNEAK UP ON YOU!!"
3010 PRINT  @ 910,"";:INPUT  "WOULD YOU LIKE THE DESCRIPTION OF THE CAVES";Z$
3020 CLS 
3030 IF   LEFT$(Z$,1)="N"  THEN  RETURN 
3040 PRINT  "THE CAVES ARE:":PRINT 
3050 PRINT  "0 - DODECAHEDRON:  THE ROOMS OF THIS CAVE ARE ON A 12-SIDED"
3060 PRINT  "    OBJECT, EACH SIDE FORMING A PENTAGON.  THE ROOMS ARE AT THE"
3070 PRINT  "    CORNERS OF THE PENTAGONS, EACH ROOM HAVING TUNNELS LEADING"
3080 PRINT  "    TO 3 OTHER ROOMS.":PRINT 
3090 PRINT  "1 - MOBIUS STRIP:  THIS CAVE IS TWO ROOMS WIDE AND 10 ROOMS"
3100 PRINT  "    AROUND (LIKE A BELT).  YOU WILL NOTICE THERE IS A HALF-"
3110 PRINT  "    TWIST SOMEWHERES.":PRINT 
3120 PRINT  "2 - STRING OF BEADS:  FIVE BEADS IN A CIRCLE.  EACH BEAD IS A"
3130 PRINT  "    DIAMOND WITH A VERTICAL CROSS-BAR.  THE RIGHT AND LEFT"
3140 PRINT  "    CORNERS LEAD TO NEIGHBORING BEADS.  (THIS ONE IS DIFFICULT"
3150 PRINT  "    TO PLAY).": GOSUB  3410
3160 PRINT  "3 - HEX NETWORK:  IMAGINE A HEX TILE FLOOR.  TAKE A RECTANGLE"
3170 PRINT  "    WITH 20 POINTS (INTERSECTIONS) INSIDE (4X5).  JOIN RIGHT"
3180 PRINT  "    AND LEFT SIDES TO MAKE A CYLINDER.  THEN JOIN TOP AND BOT-"
3190 PRINT  "    TOM TO FORM A TORUS (DOUGHNUT)."
3200 PRINT  "    HAVE FUN IMAGINING THIS ONE!":PRINT 
3210 PRINT  "CAVES 0-3 ARE REGULAR IN THE SENSE THAT EACH ROOM GOES TO THREE"
3220 PRINT  "OTHER ROOMS AND THE TUNNELS ALLOW TWO-WAY TRAFFIC."
3230 PRINT  "HERE ARE SOME IRREGULAR CAVES:":PRINT 
3240 PRINT  "4 - DENDRITE WITH DEGENERACIES:  PULL A PLANT FROM THE GROUND."
3250 PRINT  "    THE ROOTS AND BRANCHES FROM A DENDRITE - IE, THERE ARE NO"
3260 PRINT  "    LOOPING PATHS.  DEGENERACY MEANS A) SOME ROOMS CONNECT TO"
3270 PRINT  "    THEMSELVES OR B) THAT TWO ROOMS HAVE MORE THAN ONE TUNNEL"
3280 PRINT  "    BETWEEN THEM IE, 12 HAS TWO TUNNELS TO 13."
3290  GOSUB  3410
3300 PRINT  "5 - ONE WAY LATTICE:  HERE ALL TUNNELS GO ONE WAY ONLY.  TO"
3310 PRINT  "    RETURN, YOU MUST GO AROUND THE CAVE (ABOUT 5 MOVES).":PRINT 
3320 PRINT  "6 - ENTER YOUR OWN CAVE:  THE COMPUTER WILL ASK YOU FOR THE"
3330 PRINT  "    ROOMS NEXT TO EACH ROOM IN THE CAVE.":PRINT 
3340 PRINT  "   FOR EXAMPLE:":PRINT 
3350 PRINT  "    TO SET ROOM #1 UP WITH TUNNELS GOING TO ROOMS 2, 3 AND 4"
3360 PRINT  "    TYPE '2' (ENTER) '3' (ENTER) '4' (ENTER) WHEN PROMPTED"
3370 PRINT  "    WITH 'ROOM #1'"
3380 PRINT :PRINT  TAB(24);"HAPPY HUNTING!!!"
3390 PRINT  TAB(27);">>>------->"
3400  GOSUB  3410:RETURN 
3410 PRINT  @ 975,"PRESS 'ENTER' TO CONTINUE ";
3415 Z$= INKEY$ :Z$=Z$:IF  Z$=""  THEN  3415 
3420 IF   ASC(Z$)<>13  THEN  3415  ELSE  CLS :RETURN 
5000 FOR  Q=1  TO  P1:NEXT  Q:RETURN 
