-
Notifications
You must be signed in to change notification settings - Fork 2
/
advent.for
2948 lines (2458 loc) · 79.9 KB
/
advent.for
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
C ADVENTURES
C CURRENT LIMITS:
C 9650 WORDS OF MESSAGE TEXT (LINES, LINSIZ).
C 750 TRAVEL OPTIONS (TRAVEL, TRVSIZ).
C 300 VOCABULARY WORDS (KTAB, ATAB, TABSIZ).
C 150 LOCATIONS (LTEXT, STEXT, KEY, COND, ABB, ATLOC, LOCSIZ).
C 100 OBJECTS (PLAC, PLACE, FIXD, FIXED, LINK (TWICE), PTEXT, PROP).
C 35 "ACTION" VERBS (ACTSPK, VRBSIZ).
C 205 RANDOM MESSAGES (RTEXT, RTXSIZ).
C 12 DIFFERENT PLAYER CLASSIFICATIONS (CTEXT, CVAL, CLSMAX).
C 20 HINTS, LESS 3 (HINTLC, HINTED, HINTS, HNTSIZ).
C 35 MAGIC MESSAGES (MTEXT, MAGSIZ).
C THERE ARE ALSO LIMITS WHICH CANNOT BE EXCEEDED DUE TO THE STRUCTURE OF
C THE DATABASE. (E.G., THE VOCABULARY USES N/1000 TO DETERMINE WORD TYPE,
C SO THERE CAN'T BE MORE THAN 1000 WORDS.) THESE UPPER LIMITS ARE:
C 1000 NON-SYNONYMOUS VOCABULARY WORDS
C 300 LOCATIONS
C 100 OBJECTS
IMPLICIT INTEGER(A-Z)
LOGICAL DSEEN,BLKLIN,HINTED,YES,START
COMMON /TXTCOM/ RTEXT,LINES
COMMON /BLKCOM/ BLKLIN
COMMON /VOCCOM/ KTAB,ATAB,TABSIZ
COMMON /PLACOM/ ATLOC,LINK,PLACE,FIXED,HOLDNG
COMMON /MTXCOM/ MTEXT
COMMON /PTXCOM/ PTEXT
COMMON /ABBCOM/ ABB
COMMON /WIZCOM/ WKDAY,WKEND,HOLID,HBEGIN,HEND,HNAME,
1 SHORT,MAGIC,MAGNM,LATNCY,SAVED,SAVET,SETUP
DIMENSION LINES(9650)
DIMENSION TRAVEL(750)
DIMENSION KTAB(300),ATAB(300)
DIMENSION LTEXT(150),STEXT(150),KEY(150),COND(150),ABB(150),
1 ATLOC(150)
DIMENSION PLAC(100),PLACE(100),FIXD(100),FIXED(100),LINK(200),
1 PTEXT(100),PROP(100)
DIMENSION ACTSPK(35)
DIMENSION RTEXT(205)
DIMENSION CTEXT(12),CVAL(12)
DIMENSION HINTLC(20),HINTED(20),HINTS(20,4)
DIMENSION MTEXT(35)
DIMENSION TK(20),DSEEN(6),DLOC(6),ODLOC(6),HNAME(4)
C
C AVOID MAKING THE COMPILER WORRY ABOUT MODIFYING THE DO INDEX
C
INTEGER IDONDX
C STATEMENT FUNCTIONS
C
C
C TOTING(OBJ) = TRUE IF THE OBJ IS BEING CARRIED
C HERE(OBJ) = TRUE IF THE OBJ IS AT "LOC" (OR IS BEING CARRIED)
C AT(OBJ) = TRUE IF ON EITHER SIDE OF TWO-PLACED OBJECT
C LIQ(DUMMY) = OBJECT NUMBER OF LIQUID IN BOTTLE
C LIQLOC(LOC) = OBJECT NUMBER OF LIQUID (IF ANY) AT LOC
C BITSET(L,N) = TRUE IF COND(L) HAS BIT N SET (BIT 0 IS UNITS BIT)
C FORCED(LOC) = TRUE IF LOC MOVES WITHOUT ASKING FOR INPUT (COND=2)
C DARK(DUMMY) = TRUE IF LOCATION "LOC" IS DARK
C PCT(N) = TRUE N% OF THE TIME (N INTEGER FROM 0 TO 100)
C
C WZDARK SAYS WHETHER THE LOC HE'S LEAVING WAS DARK
C LMWARN SAYS WHETHER HE'S BEEN WARNED ABOUT LAMP GOING DIM
C CLOSNG SAYS WHETHER ITS CLOSING TIME YET
C PANIC SAYS WHETHER HE'S FOUND OUT HE'S TRAPPED IN THE CAVE
C CLOSED SAYS WHETHER WE'RE ALL THE WAY CLOSED
C GAVEUP SAYS WHETHER HE EXITED VIA "QUIT"
C SCORNG INDICATES TO THE SCORE ROUTINE WHETHER WE'RE DOING A "SCORE" COMMAND
C DEMO IS TRUE IF THIS IS A PRIME-TIME DEMONSTRATION GAME
C YEA IS RANDOM YES/NO REPLY
LOGICAL TOTING,HERE,AT,BITSET,DARK,WZDARK,LMWARN,CLOSNG,PANIC,
1 CLOSED,GAVEUP,SCORNG,DEMO,YEA
TOTING(OBJ)=PLACE(OBJ).EQ.-1
HERE(OBJ)=PLACE(OBJ).EQ.LOC.OR.TOTING(OBJ)
AT(OBJ)=PLACE(OBJ).EQ.LOC.OR.FIXED(OBJ).EQ.LOC
LIQ2(PBOTL)=(1-PBOTL)*WATER+(PBOTL/2)*(WATER+OIL)
LIQ(DUMMY)=LIQ2(MAX0(PROP(BOTTLE),-1-PROP(BOTTLE)))
LIQLOC(LOC)=LIQ2((MOD(COND(LOC)/2*2,8)-5)*MOD(COND(LOC)/4,2)+1)
BITSET(L,N)=(COND(L).AND.SHIFT(1,N)).NE.0
FORCED(LOC)=COND(LOC).EQ.2
DARK(DUMMY)=MOD(COND(LOC),2).EQ.0.AND.(PROP(LAMP).EQ.0.OR.
1 .NOT.HERE(LAMP))
PCT(N)=RAN(100).LT.N
C
DATA LINSIZ/9650/,TRVSIZ/750/,TABSIZ/300/,LOCSIZ/150/,
1 VRBSIZ/35/,RTXSIZ/205/,CLSMAX/12/,HNTSIZ/20/,MAGSIZ/35/
DATA SETUP/0/,BLKLIN/.TRUE./
C DESCRIPTION OF THE DATABASE FORMAT
C
C
C THE DATA FILE CONTAINS SEVERAL SECTIONS. EACH BEGINS WITH A LINE CONTAINING
C A NUMBER IDENTIFYING THE SECTION, AND ENDS WITH A LINE CONTAINING "-1".
C
C SECTION 1: LONG FORM DESCRIPTIONS. EACH LINE CONTAINS A LOCATION NUMBER,
C A TAB, AND A LINE OF TEXT. THE SET OF (NECESSARILY ADJACENT) LINES
C WHOSE NUMBERS ARE X FORM THE LONG DESCRIPTION OF LOCATION X.
C SECTION 2: SHORT FORM DESCRIPTIONS. SAME FORMAT AS LONG FORM. NOT ALL
C PLACES HAVE SHORT DESCRIPTIONS.
C SECTION 3: TRAVEL TABLE. EACH LINE CONTAINS A LOCATION NUMBER (X), A SECOND
C LOCATION NUMBER (Y), AND A LIST OF MOTION NUMBERS (SEE SECTION 4).
C EACH MOTION REPRESENTS A VERB WHICH WILL GO TO Y IF CURRENTLY AT X.
C Y, IN TURN, IS INTERPRETED AS FOLLOWS. LET M=Y/1000, N=Y MOD 1000.
C IF N<=300 IT IS THE LOCATION TO GO TO.
C IF 300<N<=500 N-300 IS USED IN A COMPUTED GOTO TO
C A SECTION OF SPECIAL CODE.
C IF N>500 MESSAGE N-500 FROM SECTION 6 IS PRINTED,
C AND HE STAYS WHEREVER HE IS.
C MEANWHILE, M SPECIFIES THE CONDITIONS ON THE MOTION.
C IF M=0 IT'S UNCONDITIONAL.
C IF 0<M<100 IT IS DONE WITH M% PROBABILITY.
C IF M=100 UNCONDITIONAL, BUT FORBIDDEN TO DWARVES.
C IF 100<M<=200 HE MUST BE CARRYING OBJECT M-100.
C IF 200<M<=300 MUST BE CARRYING OR IN SAME ROOM AS M-200.
C IF 300<M<=400 PROP(M MOD 100) MUST *NOT* BE 0.
C IF 400<M<=500 PROP(M MOD 100) MUST *NOT* BE 1.
C IF 500<M<=600 PROP(M MOD 100) MUST *NOT* BE 2, ETC.
C IF THE CONDITION (IF ANY) IS NOT MET, THEN THE NEXT *DIFFERENT*
C "DESTINATION" VALUE IS USED (UNLESS IT FAILS TO MEET *ITS* CONDITIONS,
C IN WHICH CASE THE NEXT IS FOUND, ETC.). TYPICALLY, THE NEXT DEST WILL
C BE FOR ONE OF THE SAME VERBS, SO THAT ITS ONLY USE IS AS THE ALTERNATE
C DESTINATION FOR THOSE VERBS. FOR INSTANCE:
C 15 110022 29 31 34 35 23 43
C 15 14 29
C THIS SAYS THAT, FROM LOC 15, ANY OF THE VERBS 29, 31, ETC., WILL TAKE
C HIM TO 22 IF HE'S CARRYING OBJECT 10, AND OTHERWISE WILL GO TO 14.
C 11 303008 49
C 11 9 50
C THIS SAYS THAT, FROM 11, 49 TAKES HIM TO 8 UNLESS PROP(3)=0, IN WHICH
C CASE HE GOES TO 9. VERB 50 TAKES HIM TO 9 REGARDLESS OF PROP(3).
C SECTION 4: VOCABULARY. EACH LINE CONTAINS A NUMBER (N), A TAB, AND A
C FIVE-LETTER WORD. CALL M=N/1000. IF M=0, THEN THE WORD IS A MOTION
C VERB FOR USE IN TRAVELLING (SEE SECTION 3). ELSE, IF M=1, THE WORD IS
C AN OBJECT. ELSE, IF M=2, THE WORD IS AN ACTION VERB (SUCH AS "CARRY"
C OR "ATTACK"). ELSE, IF M=3, THE WORD IS A SPECIAL CASE VERB (SUCH AS
C "DIG") AND N MOD 1000 IS AN INDEX INTO SECTION 6. OBJECTS FROM 50 TO
C (CURRENTLY, ANYWAY) 79 ARE CONSIDERED TREASURES (FOR PIRATE, CLOSEOUT).
C SECTION 5: OBJECT DESCRIPTIONS. EACH LINE CONTAINS A NUMBER (N), A TAB,
C AND A MESSAGE. IF N IS FROM 1 TO 100, THE MESSAGE IS THE "INVENTORY"
C MESSAGE FOR OBJECT N. OTHERWISE, N SHOULD BE 000, 100, 200, ETC., AND
C THE MESSAGE SHOULD BE THE DESCRIPTION OF THE PRECEDING OBJECT WHEN ITS
C PROP VALUE IS N/100. THE N/100 IS USED ONLY TO DISTINGUISH MULTIPLE
C MESSAGES FROM MULTI-LINE MESSAGES; THE PROP INFO ACTUALLY REQUIRES ALL
C MESSAGES FOR AN OBJECT TO BE PRESENT AND CONSECUTIVE. PROPERTIES WHICH
C PRODUCE NO MESSAGE SHOULD BE GIVEN THE MESSAGE ">$<".
C SECTION 6: ARBITRARY MESSAGES. SAME FORMAT AS SECTIONS 1, 2, AND 5, EXCEPT
C THE NUMBERS BEAR NO RELATION TO ANYTHING (EXCEPT FOR SPECIAL VERBS
C IN SECTION 4).
C SECTION 7: OBJECT LOCATIONS. EACH LINE CONTAINS AN OBJECT NUMBER AND ITS
C INITIAL LOCATION (ZERO (OR OMITTED) IF NONE). IF THE OBJECT IS
C IMMOVABLE, THE LOCATION IS FOLLOWED BY A "-1". IF IT HAS TWO LOCATIONS
C (E.G. THE GRATE) THE FIRST LOCATION IS FOLLOWED WITH THE SECOND, AND
C THE OBJECT IS ASSUMED TO BE IMMOVABLE.
C SECTION 8: ACTION DEFAULTS. EACH LINE CONTAINS AN "ACTION-VERB" NUMBER AND
C THE INDEX (IN SECTION 6) OF THE DEFAULT MESSAGE FOR THE VERB.
C SECTION 9: LIQUID ASSETS, ETC. EACH LINE CONTAINS A NUMBER (N) AND UP TO 20
C LOCATION NUMBERS. BIT N (WHERE 0 IS THE UNITS BIT) IS SET IN COND(LOC)
C FOR EACH LOC GIVEN. THE COND BITS CURRENTLY ASSIGNED ARE:
C 0 LIGHT
C 1 IF BIT 2 IS ON: ON FOR OIL, OFF FOR WATER
C 2 LIQUID ASSET, SEE BIT 1
C 3 PIRATE DOESN'T GO HERE UNLESS FOLLOWING PLAYER
C OTHER BITS ARE USED TO INDICATE AREAS OF INTEREST TO "HINT" ROUTINES:
C 4 TRYING TO GET INTO CAVE
C 5 TRYING TO CATCH BIRD
C 6 TRYING TO DEAL WITH SNAKE
C 7 LOST IN MAZE
C 8 PONDERING DARK ROOM
C 9 AT WITT'S END
C COND(LOC) IS SET TO 2, OVERRIDING ALL OTHER BITS, IF LOC HAS FORCED
C MOTION.
C SECTION 10: CLASS MESSAGES. EACH LINE CONTAINS A NUMBER (N), A TAB, AND A
C MESSAGE DESCRIBING A CLASSIFICATION OF PLAYER. THE SCORING SECTION
C SELECTS THE APPROPRIATE MESSAGE, WHERE EACH MESSAGE IS CONSIDERED TO
C APPLY TO PLAYERS WHOSE SCORES ARE HIGHER THAN THE PREVIOUS N BUT NOT
C HIGHER THAN THIS N. NOTE THAT THESE SCORES PROBABLY CHANGE WITH EVERY
C MODIFICATION (AND PARTICULARLY EXPANSION) OF THE PROGRAM.
C SECTION 11: HINTS. EACH LINE CONTAINS A HINT NUMBER (CORRESPONDING TO A
C COND BIT, SEE SECTION 9), THE NUMBER OF TURNS HE MUST BE AT THE RIGHT
C LOC(S) BEFORE TRIGGERING THE HINT, THE POINTS DEDUCTED FOR TAKING THE
C HINT, THE MESSAGE NUMBER (SECTION 6) OF THE QUESTION, AND THE MESSAGE
C NUMBER OF THE HINT. THESE VALUES ARE STASHED IN THE "HINTS" ARRAY.
C HNTMAX IS SET TO THE MAX HINT NUMBER (<= HNTSIZ). NUMBERS 1-3 ARE
C UNUSABLE SINCE COND BITS ARE OTHERWISE ASSIGNED, SO 2 IS USED TO
C REMEMBER IF HE'S READ THE CLUE IN THE REPOSITORY, AND 3 IS USED TO
C REMEMBER WHETHER HE ASKED FOR INSTRUCTIONS (GETS MORE TURNS, BUT LOSES
C POINTS).
C SECTION 12: MAGIC MESSAGES. IDENTICAL TO SECTION 6 EXCEPT PUT IN A SEPARATE
C SECTION FOR EASIER REFERENCE. MAGIC MESSAGES ARE USED BY THE STARTUP,
C MAINTENANCE MODE, AND RELATED ROUTINES.
C SECTION 0: END OF DATABASE.
C READ THE DATABASE IF WE HAVE NOT YET DONE SO
IF(SETUP.NE.0)GOTO 1100
TYPE 1000
1000 FORMAT(' Initializing...')
C CLEAR OUT THE VARIOUS TEXT-POINTER ARRAYS. ALL TEXT IS STORED IN ARRAY
C LINES; EACH LINE IS PRECEDED BY A WORD POINTING TO THE NEXT POINTER (I.E.
C THE WORD FOLLOWING THE END OF THE LINE). THE POINTER IS NEGATIVE IF THIS IS
C FIRST LINE OF A MESSAGE. THE TEXT-POINTER ARRAYS CONTAIN INDICES OF
C POINTER-WORDS IN LINES. STEXT(N) IS SHORT DESCRIPTION OF LOCATION N.
C LTEXT(N) IS LONG DESCRIPTION. PTEXT(N) POINTS TO MESSAGE FOR PROP(N)=0.
C SUCCESSIVE PROP MESSAGES ARE FOUND BY CHASING POINTERS. RTEXT CONTAINS
C SECTION 6'S STUFF. CTEXT(N) POINTS TO A PLAYER-CLASS MESSAGE. MTEXT IS FOR
C SECTION 12. WE ALSO CLEAR COND. SEE DESCRIPTION OF SECTION 9 FOR DETAILS.
DO 1001 I=1,300
IF(I.LE.100)PTEXT(I)=0
IF(I.LE.RTXSIZ)RTEXT(I)=0
IF(I.LE.CLSMAX)CTEXT(I)=0
IF(I.LE.MAGSIZ)MTEXT(I)=0
IF(I.GT.LOCSIZ)GOTO 1001
STEXT(I)=0
LTEXT(I)=0
COND(I)=0
1001 CONTINUE
OPEN(UNIT=1,NAME='ADVENT',ACCESS='SEQIN')
SETUP=1
LINUSE=1
TRVS=1
CLSSES=1
C START NEW DATA SECTION. SECT IS THE SECTION NUMBER.
1002 READ(1,1003)SECT
1003 FORMAT(G)
OLDLOC=-1
GOTO(1100,1004,1004,1030,1040,1004,1004,1050,1060,1070,1004,
1 1080,1004) (SECT+1)
C (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
C (11) (12)
CALL BUG(9)
C SECTIONS 1, 2, 5, 6, 10, 12. READ MESSAGES AND SET UP POINTERS.
1004 READ(1,1005)LOC,(LINES(J),J=LINUSE+1,LINUSE+14),KK
1005 FORMAT(1G,15A5)
IF(KK.NE.' ')CALL BUG(0)
IF(LOC.EQ.-1)GOTO 1002
DO 1006 K=1,14
KK=LINUSE+15-K
IF(LINES(KK).NE.' ')GOTO 1007
1006 CONTINUE
IF(LOC.EQ.0)GOTO 1004
C ABOVE KLUGE IS TO AVOID F40 BUG IF CRLF BROKEN ACROSS RECORD BOUNDARY
CALL BUG(1)
1007 LINES(LINUSE)=KK+1
IF(LOC.EQ.OLDLOC)GOTO 1020
LINES(LINUSE)=-LINES(LINUSE)
IF(SECT.EQ.12)GOTO 1013
IF(SECT.EQ.10)GOTO 1012
IF(SECT.EQ.6)GOTO 1011
IF(SECT.EQ.5)GOTO 1010
IF(SECT.EQ.1)GOTO 1008
STEXT(LOC)=LINUSE
GOTO 1020
1008 LTEXT(LOC)=LINUSE
GOTO 1020
1010 IF(LOC.GT.0.AND.LOC.LE.100)PTEXT(LOC)=LINUSE
GOTO 1020
1011 IF(LOC.GT.RTXSIZ)CALL BUG(6)
RTEXT(LOC)=LINUSE
GOTO 1020
1012 CTEXT(CLSSES)=LINUSE
CVAL(CLSSES)=LOC
CLSSES=CLSSES+1
GOTO 1020
1013 IF(LOC.GT.MAGSIZ)CALL BUG(6)
MTEXT(LOC)=LINUSE
1020 LINUSE=KK+1
LINES(LINUSE)=-1
OLDLOC=LOC
IF(LINUSE+14.GT.LINSIZ)CALL BUG(2)
GOTO 1004
C THE STUFF FOR SECTION 3 IS ENCODED HERE. EACH "FROM-LOCATION" GETS A
C CONTIGUOUS SECTION OF THE "TRAVEL" ARRAY. EACH ENTRY IN TRAVEL IS
C NEWLOC*1000 + KEYWORD (FROM SECTION 4, MOTION VERBS), AND IS NEGATED IF
C THIS IS THE LAST ENTRY FOR THIS LOCATION. KEY(N) IS THE INDEX IN TRAVEL
C OF THE FIRST OPTION AT LOCATION N.
1030 READ(1,1031)LOC,NEWLOC,TK
1031 FORMAT(99G)
IF(LOC.EQ.0)GOTO 1030
C ABOVE KLUGE IS TO AVOID AFOREMENTIONED F40 BUG
IF(LOC.EQ.-1)GOTO 1002
IF(KEY(LOC).NE.0)GOTO 1033
KEY(LOC)=TRVS
GOTO 1035
1033 TRAVEL(TRVS-1)=-TRAVEL(TRVS-1)
1035 DO 1037 L=1,20
IF(TK(L).EQ.0)GOTO 1039
TRAVEL(TRVS)=NEWLOC*1000+TK(L)
TRVS=TRVS+1
IF(TRVS.EQ.TRVSIZ)CALL BUG(3)
1037 CONTINUE
1039 TRAVEL(TRVS-1)=-TRAVEL(TRVS-1)
GOTO 1030
C HERE WE READ IN THE VOCABULARY. KTAB(N) IS THE WORD NUMBER, ATAB(N) IS
C THE CORRESPONDING WORD. THE -1 AT THE END OF SECTION 4 IS LEFT IN KTAB
C AS AN END-MARKER. THE WORDS ARE GIVEN A MINIMAL HASH TO MAKE READING THE
C CORE-IMAGE HARDER. NOTE THAT '/7-08' HAD BETTER NOT BE IN THE LIST, SINCE
C IT COULD HASH TO -1.
1040 DO 1042 TABNDX=1,TABSIZ
1043 READ(1,1041)KTAB(TABNDX),ATAB(TABNDX)
1041 FORMAT(G,A5)
IF(KTAB(TABNDX).EQ.0)GOTO 1043
C ABOVE KLUGE IS TO AVOID AFOREMENTIONED F40 BUG
IF(KTAB(TABNDX).EQ.-1)GOTO 1002
1042 ATAB(TABNDX)=ATAB(TABNDX).XOR.'PHROG'
CALL BUG(4)
C READ IN THE INITIAL LOCATIONS FOR EACH OBJECT. ALSO THE IMMOVABILITY INFO.
C PLAC CONTAINS INITIAL LOCATIONS OF OBJECTS. FIXD IS -1 FOR IMMOVABLE
C OBJECTS (INCLUDING THE SNAKE), OR = SECOND LOC FOR TWO-PLACED OBJECTS.
1050 READ(1,1031)OBJ,J,K
IF(OBJ.EQ.-1)GOTO 1002
PLAC(OBJ)=J
FIXD(OBJ)=K
GOTO 1050
C READ DEFAULT MESSAGE NUMBERS FOR ACTION VERBS, STORE IN ACTSPK.
1060 READ(1,1031)VERB,J
IF(VERB.EQ.-1)GOTO 1002
ACTSPK(VERB)=J
GOTO 1060
C READ INFO ABOUT AVAILABLE LIQUIDS AND OTHER CONDITIONS, STORE IN COND.
1070 READ(1,1031)K,TK
IF(K.EQ.-1)GOTO 1002
DO 1071 I=1,20
LOC=TK(I)
IF(LOC.EQ.0)GOTO 1070
IF(BITSET(LOC,K))CALL BUG(8)
1071 COND(LOC)=COND(LOC)+SHIFT(1,K)
GOTO 1070
C READ DATA FOR HINTS.
1080 HNTMAX=0
1081 READ(1,1031)K,TK
IF(K.EQ.-1)GOTO 1002
IF(K.EQ.0)GOTO 1081
IF(K.LT.0.OR.K.GT.HNTSIZ)CALL BUG(7)
DO 1083 I=1,4
1083 HINTS(K,I)=TK(I)
HNTMAX=MAX0(HNTMAX,K)
GOTO 1081
C FINISH CONSTRUCTING INTERNAL DATA FORMAT
C IF SETUP=2 WE DON'T NEED TO DO THIS. IT'S ONLY NECESSARY IF WE HAVEN'T DONE
C IT AT ALL OR IF THE PROGRAM HAS BEEN RUN SINCE THEN.
1100 IF(SETUP.EQ.2)GOTO 1
IF(SETUP.EQ.-1)GOTO 8305
C HAVING READ IN THE DATABASE, CERTAIN THINGS ARE NOW CONSTRUCTED. PROPS ARE
C SET TO ZERO. WE FINISH SETTING UP COND BY CHECKING FOR FORCED-MOTION TRAVEL
C ENTRIES. THE PLAC AND FIXD ARRAYS ARE USED TO SET UP ATLOC(N) AS THE FIRST
C OBJECT AT LOCATION N, AND LINK(OBJ) AS THE NEXT OBJECT AT THE SAME LOCATION
C AS OBJ. (OBJ>100 INDICATES THAT FIXED(OBJ-100)=LOC; LINK(OBJ) IS STILL THE
C CORRECT LINK TO USE.) ABB IS ZEROED; IT CONTROLS WHETHER THE ABBREVIATED
C DESCRIPTION IS PRINTED. COUNTS MOD 5 UNLESS "LOOK" IS USED.
DO 1101 I=1,100
PLACE(I)=0
PROP(I)=0
LINK(I)=0
1101 LINK(I+100)=0
DO 1102 I=1,LOCSIZ
ABB(I)=0
IF(LTEXT(I).EQ.0.OR.KEY(I).EQ.0)GOTO 1102
K=KEY(I)
IF(MOD(IABS(TRAVEL(K)),1000).EQ.1)COND(I)=2
1102 ATLOC(I)=0
C SET UP THE ATLOC AND LINK ARRAYS AS DESCRIBED ABOVE. WE'LL USE THE DROP
C SUBROUTINE, WHICH PREFACES NEW OBJECTS ON THE LISTS. SINCE WE WANT THINGS
C IN THE OTHER ORDER, WE'LL RUN THE LOOP BACKWARDS. IF THE OBJECT IS IN TWO
C LOCS, WE DROP IT TWICE. THIS ALSO SETS UP "PLACE" AND "FIXED" AS COPIES OF
C "PLAC" AND "FIXD". ALSO, SINCE TWO-PLACED OBJECTS ARE TYPICALLY BEST
C DESCRIBED LAST, WE'LL DROP THEM FIRST.
DO 1106 I=1,100
K=101-I
IF(FIXD(K).LE.0)GOTO 1106
CALL DROP(K+100,FIXD(K))
CALL DROP(K,PLAC(K))
1106 CONTINUE
DO 1107 I=1,100
K=101-I
FIXED(K)=FIXD(K)
1107 IF(PLAC(K).NE.0.AND.FIXD(K).LE.0)CALL DROP(K,PLAC(K))
C TREASURES, AS NOTED EARLIER, ARE OBJECTS 50 THROUGH MAXTRS (CURRENTLY 79).
C THEIR PROPS ARE INITIALLY -1, AND ARE SET TO 0 THE FIRST TIME THEY ARE
C DESCRIBED. TALLY KEEPS TRACK OF HOW MANY ARE NOT YET FOUND, SO WE KNOW
C WHEN TO CLOSE THE CAVE. TALLY2 COUNTS HOW MANY CAN NEVER BE FOUND (E.G. IF
C LOST BIRD OR BRIDGE).
MAXTRS=79
TALLY=0
TALLY2=0
DO 1200 I=50,MAXTRS
IF(PTEXT(I).NE.0)PROP(I)=-1
1200 TALLY=TALLY-PROP(I)
C CLEAR THE HINT STUFF. HINTLC(I) IS HOW LONG HE'S BEEN AT LOC WITH COND BIT
C I. HINTED(I) IS TRUE IFF HINT I HAS BEEN USED.
DO 1300 I=1,HNTMAX
HINTED(I)=.FALSE.
1300 HINTLC(I)=0
C DEFINE SOME HANDY MNEMONICS. THESE CORRESPOND TO OBJECT NUMBERS.
KEYS=VOCAB(0+'KEYS',1)
LAMP=VOCAB(0+'LAMP',1)
GRATE=VOCAB(0+'GRATE',1)
CAGE=VOCAB(0+'CAGE',1)
ROD=VOCAB(0+'ROD',1)
ROD2=ROD+1
STEPS=VOCAB(0+'STEPS',1)
BIRD=VOCAB(0+'BIRD',1)
DOOR=VOCAB(0+'DOOR',1)
PILLOW=VOCAB(0+'PILLO',1)
SNAKE=VOCAB(0+'SNAKE',1)
FISSUR=VOCAB(0+'FISSU',1)
TABLET=VOCAB(0+'TABLE',1)
CLAM=VOCAB(0+'CLAM',1)
OYSTER=VOCAB(0+'OYSTE',1)
MAGZIN=VOCAB(0+'MAGAZ',1)
DWARF=VOCAB(0+'DWARF',1)
KNIFE=VOCAB(0+'KNIFE',1)
FOOD=VOCAB(0+'FOOD',1)
BOTTLE=VOCAB(0+'BOTTL',1)
WATER=VOCAB(0+'WATER',1)
OIL=VOCAB(0+'OIL',1)
PLANT=VOCAB(0+'PLANT',1)
PLANT2=PLANT+1
AXE=VOCAB(0+'AXE',1)
MIRROR=VOCAB(0+'MIRRO',1)
DRAGON=VOCAB(0+'DRAGO',1)
CHASM=VOCAB(0+'CHASM',1)
TROLL=VOCAB(0+'TROLL',1)
TROLL2=TROLL+1
BEAR=VOCAB(0+'BEAR',1)
MESSAG=VOCAB(0+'MESSA',1)
VEND=VOCAB(0+'VENDI',1)
BATTER=VOCAB(0+'BATTE',1)
C OBJECTS FROM 50 THROUGH WHATEVER ARE TREASURES. HERE ARE A FEW.
NUGGET=VOCAB(0+'GOLD',1)
COINS=VOCAB(0+'COINS',1)
CHEST=VOCAB(0+'CHEST',1)
EGGS=VOCAB(0+'EGGS',1)
TRIDNT=VOCAB(0+'TRIDE',1)
VASE=VOCAB(0+'VASE',1)
EMRALD=VOCAB(0+'EMERA',1)
PYRAM=VOCAB(0+'PYRAM',1)
PEARL=VOCAB(0+'PEARL',1)
RUG=VOCAB(0+'RUG',1)
CHAIN=VOCAB(0+'CHAIN',1)
C THESE ARE MOTION-VERB NUMBERS.
BACK=VOCAB(0+'BACK',0)
LOOK=VOCAB(0+'LOOK',0)
CAVE=VOCAB(0+'CAVE',0)
NULL=VOCAB(0+'NULL',0)
ENTRNC=VOCAB(0+'ENTRA',0)
DPRSSN=VOCAB(0+'DEPRE',0)
C AND SOME ACTION VERBS.
SAY=VOCAB(0+'SAY',2)
LOCK=VOCAB(0+'LOCK',2)
THROW=VOCAB(0+'THROW',2)
FIND=VOCAB(0+'FIND',2)
INVENT=VOCAB(0+'INVEN',2)
C INITIALISE THE DWARVES. DLOC IS LOC OF DWARVES, HARD-WIRED IN. ODLOC IS
C PRIOR LOC OF EACH DWARF, INITIALLY GARBAGE. DALTLC IS ALTERNATE INITIAL LOC
C FOR DWARF, IN CASE ONE OF THEM STARTS OUT ON TOP OF THE ADVENTURER. (NO 2
C OF THE 5 INITIAL LOCS ARE ADJACENT.) DSEEN IS TRUE IF DWARF HAS SEEN HIM.
C DFLAG CONTROLS THE LEVEL OF ACTIVATION OF ALL THIS:
C 0 NO DWARF STUFF YET (WAIT UNTIL REACHES HALL OF MISTS)
C 1 REACHED HALL OF MISTS, BUT HASN'T MET FIRST DWARF
C 2 MET FIRST DWARF, OTHERS START MOVING, NO KNIVES THROWN YET
C 3 A KNIFE HAS BEEN THROWN (FIRST SET ALWAYS MISSES)
C 3+ DWARVES ARE MAD (INCREASES THEIR ACCURACY)
C SIXTH DWARF IS SPECIAL (THE PIRATE). HE ALWAYS STARTS AT HIS CHEST'S
C EVENTUAL LOCATION INSIDE THE MAZE. THIS LOC IS SAVED IN CHLOC FOR REF.
C THE DEAD END IN THE OTHER MAZE HAS ITS LOC STORED IN CHLOC2.
CHLOC=114
CHLOC2=140
DO 1700 I=1,6
1700 DSEEN(I)=.FALSE.
DFLAG=0
DLOC(1)=19
DLOC(2)=27
DLOC(3)=33
DLOC(4)=44
DLOC(5)=64
DLOC(6)=CHLOC
DALTLC=18
C OTHER RANDOM FLAGS AND COUNTERS, AS FOLLOWS:
C TURNS TALLIES HOW MANY COMMANDS HE'S GIVEN (IGNORES YES/NO)
C LIMIT LIFETIME OF LAMP (NOT SET HERE)
C IWEST HOW MANY TIMES HE'S SAID "WEST" INSTEAD OF "W"
C KNFLOC 0 IF NO KNIFE HERE, LOC IF KNIFE HERE, -1 AFTER CAVEAT
C DETAIL HOW OFTEN WE'VE SAID "NOT ALLOWED TO GIVE MORE DETAIL"
C ABBNUM HOW OFTEN WE SHOULD PRINT NON-ABBREVIATED DESCRIPTIONS
C MAXDIE NUMBER OF REINCARNATION MESSAGES AVAILABLE (UP TO 5)
C NUMDIE NUMBER OF TIMES KILLED SO FAR
C HOLDNG NUMBER OF OBJECTS BEING CARRIED
C DKILL NUMBER OF DWARVES KILLED (UNUSED IN SCORING, NEEDED FOR MSG)
C FOOBAR CURRENT PROGRESS IN SAYING "FEE FIE FOE FOO".
C BONUS USED TO DETERMINE AMOUNT OF BONUS IF HE REACHES CLOSING
C CLOCK1 NUMBER OF TURNS FROM FINDING LAST TREASURE TILL CLOSING
C CLOCK2 NUMBER OF TURNS FROM FIRST WARNING TILL BLINDING FLASH
C LOGICALS WERE EXPLAINED EARLIER
TURNS=0
LMWARN=.FALSE.
IWEST=0
KNFLOC=0
DETAIL=0
ABBNUM=5
DO 1800 I=0,4
1800 IF(RTEXT(2*I+81).NE.0)MAXDIE=I+1
NUMDIE=0
HOLDNG=0
DKILL=0
FOOBAR=0
BONUS=0
CLOCK1=30
CLOCK2=50
SAVED=0
CLOSNG=.FALSE.
PANIC=.FALSE.
CLOSED=.FALSE.
GAVEUP=.FALSE.
SCORNG=.FALSE.
C IF SETUP=1, REPORT ON AMOUNT OF ARRAYS ACTUALLY USED, TO PERMIT REDUCTIONS.
IF(SETUP.NE.1)GOTO 1
SETUP=2
DO 1998 K=1,LOCSIZ
KK=LOCSIZ+1-K
IF(LTEXT(KK).NE.0)GOTO 1997
1998 CONTINUE
OBJ=0
1997 DO 1996 K=1,100
1996 IF(PTEXT(K).NE.0)OBJ=OBJ+1
DO 1995 K=1,TABNDX
1995 IF(KTAB(K)/1000.EQ.2)VERB=KTAB(K)-2000
DO 1994 K=1,RTXSIZ
J=RTXSIZ+1-K
IF(RTEXT(J).NE.0)GOTO 1993
1994 CONTINUE
1993 DO 1992 K=1,MAGSIZ
I=MAGSIZ+1-K
IF(MTEXT(I).NE.0)GOTO 1991
1992 CONTINUE
1991 K=100
TYPE 1999,LINUSE,LINSIZ,TRVS,TRVSIZ,TABNDX,TABSIZ,KK
1 ,LOCSIZ,OBJ,K,VERB,VRBSIZ,J,RTXSIZ,CLSSES,CLSMAX
2 ,HNTMAX,HNTSIZ,I,MAGSIZ
1999 FORMAT (' Table space used:'/
1 ' ',I6,' OF ',I6,' words of messages'/
2 ' ',I6,' OF ',I6,' travel options'/
3 ' ',I6,' OF ',I6,' vocabulary words'/
4 ' ',I6,' OF ',I6,' locations'/
5 ' ',I6,' OF ',I6,' objects'/
6 ' ',I6,' OF ',I6,' action verbs'/
7 ' ',I6,' OF ',I6,' RTEXT messages'/
8 ' ',I6,' OF ',I6,' CLASS messages'/
9 ' ',I6,' OF ',I6,' hints'/
1 ' ',I6,' OF ',I6,' MAGIC messages'/
2 )
C FINALLY, SINCE WE'RE CLEARLY SETTING THINGS UP FOR THE FIRST TIME...
CALL POOF
PAUSE 'INIT Done'
C START-UP, DWARF STUFF
1 DEMO=START(0)
CALL MOTD(.FALSE.)
I=RAN(1)
HINTED(3)=YES(65,1,0)
NEWLOC=1
SETUP=3
LIMIT=330
IF(HINTED(3))LIMIT=1000
C CAN'T LEAVE CAVE ONCE IT'S CLOSING (EXCEPT BY MAIN OFFICE).
2 IF(NEWLOC.GE.9.OR.NEWLOC.EQ.0.OR..NOT.CLOSNG)GOTO 71
CALL RSPEAK(130)
NEWLOC=LOC
IF(.NOT.PANIC)CLOCK2=15
PANIC=.TRUE.
C SEE IF A DWARF HAS SEEN HIM AND HAS COME FROM WHERE HE WANTS TO GO. IF SO,
C THE DWARF'S BLOCKING HIS WAY. IF COMING FROM PLACE FORBIDDEN TO PIRATE
C (DWARVES ROOTED IN PLACE) LET HIM GET OUT (AND ATTACKED).
71 IF(NEWLOC.EQ.LOC.OR.FORCED(LOC).OR.BITSET(LOC,3))GOTO 74
DO 73 I=1,5
IF(ODLOC(I).NE.NEWLOC.OR..NOT.DSEEN(I))GOTO 73
NEWLOC=LOC
CALL RSPEAK(2)
GOTO 74
73 CONTINUE
74 LOC=NEWLOC
C DWARF STUFF. SEE EARLIER COMMENTS FOR DESCRIPTION OF VARIABLES. REMEMBER
C SIXTH DWARF IS PIRATE AND IS THUS VERY DIFFERENT EXCEPT FOR MOTION RULES.
C FIRST OFF, DON'T LET THE DWARVES FOLLOW HIM INTO A PIT OR A WALL. ACTIVATE
C THE WHOLE MESS THE FIRST TIME HE GETS AS FAR AS THE HALL OF MISTS (LOC 15).
C IF NEWLOC IS FORBIDDEN TO PIRATE (IN PARTICULAR, IF IT'S BEYOND THE TROLL
C BRIDGE), BYPASS DWARF STUFF. THAT WAY PIRATE CAN'T STEAL RETURN TOLL, AND
C DWARVES CAN'T MEET THE BEAR. ALSO MEANS DWARVES WON'T FOLLOW HIM INTO DEAD
C END IN MAZE, BUT C'EST LA VIE. THEY'LL WAIT FOR HIM OUTSIDE THE DEAD END.
IF(LOC.EQ.0.OR.FORCED(LOC).OR.BITSET(NEWLOC,3))GOTO 2000
IF(DFLAG.NE.0)GOTO 6000
IF(LOC.GE.15)DFLAG=1
GOTO 2000
C WHEN WE ENCOUNTER THE FIRST DWARF, WE KILL 0, 1, OR 2 OF THE 5 DWARVES. IF
C ANY OF THE SURVIVORS IS AT LOC, REPLACE HIM WITH THE ALTERNATE.
6000 IF(DFLAG.NE.1)GOTO 6010
IF(LOC.LT.15.OR.PCT(95))GOTO 2000
DFLAG=2
DO 6001 I=1,2
J=1+RAN(5)
C IF SAVED NOT = -1, HE BYPASSED THE "START" CALL.
6001 IF(PCT(50).AND.SAVED.EQ.-1)DLOC(J)=0
DO 6002 I=1,5
IF(DLOC(I).EQ.LOC)DLOC(I)=DALTLC
6002 ODLOC(I)=DLOC(I)
CALL RSPEAK(3)
CALL DROP(AXE,LOC)
GOTO 2000
C THINGS ARE IN FULL SWING. MOVE EACH DWARF AT RANDOM, EXCEPT IF HE'S SEEN US
C HE STICKS WITH US. DWARVES NEVER GO TO LOCS <15. IF WANDERING AT RANDOM,
C THEY DON'T BACK UP UNLESS THERE'S NO ALTERNATIVE. IF THEY DON'T HAVE TO
C MOVE, THEY ATTACK. AND, OF COURSE, DEAD DWARVES DON'T DO MUCH OF ANYTHING.
6010 DTOTAL=0
ATTACK=0
STICK=0
DO 6030 I=1,6
IF(DLOC(I).EQ.0)GOTO 6030
J=1
KK=DLOC(I)
KK=KEY(KK)
IF(KK.EQ.0)GOTO 6016
6012 NEWLOC=MOD(IABS(TRAVEL(KK))/1000,1000)
IF(NEWLOC.GT.300.OR.NEWLOC.LT.15.OR.NEWLOC.EQ.ODLOC(I)
1 .OR.(J.GT.1.AND.NEWLOC.EQ.TK(J-1)).OR.J.GE.20
2 .OR.NEWLOC.EQ.DLOC(I).OR.FORCED(NEWLOC)
3 .OR.(I.EQ.6.AND.BITSET(NEWLOC,3))
4 .OR.IABS(TRAVEL(KK))/1000000.EQ.100)GOTO 6014
TK(J)=NEWLOC
J=J+1
6014 KK=KK+1
IF(TRAVEL(KK-1).GE.0)GOTO 6012
6016 TK(J)=ODLOC(I)
IF(J.GE.2)J=J-1
J=1+RAN(J)
ODLOC(I)=DLOC(I)
DLOC(I)=TK(J)
DSEEN(I)=(DSEEN(I).AND.LOC.GE.15)
1 .OR.(DLOC(I).EQ.LOC.OR.ODLOC(I).EQ.LOC)
IF(.NOT.DSEEN(I))GOTO 6030
DLOC(I)=LOC
IF(I.NE.6)GOTO 6027
C THE PIRATE'S SPOTTED HIM. HE LEAVES HIM ALONE ONCE WE'VE FOUND CHEST.
C K COUNTS IF A TREASURE IS HERE. IF NOT, AND TALLY=TALLY2 PLUS ONE FOR
C AN UNSEEN CHEST, LET THE PIRATE BE SPOTTED.
IF(LOC.EQ.CHLOC.OR.PROP(CHEST).GE.0)GOTO 6030
K=0
DO 6020 J=50,MAXTRS
C PIRATE WON'T TAKE PYRAMID FROM PLOVER ROOM OR DARK ROOM (TOO EASY!).
IF(J.EQ.PYRAM.AND.(LOC.EQ.PLAC(PYRAM)
1 .OR.LOC.EQ.PLAC(EMRALD)))GOTO 6020
IDONDX=J
IF(TOTING(IDONDX))GOTO 6022
6020 IF(HERE(IDONDX))K=1
IF(TALLY.EQ.TALLY2+1.AND.K.EQ.0.AND.PLACE(CHEST).EQ.0
1 .AND.HERE(LAMP).AND.PROP(LAMP).EQ.1)GOTO 6025
IF(ODLOC(6).NE.DLOC(6).AND.PCT(20))CALL RSPEAK(127)
GOTO 6030
6022 CALL RSPEAK(128)
C DON'T STEAL CHEST BACK FROM TROLL!
IF(PLACE(MESSAG).EQ.0)CALL MOVE(CHEST,CHLOC)
CALL MOVE(MESSAG,CHLOC2)
DO 6023 J=50,MAXTRS
IF(J.EQ.PYRAM.AND.(LOC.EQ.PLAC(PYRAM)
1 .OR.LOC.EQ.PLAC(EMRALD)))GOTO 6023
IDONDX=J
IF(AT(IDONDX).AND.FIXED(IDONDX).EQ.0)
1 CALL CARRY(IDONDX,LOC)
IF(TOTING(IDONDX))CALL DROP(IDONDX,CHLOC)
6023 CONTINUE
6024 DLOC(6)=CHLOC
ODLOC(6)=CHLOC
DSEEN(6)=.FALSE.
GOTO 6030
6025 CALL RSPEAK(186)
CALL MOVE(CHEST,CHLOC)
CALL MOVE(MESSAG,CHLOC2)
GOTO 6024
C THIS THREATENING LITTLE DWARF IS IN THE ROOM WITH HIM!
6027 DTOTAL=DTOTAL+1
IF(ODLOC(I).NE.DLOC(I))GOTO 6030
ATTACK=ATTACK+1
IF(KNFLOC.GE.0)KNFLOC=LOC
IF(RAN(1000).LT.95*(DFLAG-2))STICK=STICK+1
6030 CONTINUE
C NOW WE KNOW WHAT'S HAPPENING. LET'S TELL THE POOR SUCKER ABOUT IT.
IF(DTOTAL.EQ.0)GOTO 2000
IF(DTOTAL.EQ.1)GOTO 75
TYPE 67,DTOTAL
67 FORMAT(/' There are ',I1,' threatening little dwarves in the'
1 ,' room with you.')
GOTO 77
75 CALL RSPEAK(4)
77 IF(ATTACK.EQ.0)GOTO 2000
IF(DFLAG.EQ.2)DFLAG=3
C IF SAVED NOT = -1, HE BYPASSED THE "START" CALL. DWARVES GET *VERY* MAD!
IF(SAVED.NE.-1)DFLAG=20
IF(ATTACK.EQ.1)GOTO 79
TYPE 78,ATTACK
78 FORMAT(/' ',I1,' of them throw knives at you!')
K=6
82 IF(STICK.GT.1)GOTO 83
CALL RSPEAK(K+STICK)
IF(STICK.EQ.0)GOTO 2000
GOTO 84
83 TYPE 68,STICK
68 FORMAT(/' ',I1,' of them get you!')
84 OLDLC2=LOC
GOTO 99
79 CALL RSPEAK(5)
K=52
GOTO 82
C DESCRIBE THE CURRENT LOCATION AND (MAYBE) GET NEXT COMMAND.
C PRINT TEXT FOR CURRENT LOC.
2000 IF(LOC.EQ.0)GOTO 99
KK=STEXT(LOC)
IF(MOD(ABB(LOC),ABBNUM).EQ.0.OR.KK.EQ.0)KK=LTEXT(LOC)
IF(FORCED(LOC).OR..NOT.DARK(0))GOTO 2001
IF(WZDARK.AND.PCT(35))GOTO 90
KK=RTEXT(16)
2001 IF(TOTING(BEAR))CALL RSPEAK(141)
CALL SPEAK(KK)
K=1
IF(FORCED(LOC))GOTO 8
IF(LOC.EQ.33.AND.PCT(25).AND..NOT.CLOSNG)CALL RSPEAK(8)
C PRINT OUT DESCRIPTIONS OF OBJECTS AT THIS LOCATION. IF NOT CLOSING AND
C PROPERTY VALUE IS NEGATIVE, TALLY OFF ANOTHER TREASURE. RUG IS SPECIAL
C CASE; ONCE SEEN, ITS PROP IS 1 (DRAGON ON IT) TILL DRAGON IS KILLED.
C SIMILARLY FOR CHAIN; PROP IS INITIALLY 1 (LOCKED TO BEAR). THESE HACKS
C ARE BECAUSE PROP=0 IS NEEDED TO GET FULL SCORE.
IF(DARK(0))GOTO 2012
ABB(LOC)=ABB(LOC)+1
I=ATLOC(LOC)
2004 IF(I.EQ.0)GOTO 2012
OBJ=I
IF(OBJ.GT.100)OBJ=OBJ-100
IF(OBJ.EQ.STEPS.AND.TOTING(NUGGET))GOTO 2008
IF(PROP(OBJ).GE.0)GOTO 2006
IF(CLOSED)GOTO 2008
PROP(OBJ)=0
IF(OBJ.EQ.RUG.OR.OBJ.EQ.CHAIN)PROP(OBJ)=1
TALLY=TALLY-1
C IF REMAINING TREASURES TOO ELUSIVE, ZAP HIS LAMP.
IF(TALLY.EQ.TALLY2.AND.TALLY.NE.0)LIMIT=MIN0(35,LIMIT)
2006 KK=PROP(OBJ)
IF(OBJ.EQ.STEPS.AND.LOC.EQ.FIXED(STEPS))KK=1
CALL PSPEAK(OBJ,KK)
2008 I=LINK(I)
GOTO 2004
2009 K=54
2010 SPK=K
2011 CALL RSPEAK(SPK)
2012 VERB=0
OBJ=0
C CHECK IF THIS LOC IS ELIGIBLE FOR ANY HINTS. IF BEEN HERE LONG ENOUGH,
C BRANCH TO HELP SECTION (ON LATER PAGE). HINTS ALL COME BACK HERE EVENTUALLY
C TO FINISH THE LOOP. IGNORE "HINTS" < 4 (SPECIAL STUFF, SEE DATABASE NOTES).
2600 DO 2602 HINT=4,HNTMAX
IF(HINTED(HINT))GOTO 2602
IDONDX=HINT
IF(.NOT.BITSET(LOC,IDONDX))HINTLC(HINT)=-1
HINTLC(HINT)=HINTLC(HINT)+1
IF(HINTLC(HINT).GE.HINTS(HINT,1))GOTO 40000
2602 CONTINUE
C KICK THE RANDOM NUMBER GENERATOR JUST TO ADD VARIETY TO THE CHASE. ALSO,
C IF CLOSING TIME, CHECK FOR ANY OBJECTS BEING TOTED WITH PROP < 0 AND SET
C THE PROP TO -1-PROP. THIS WAY OBJECTS WON'T BE DESCRIBED UNTIL THEY'VE
C BEEN PICKED UP AND PUT DOWN SEPARATE FROM THEIR RESPECTIVE PILES. DON'T
C TICK CLOCK1 UNLESS WELL INTO CAVE (AND NOT AT Y2).
IF(.NOT.CLOSED)GOTO 2605
IF(PROP(OYSTER).LT.0.AND.TOTING(OYSTER))
1 CALL PSPEAK(OYSTER,1)
DO 2604 I=1,100
IDONDX=I
2604 IF(TOTING(IDONDX).AND.PROP(IDONDX).LT.0)
1 PROP(IDONDX)=-1-PROP(IDONDX)
2605 WZDARK=DARK(0)
IF(KNFLOC.GT.0.AND.KNFLOC.NE.LOC)KNFLOC=0
I=RAN(1)
CALL GETIN(WD1,WD1X,WD2,WD2X)
C EVERY INPUT, CHECK "FOOBAR" FLAG. IF ZERO, NOTHING'S GOING ON. IF POS,
C MAKE NEG. IF NEG, HE SKIPPED A WORD, SO MAKE IT ZERO.
2608 FOOBAR=MIN0(0,-FOOBAR)
IF(TURNS.EQ.0.AND.WD1.EQ.'MAGIC'.AND.WD2.EQ.'MODE')CALL MAINT
TURNS=TURNS+1
IF(DEMO.AND.TURNS.GE.SHORT)GOTO 13000
IF(VERB.EQ.SAY.AND.WD2.NE.0)VERB=0
IF(VERB.EQ.SAY)GOTO 4090
IF(TALLY.EQ.0.AND.LOC.GE.15.AND.LOC.NE.33)CLOCK1=CLOCK1-1
IF(CLOCK1.EQ.0)GOTO 10000
IF(CLOCK1.LT.0)CLOCK2=CLOCK2-1
IF(CLOCK2.EQ.0)GOTO 11000
IF(PROP(LAMP).EQ.1)LIMIT=LIMIT-1
IF(LIMIT.LE.30.AND.HERE(BATTER).AND.PROP(BATTER).EQ.0
1 .AND.HERE(LAMP))GOTO 12000
IF(LIMIT.EQ.0)GOTO 12400
IF(LIMIT.LT.0.AND.LOC.LE.8)GOTO 12600
IF(LIMIT.LE.30)GOTO 12200
19999 K=43
IF(LIQLOC(LOC).EQ.WATER)K=70
IF(WD1.EQ.'ENTER'.AND.(WD2.EQ.'STREA'.OR.WD2.EQ.'WATER'))
1 GOTO 2010
IF(WD1.EQ.'ENTER'.AND.WD2.NE.0)GOTO 2800
IF((WD1.NE.'WATER'.AND.WD1.NE.'OIL')
1 .OR.(WD2.NE.'PLANT'.AND.WD2.NE.'DOOR'))GOTO 2610
IF(AT(VOCAB(WD2,1)))WD2='POUR'
2610 IF(WD1.NE.'WEST')GOTO 2630
IWEST=IWEST+1
IF(IWEST.EQ.10)CALL RSPEAK(17)
2630 I=VOCAB(WD1,-1)
IF(I.EQ.-1)GOTO 3000
K=MOD(I,1000)
KQ=I/1000+1
GOTO (8,5000,4000,2010)KQ
CALL BUG(22)
C GET SECOND WORD FOR ANALYSIS.
2800 WD1=WD2
WD1X=WD2X
WD2=0
GOTO 2610
C GEE, I DON'T UNDERSTAND.
3000 SPK=60
IF(PCT(20))SPK=61
IF(PCT(20))SPK=13
CALL RSPEAK(SPK)
GOTO 2600
C ANALYSE A VERB. REMEMBER WHAT IT WAS, GO BACK FOR OBJECT IF SECOND WORD
C UNLESS VERB IS "SAY", WHICH SNARFS ARBITRARY SECOND WORD.
4000 VERB=K
SPK=ACTSPK(VERB)
IF(WD2.NE.0.AND.VERB.NE.SAY)GOTO 2800
IF(VERB.EQ.SAY)OBJ=WD2
IF(OBJ.NE.0)GOTO 4090
C ANALYSE AN INTRANSITIVE VERB (IE, NO OBJECT GIVEN YET).
4080 GOTO(8010,8000,8000,8040,2009,8040,9070,9080,8000,8000,
1 2011,9120,9130,8140,9150,8000,8000,8180,8000,8200,
2 8000,9220,9230,8240,8250,8260,8270,8000,8000,8300,
3 8310)VERB
C TAKE DROP SAY OPEN NOTH LOCK ON OFF WAVE CALM
C WALK KILL POUR EAT DRNK RUB TOSS QUIT FIND INVN
C FEED FILL BLST SCOR FOO BRF READ BREK WAKE SUSP
C HOUR
CALL BUG(23)
C ANALYSE A TRANSITIVE VERB.
4090 GOTO(9010,9020,9030,9040,2009,9040,9070,9080,9090,2011,
1 2011,9120,9130,9140,9150,9160,9170,2011,9190,9190,
2 9210,9220,9230,2011,2011,2011,9270,9280,9290,2011,
3 2011)VERB
C TAKE DROP SAY OPEN NOTH LOCK ON OFF WAVE CALM
C WALK KILL POUR EAT DRNK RUB TOSS QUIT FIND INVN
C FEED FILL BLST SCOR FOO BRF READ BREK WAKE SUSP
C HOUR
CALL BUG(24)
C ANALYSE AN OBJECT WORD. SEE IF THE THING IS HERE, WHETHER WE'VE GOT A VERB
C YET, AND SO ON. OBJECT MUST BE HERE UNLESS VERB IS "FIND" OR "INVENT(ORY)"
C (AND NO NEW VERB YET TO BE ANALYSED). WATER AND OIL ARE ALSO FUNNY, SINCE
C THEY ARE NEVER ACTUALLY DROPPED AT ANY LOCATION, BUT MIGHT BE HERE INSIDE
C THE BOTTLE OR AS A FEATURE OF THE LOCATION.
5000 OBJ=K
IF(FIXED(K).NE.LOC.AND..NOT.HERE(K))GOTO 5100
5010 IF(WD2.NE.0)GOTO 2800
IF(VERB.NE.0)GOTO 4090
CALL A5TOA1(WD1,WD1X,'?',TK,K)
TYPE 5015,(TK(I),I=1,K)
5015 FORMAT(/' What do you want to do with the ',20A1)
GOTO 2600
5100 IF(K.NE.GRATE)GOTO 5110
IF(LOC.EQ.1.OR.LOC.EQ.4.OR.LOC.EQ.7)K=DPRSSN
IF(LOC.GT.9.AND.LOC.LT.15)K=ENTRNC
IF(K.NE.GRATE)GOTO 8
5110 IF(K.NE.DWARF)GOTO 5120
DO 5112 I=1,5
IF(DLOC(I).EQ.LOC.AND.DFLAG.GE.2)GOTO 5010
5112 CONTINUE
5120 IF((LIQ(0).EQ.K.AND.HERE(BOTTLE)).OR.K.EQ.LIQLOC(LOC))GOTO 5010
IF(OBJ.NE.PLANT.OR..NOT.AT(PLANT2).OR.PROP(PLANT2).EQ.0)GOTO 5130
OBJ=PLANT2
GOTO 5010
5130 IF(OBJ.NE.KNIFE.OR.KNFLOC.NE.LOC)GOTO 5140
KNFLOC=-1
SPK=116
GOTO 2011
5140 IF(OBJ.NE.ROD.OR..NOT.HERE(ROD2))GOTO 5190
OBJ=ROD2
GOTO 5010
5190 IF((VERB.EQ.FIND.OR.VERB.EQ.INVENT).AND.WD2.EQ.0)GOTO 5010
CALL A5TOA1(WD1,WD1X,'here.',TK,K)
TYPE 5199,(TK(I),I=1,K)
5199 FORMAT(/' I see no ',20A1)
GOTO 2012
C FIGURE OUT THE NEW LOCATION
C
C GIVEN THE CURRENT LOCATION IN "LOC", AND A MOTION VERB NUMBER IN "K", PUT
C THE NEW LOCATION IN "NEWLOC". THE CURRENT LOC IS SAVED IN "OLDLOC" IN CASE