
prgmABBEYA uses the following variables:
  A,B,C - scratch space for prgmZSRL
  D - boolean: Describe current room this turn?
  E - kEy general location (0=carried, 1..9=dropped)
  F - room where the guards are going (1..9)
  G - room where the Guards are now (1..9)
  H - sHovel specific location (0=carried, 1..9=dropped)
  J - boolean: verb takes a noun?; scratch space during movement
  L - paiL general location (0=carried, 1..9=dropped)
  M - pail specific location (0=carried, 1..9=dropped, \e\=basket)
  N - currently selected Noun
  R - current Room (1..9)
  S - baSket specific location (0=carried, 1..9=dropped)
  T - Time counter (0 if guards not after you, counts up otherwise)
  V - currently selected Verb
  W - boolean: pail contains Water?
  Z - key specific location (0=carried, 1..9=dropped, \e\=basket, \pi\=pail)

   0: 1\->\\Delta\Y:-62\->\Ymin
   2: AxesOff:FnOff 
   4: PlotsOff:Full
   6: ClrDraw
   7: Horizontal -9
   8: " : : :
   9: Ans+Ans\->\Str9
  10: "     _
  11: Ans+Ans+Ans+Ans
  12: Ans+Ans+Ans+Ans\->\Str8
  13: "ATTRELLISINORCHARDINCHAPEL ATDOOR   ATRIVER  ONROOF   INSHED   INBELFRY INWOODS  776454465\->\Str6
  14: DelVar T4\->\R:1\->\D:2\->\G
  17: DelVar W5\->\L:-1\->\E:2\->\S:7\->\H
  21: E\->\Z:L\->\M
  23: While 1
  24:   R\->\O:sum(Ans={M,Z,S,H\->\P
  26:   If D:Then
  28:     Text(1,3,sub(Str6,9R-6,7)," "
  29:     If R<4:Then
  31:       "A ROSE TRELLIS LEANS ON THE CHAPEL WALL.
  32:       If R=2:"THIS ORCHARD'S TREES LOOK PARCHED. THERE IS A SHED TO THE EAST.
  34:       If R=3:"THE SIDE DOOR GOES EAST. STAIRS GO UP.:A ROPE HANGS FROM THE BELFRY.
  36:     Else
  37:       If R<7:Then
  39:         "THE ROAD ENDS AT A CHAPEL TO THE NORTH.
  40:         If R=5:"YOU ARE ON A RIVERBANK SOUTH OF THE CHAPEL.
  42:         If R=6:"FROM HERE YOU CAN SEE MILES!:A STONE GARGOYLE PERCHES HERE.
  44:       Else
  45:         "THE WOODS ARE DAMP AND CHILL. A DOOR LEADS BACK WEST.
  46:         If R=8:"YOU ARE NOW ON THE ROOF'S HIGHEST POINT.
  48:         If R=7:"A GARDENER'S SHED.
  50:       End
  51:     End
  52:     If P:Then
  54:       prgmZSRL
  55:       Goto I
  56:       Lbl J
  57:       "YOU SEE HERE "+Ans
  58:     End
  59:     prgmZSRL
  60:     Lbl V
  61:   End
  62:   Text(57,3,">
  63:   Repeat Ans\!=\".
  64:     Repeat Ans:getKey\->\V:End:".
  68:     If V=51:"DROP
  70:     If V=52:"EAST
  72:     If V=53 and R=5:"FILL
  74:     If V=54:"GET
  76:     If V=61:"INVENTORY
  78:     If V=64:"LOOK
  80:     If V=71:"NORTH
  82:     If V=73:"PUT
  84:     If V=73 and R=3:"PULL
  86:     If V=74:"QUIT
  88:     If V=75:"RESTORE
  90:     If V=81:"SOUTH
  92:     If V=83:"UP
  94:     If V=85:"WEST
  96:     If V=32:91\->\V
  98:     If V=91:"EXAMINE
 100:     If V=93:"WAIT
 102:   End
 103:   Text(57,9,Ans
 104:   Ans\->\Str7
 105:   max(V={51,53,54,72,73,82,91\->\J
 106:   If 0:Then
 108:     Lbl N
 109:   End
 110:   Repeat Ans\!=\".
 111:     Repeat Ans:getKey\->\N:End:".
 115:     If N=24:DelVar J"X
 117:     If N=25:Then
 119:       If V=51:Then
 121:         1\->\J:"DOWN
 123:         If Str7=Ans:"DROP
 125:         If inString(Str7,"R")not(H)max(R={1,2,5,9:"DIG
 127:         If not(inString(Ans,"R
 128:         DelVar J
 129:       End
 130:       If V=52:Then
 132:         1\->\J:"EMPTY
 134:         If Str7=Ans or LS:DelVar J"EAST
 136:       End
 137:       If V=73:Then
 139:         "PUT
 140:         If Str7=Ans and R=3:"PULL
 142:       End
 143:       If V=81:Then
 145:         "SAVE
 146:         If Str7=Ans:"SOUTH
 148:       End
 149:       If Ans\!=\".
 150:       Then
 151:         Ans\->\Str7
 152:         Text(57,9,Ans,Str8
 153:         ".
 154:         DelVar NEnd
 155:       End
 156:     End
 157:     If J:Then
 159:       If V\>=\52 and V\<=\53:Then
 161:         If N=73 and (L\!=\R xor L:"PAIL
 163:         If N=42 and (S\!=\R xor S:"BASKET
 165:       Else
 166:         If Str7="PUT
 167:         Then
 168:           If N=42 and (S\!=\R xor S:Then
 170:             N\->\V:"BASKET
 172:           End
 173:           If N=85 and (R=5 or Wnot(L:Then
 175:             53\->\V:"WATER
 177:           End
 178:           If N=63 and (E\!=\R xor E:Then
 180:             N\->\V:"KEY
 182:           End
 183:           If N=73 and (L\!=\R xor L:Then
 185:             9\->\V:"PAIL
 187:           End
 188:           If N=81 and (H\!=\R xor H:Then
 190:             20\->\V:"SHOVEL
 192:           End
 193:           If Ans\!=\".
 194:           Then
 195:             Ans+" IN
 196:             Text(57,22,Ans
 197:             Str7+" "+Ans\->\Str7
 198:             ".
 199:           End
 200:         Else
 201:           If V=73 and N=75 and R=3:"ROPE
 203:           If N=54:Then
 205:             If V=91 and R=6:"GARGOYLE
 207:           Else
 208:             If V\!=\54 and N=43:"CHEST
 210:             If V\!=\42 and N=42 and (S\!=\R xor S:"BASKET
 212:             If V\!=\42 and V\!=\9 and N=73 and (L\!=\R xor L:"PAIL
 214:             If min(V\!=\{9,20,63:Then
 216:               If N=85 and (R=5 or V\!=\42 and Wnot(L:"WATER
 218:               If V\!=\42 and N=81 and (H\!=\R xor H:"SHOVEL
 220:               If V\!=\42 and N=63 and (E\!=\R xor E:"KEY
 222:             End
 223:           End
 224:         End
 225:       End
 226:     Else
 227:       If N=105:"X
 229:     End
 230:   End
 231:   If N=24:Then
 233:     Text(57,9,Str8
 234:     Goto V
 235:   End
 236:   If N=105:".
 238:   If Ans\!=\".
 239:   Then
 240:     Str7+" "+Ans\->\Str7
 241:     Text(57,9,Ans
 242:     Repeat Ans=105 or Ans=24:getKey:End
 245:     If Ans=24:Then
 247:       sub(Str7,1,inString(Str7," ")-1\->\Str7
 248:       Text(57,9,Ans,Str8
 249:       If Ans="PUT
 250:       73\->\V
 251:       DelVar DEnd
 252:       Goto N
 253:     End
 254:   End
 255:   ">  "+Str7
 256:   prgmZSRL
 257:   DelVar DText(57,3,Str8
 258:   N(N>30 and N<99\->\N
 259:   If N:Then
 261:     If V=53 or V=54 and N=85:Then
 263:       1\->\P:"YOU FILL THE PAIL.
 265:       If W:"THE PAIL IS ALREADY FULL.
 267:       If L and L\!=\R:DelVar P"HOW?
 269:       If N=42:DelVar P"HA!
 271:       prgmZSRL
 272:       DelVar VW or P\->\W
 273:     Else
 274:       If V=73:Then
 276:         3\->\F:T+.1\->\T
 278:         "_
 279:         If T<1:" BATS SCATTER AT THE NOISE.
 281:         "BING! BONG! BOOM!"+Ans+":YOU HEAR SHOUTS FROM THE "\->\Str7
 282:         sub(Str6,9G-6,7
 283:         Str7+sub(Ans,1,expr(sub(Str6,81+G,1
 284:         Ans+"!
 285:       End
 286:       If V=52 or V=51 and N=85 and Wnot(L:Then
 288:         If N=42:Then
 290:           \pi\
 291:           If Z=e:S\->\Z
 293:           If M=e:S\->\M
 295:           If fPart(Ans:Then:"IT'S EMPTY!
 298:           Else:"DONE.
 300:           End
 301:         Else
 302:           DelVar V1\->\Y:E
 304:           If Z=\pi\:DelVar YRW\->\Z
 306:           Ans\->\E
 307:           If W:Then
 309:             DelVar W"YOU POUR OUT THE WATER.
 310:             If R=8:Then
 312:               Ans+" IT RUNS DOWN INTO A RAINSPOUT.
 313:               If E<0:Then
 315:                 prgmZSRL
 316:                 "SOMETHING IS SWEPT FROM THE GARGOYLE'S MOUTH!
 317:                 prgmZSRL
 318:                 .5\->\E
 319:                 "GRASS AND IS LOST.
 320:                 If 1=S:Then
 322:                   1\->\E:e\->\Z
 324:                   "BASKET!
 325:                 End
 326:                 "IT FALLS INTO THE "+Ans
 327:               End
 328:             End
 329:           Else
 330:             "DONE.
 331:             If Y:"IT'S EMPTY!
 333:           End
 334:         End
 335:       End
 336:       If V=91:Then
 338:         inString(Str7,"_
 339:         "IT'S JUST A"+sub(Str7,Ans,1-Ans+length(Str7
 340:         If N=85:"IT'S WATER
 342:         If N=75:"LOOKS LIKE A BELLROPE
 344:         If N=54 and E<0:"SOMETHING SHINY IS STUCK IN THE GARGOYLE'S THROAT
 346:         DelVar NAns+".
 347:       Else
 348:         If V=51:Then
 350:           If N=85 or max(N={42,63,73,81}>not({S,E,L,H:Then
 352:             "YOU DON'T HAVE IT.
 353:           Else
 354:             If N=42:Then
 356:               R\->\S
 357:               If M=e:R\->\L
 359:               If fPart(Z:R\->\E
 361:             End
 362:             If N=63:Then:R\->\E:R\->\Z:End
 367:             If N=73:Then
 369:               R\->\L:R\->\M
 371:               If Z=\pi\:R\->\E
 373:             End
 374:             If N=81:Then:R\->\H:End
 378:             "OKAY.
 379:             If N=43:"THE GUARDS WOULD FIND IT HERE!
 381:           End
 382:         Else
 383:           If V=42 or N=43:DelVar V"CLEVER, BUT NO.
 385:         End
 386:       End
 387:       If max(V={9,20:Then
 389:         "HA!
 390:         If V=9:Then
 392:           S\->\L:e\->\M
 394:           If Z=\pi\:S\->\E
 396:           "OKAY.
 397:         End
 398:       End
 399:       If V=63:Then
 401:         e:If N=73:\pi\
 404:         Ans\->\Z
 405:         S:If N=73:L
 408:         Ans\->\E
 409:         "OKAY.
 410:       End
 411:       If V=54:Then
 413:         If max(N={42,63,73,81}>(R={S,E,L,H:Then
 415:           "YOU ALREADY HAVE IT.
 416:         Else
 417:           If N=42:DelVar S
 419:           If N=63:DelVar EDelVar Z
 421:           If N=73:DelVar LDelVar M
 423:           If N=81:DelVar H
 425:           If M=e:S\->\L
 427:           If Z=e:S\->\E
 429:           If Z=\pi\:L\->\E
 431:           "OKAY.
 432:         End
 433:       End
 434:       prgmZSRL
 435:     End
 436:   End
 437:   T+(T and N\->\T
 438:   If Jnot(Ans:End
 440:   If not(J:Then
 442:     If Str7="DIG
 443:     Then
 444:       If R=9:Goto W
 446:       "SAND!
 447:       If R<3:"HARD SOIL!
 449:       "YOU CAN'T DIG IN THE "+Ans
 450:       prgmZSRL
 451:       1\->\J
 452:     Else
 453:       V-inString(Str7,"SA\->\V
 454:       If max(Ans={71,81,52,85,83,51:Then
 456:         T+not(not(T\->\T
 457:         "04031\pi\0\pi\0
 458:         If V=81:"50420\pi\0\pi\0
 460:         If V=52:"4\pi\902\pi\0\pi\0
 462:         If V=85:"05010\pi\2\pi\3
 464:         If V=83:"60\pi\000000
 466:         If V=51:"000001030
 468:         expr(sub(Ans,R,1\->\J
 469:         If fPart(Ans:Then
 471:           ".
 472:           If R\>=\6:"THAT WOULD BE DANGEROUS!
 474:           If R=3 and not(T:"A SWARM OF BATS PREVENTS YOU!
 476:           If R=2 and E:"THE SHED IS LOCKED AND YOU HAVE NO KEY.
 478:           If Ans\!=\".
 479:           Then:prgmZSRL
 481:           Else:R+5\->\R:1\->\D
 484:           End
 485:         Else
 486:           If Ans:Then
 488:             Ans\!=\R\->\D
 489:             J\->\R
 490:           Else
 491:             "YOU CAN'T GO "+Str7+" FROM HERE.
 492:             prgmZSRL
 493:           End
 494:         End
 495:       Else
 496:         If V=61:Then
 498:           R\->\J:DelVar R
 500:           sum(not({M,Z,S,H\->\P
 501:           "NOTHING.
 502:           If P:Then
 504:             Lbl I
 505:             ":
 506:             If R=M:Ans+sub("XPAIL OF WATER",1,5+9W
 508:             If R=Z:Ans+"XKEY
 510:             If R=S:Ans+"XBASKET
 512:             If R=H:Ans+"XSHOVEL
 514:             sub(Ans,3,length(Ans)-2\->\Str7
 515:             For(C,3,P
 516:               inString(Ans,"X
 517:               sub(Str7,1,Ans-1)+",  A "+sub(Str7,Ans+1,length(Str7)-Ans\->\Str7
 518:             End
 519:             If P>1:Then
 521:               inString(Ans,"X
 522:               sub(Str7,1,Ans-1)+" AND A "+sub(Str7,Ans+1,length(Str7)-Ans
 523:             End
 524:             "A "+Ans+".\->\Str7
 525:             If S=R and max(e={M,Z:Then
 527:               Str7+"  THE BASKET CONTAINS_
 528:               If M=e:Ans+sub("A PAIL OF WATER",1,6+9W
 530:               If Z=e:Ans+sub(" AND A KEY",1+5(M\!=\e),5+5(M=e
 532:               Ans+".\->\Str7
 533:             End
 534:             If L=R and Z=\pi\:Ans+"  IN THE PAIL IS A KEY.
 536:             If R:Goto J
 538:           End
 539:           "BESIDES THE CHEST, YOU ARE CARRYING "+Ans
 540:           prgmZSRL
 541:           J\->\R:0\->\J
 543:         End
 544:         If V=64:1\->\D
 546:         T+(T and V=93\->\T
 547:         If V=74:Then
 549:           "GOODBYE.
 550:           Goto Q
 551:         End
 552:         If V=80:Then
 554:           {0,E,F,G,H,L,M,R,S,T,W,Z\->\\L\ABBEY
 555:           "SAVED.
 556:           prgmZSRL
 557:         End
 558:         If V=75:Then
 560:           0\->\\L\ABBEY(1
 561:           \L\ABBEY
 562:           If 9\>=\dim(Ans:Then
 564:             "I CAN'T.
 565:             prgmZSRL
 566:           Else
 567:             Ans(2\->\E
 568:             \L\ABBEY(3\->\F
 569:             \L\ABBEY(4\->\G
 570:             \L\ABBEY(5\->\H
 571:             \L\ABBEY(6\->\L
 572:             \L\ABBEY(7\->\M
 573:             \L\ABBEY(8\->\R
 574:             \L\ABBEY(9\->\S
 575:             \L\ABBEY(10\->\T
 576:             \L\ABBEY(11\->\W
 577:             \L\ABBEY(12\->\Z
 578:             1\->\D
 579:           End
 580:         End
 581:         J+(V=93\->\J
 582:       End
 583:     End
 584:   End
 585:   If not(TJ:End
 587:   If G=F:Then
 589:     If G=R:Goto C
 591:     randInt(1,9\->\F
 592:     If F=R and R\>=\6 and G\<=\3 and not(fPart(E:G\->\F
 594:     If G\!=\F:Then
 596:       1\->\T
 597:       sub(Str6,9F-6,7
 598:       sub(Ans,1,expr(sub(Str6,81+F,1
 599:       sub(Str6,9F-8,2)+" THE "+Ans
 600:       If .4>rand:Then
 602:         "MAYBE HE'S "+Ans+sub(".?!",randInt(1,3),1
 603:       Else
 604:         If .4>rand:Then
 606:           "HAVE WE CHECKED "+Ans+"?
 607:         Else
 608:           "I BET HE'S "+Ans+sub(".!",randInt(1,2),1
 609:         End
 610:       End
 611:       "'"+Ans+"'
 612:       prgmZSRL
 613:     End
 614:   Else
 615:     If T\>=\2:Then
 617:       If G\>=\6:Then
 619:         min(G-5,3
 620:       Else
 621:         F
 622:         If G\<=\2:Then
 624:           If F\!=\5 and G\!=\F-5:randInt(4,4+max(F+G={3,8
 626:         Else
 627:           If G=3:Then
 629:             If F<8:4
 631:           Else
 632:             F-5(F>5
 633:             If G=5:Then
 635:               If Ans>2:randInt(1,2
 637:             Else
 638:               If Ans=4:3
 640:               If Ans=5:randInt(1,2
 642:             End
 643:           End
 644:         End
 645:       End
 646:       If G=R and Ans=O:Goto C
 648:       Ans\->\G
 649:     End
 650:     If G=R:Then
 652:       Lbl C
 653:       "THE KING'S GUARDS HAVE CAUGHT YOU!
 654:       Goto Q
 655:     End
 656:   End
 657: End
 658: Lbl W
 659: "YOU DIG A HOLE AND BURY THE CHEST. THE TREASURE WILL BE SAFE NOW.
 660: prgmZSRL
 661: "CONGRATULATIONS! YOU BEAT THE GAME!
 662: Lbl Q
 663: prgmZSRL
 664: Pause 

