mirror of
https://github.com/PDP-10/its.git
synced 2026-04-28 21:08:01 +00:00
349 lines
12 KiB
Plaintext
349 lines
12 KiB
Plaintext
|
|
(comment)
|
|
|
|
(progn ;don't print out stuff
|
|
(princ '|Please wait while I get ready|)
|
|
(alloc '(REGPDL 120000.))
|
|
(alloc '(SPECPDL 48000.))
|
|
(alloc '(FIXPDL 24000.))
|
|
(alloc '(LIST 75000.))
|
|
(alloc '(SYMBOL 48000.))
|
|
(alloc '(FIXNUM 75000.))
|
|
(alloc '(FLONUM 75000.))
|
|
(alloc '(BIGNUM 12000.))
|
|
(alloc '(ARRAY 12000.))
|
|
|
|
(setsyntax '/
|
|
'/ '/ )
|
|
(defprop debug ((dsk rwk) debug fasl) autoload)
|
|
(defprop bt ((dsk rwk) debug fasl) autoload)
|
|
(setq *rset t)
|
|
;;; SC-HELP calls for human intervention when appropriate.
|
|
|
|
(defun g-*uwrite (name mode newdefault)
|
|
(DECLARE (SPECIAL UWRITE OUTFILES))
|
|
(cond (uwrite
|
|
(setq outfiles (delq uwrite outfiles))
|
|
(close uwrite)
|
|
(setq uwrite nil)))
|
|
((lambda (file)
|
|
(setq outfiles
|
|
(cons (setq uwrite file)
|
|
outfiles))
|
|
(car (defaultf newdefault)))
|
|
(open name mode)))
|
|
|
|
(DEFUN G-TERPRI NIL
|
|
(DECLARE (SPECIAL GV-CURSORPOS G-SILENT *SS-ACTIVE))
|
|
(SETQ GV-CURSORPOS 0.)
|
|
(COND ((AND G-SILENT
|
|
(OR *SS-ACTIVE
|
|
(NOT (CURSORPOS))
|
|
(= (CDR (CURSORPOS)) 0.)))
|
|
(SETQ ^W T)
|
|
(TYO 13.)
|
|
(SETQ ^W NIL))
|
|
(T (TYO 13.))))
|
|
|
|
(DEFUN SC-HELP (CAUSE)
|
|
(G-TSAY '(|****** This student's model is beyond my limitations. ******|))
|
|
(COND ((< SL-REPEAT 0.0)
|
|
(SETQ SL-REPEAT 0.9)
|
|
(SC-UPDATE-MODEL)))
|
|
(SETQ SC-NOTEST CAUSE))
|
|
|
|
(DEFUN GCI-CREATE NARGS
|
|
(CONS (ARG 1.)
|
|
(GCI-WCREATE (ARG 1.)
|
|
NIL
|
|
(COND ((> (ARG NIL) 1.) (ARG 2.))))))
|
|
|
|
;;; GCI-WCREATE does the actual work of WGI-CREAT.
|
|
|
|
(DEFUN GCI-WCREATE (NUM LIST VALS)
|
|
(COND ((< NUM 1.) (RPLACD (LAST LIST) LIST))
|
|
(T (GCI-WCREATE (1- NUM)
|
|
(CONS (GCI-VAL VALS) LIST)
|
|
(CDR VALS)))))
|
|
|
|
;;; GCI-VAL returns the appropriate value.
|
|
|
|
(DEFUN GCI-VAL (VALS) (COND ((ATOM VALS) NIL) (T (CAR VALS))))
|
|
|
|
(ENDPAGEFN TYO NIL)
|
|
(SETSYNTAX 46. 128. NIL)
|
|
(SETQ IBASE 10.
|
|
BASE 10.
|
|
*NOPOINT T
|
|
*SS-ACTIVE nil
|
|
*SS-VERSION NIL
|
|
WE-VERSION '|eight|
|
|
WEV-RECREATE NIL
|
|
WE-GAME-HIST NIL
|
|
DB-NUM-CRULES 6.
|
|
DB-NUM-RULES 19.
|
|
DB-NUM-PROP 7.
|
|
DB-NUM-DPROP 18.
|
|
DB-DATE 0.
|
|
WAV-TOLD-RULE NIL
|
|
CX-WHY-BETTER NIL
|
|
CX-WHY-WORSE NIL
|
|
EGV-PLURAL 'EGV-PLURAL
|
|
EGV-BECAUSE '(|, because|)
|
|
EG-SPEC 'EG-SPEC
|
|
SC-LREPEAT 0.0
|
|
SC-UREPEAT 5.0
|
|
SC-LFORGET 2.0
|
|
SC-UFORGET 30.0
|
|
LEG-THEREFORE (GCI-CREATE 3.
|
|
'((|, and so|)
|
|
(|. Therefore|)
|
|
(|. Hence|)))
|
|
LEG-ALSO (GCI-CREATE 3.
|
|
'((|. Also,|)
|
|
(|, and|)
|
|
(|. Likewise,|)))
|
|
LEG-CONVERSELY (GCI-CREATE 2.
|
|
'((|. Conversely,|)
|
|
(|. In contrast,|)))
|
|
LEG-HOWEVER (GCI-CREATE 2.
|
|
'((|. However|) (|, but|)))
|
|
LWA-TELL-C4 (GCI-CREATE 3.
|
|
'((LIST '|I don't know,|
|
|
DB-NAME
|
|
'|, but|)
|
|
(LIST '|Well,|
|
|
DB-NAME
|
|
'|, I think that|)
|
|
(LIST '|You know,|
|
|
DB-NAME
|
|
'|,|)))
|
|
LWAW-TELL-WANDER (GCI-CREATE 3.
|
|
'((LIST DB-NAME
|
|
'|, we seem to be going in circles|)
|
|
(LIST '|I seem to remember just|
|
|
'|coming from that cave,|
|
|
DB-NAME)
|
|
(LIST '|We seem to be wandering aimlessly,|
|
|
DB-NAME)))
|
|
G-DOUBLESPACE NIL
|
|
G-LAST 32.
|
|
G-BLAST 32.
|
|
G-BBLAST 46.
|
|
G-SILENT nil
|
|
G-READ-NUM 1.
|
|
GV-CURSORPOS 0.
|
|
XP-P12-CHANGED NIL
|
|
SC-INCREASE-FORGET NIL
|
|
SC-DECREASE-FORGET NIL
|
|
SC-INCREASE-REPEAT NIL
|
|
SC-DECREASE-REPEAT NIL
|
|
SF-VAR-LIST '(DB-UNAME DB-NAME
|
|
DB-LAST-DATE
|
|
DB-NUMWINS
|
|
DB-NUMLOSSES
|
|
DB-MOVES
|
|
DB-DEBUG
|
|
DB-COMMENT
|
|
SL-REPEAT
|
|
SL-FORGET
|
|
SL-RECEPTIVITY
|
|
SL-HEARD-OF
|
|
WA-CAN-BACKTRACK
|
|
WA-TOLD-BACKTRACK
|
|
WE-MOVE-NUM
|
|
SL-LAST-LEARNED
|
|
SC-INITIALIZED
|
|
SL-TUTOR
|
|
DB-GAME-NUM
|
|
DB-HISTORY))
|
|
(ARRAY ADB-CAVE T 1. DB-NUM-PROP)
|
|
(ARRAY ADB-DCAVE T 1. DB-NUM-DPROP 1.)
|
|
(ARRAY AEG-TELL-AVOID T 3. 3.)
|
|
(ARRAY ADB-TELL-WARNING T 3. 3.)
|
|
(ARRAY ADB-TELL-DANGER T 3. 3.)
|
|
(ARRAY ASK-WDRULES FIXNUM (1+ DB-NUM-RULES) 2. 3.)
|
|
(ARRAY ASK-DRULES FLONUM (1+ DB-NUM-RULES) 2. 3.)
|
|
(ARRAY AWE-EXPL-RULES T 16.)
|
|
(ARRAY ASL-PHASE-RULES T 5. 3.)
|
|
(ARRAY ASL-NEXT-RULES T 5. 3.)
|
|
(ARRAY ASL-PNUM-DANGERS T 5. 3.)
|
|
(ARRAY ASKC-RULES T 8. 3.)
|
|
(ARRAY AEG-NUMBER T 10.)
|
|
(MAPC (FUNCTION (LAMBDA (X) (*ARRAY X T 3.)))
|
|
'(AXS-CHANGED-SETS AEG-DANGER-SING AEG-DANGER-PLUR
|
|
ASL-WORK-ON-RULES AXR-FOUND-N AXS-EXACT-CAVES
|
|
AXS-PARTIAL-SETS AXS-COMPLETE-SETS
|
|
APS-RULE-ARRAY AEG-WARNING-PRES AEG-WARNING-PAST
|
|
ASC-INITIALIZED AEG-ENCOUNTER AWA-TOLD-RULES))
|
|
(MAPC (FUNCTION (LAMBDA (X) (*ARRAY X 'FIXNUM 3.)))
|
|
'(ADB-NUM-DANGERS ADB-WARNING-DIST AXR-NUM-IDENTIFIED
|
|
ASL-PHASE ADB-DIST-START))
|
|
(MAPC (FUNCTION (LAMBDA (X) (*ARRAY X 'FLONUM 3.)))
|
|
'(AXX-EST-NUM-DANGERS AXP-PROB12))
|
|
(MAPC (FUNCTION (LAMBDA (X Y)
|
|
(DECLARE (SPECIAL EGV-PLURAL))
|
|
(PUTPROP EGV-PLURAL Y X)))
|
|
'(|is cave| |is| |can| |could| |is rule|)
|
|
'(|are caves| |are| |can| |could| |are rules|))
|
|
(MAPC (FUNCTION (LAMBDA (X Y)
|
|
(DECLARE (SPECIAL EG-SPEC))
|
|
(PUTPROP EG-SPEC Y X)))
|
|
'(|were| |fell|)
|
|
'(|would have been| |would have fallen|))
|
|
(MAPC (FUNCTION (LAMBDA (X Y) (STORE (ASKC-RULES X 1.) Y)))
|
|
'(7. 6. 5. 4. 3. 2. 1. 0.)
|
|
'(0. 2. 1. 2. 0. 0. 0. 0.))
|
|
(MAPC (FUNCTION (LAMBDA (X A B C D E F G H I)
|
|
(STORE (ASL-PHASE-RULES X 0.) A)
|
|
(STORE (ASL-PHASE-RULES X 1.) B)
|
|
(STORE (ASL-PHASE-RULES X 2.) C)
|
|
(STORE (ASL-NEXT-RULES X 0.) D)
|
|
(STORE (ASL-NEXT-RULES X 1.) E)
|
|
(STORE (ASL-NEXT-RULES X 2.) F)
|
|
(STORE (ASL-PNUM-DANGERS X 0.) G)
|
|
(STORE (ASL-PNUM-DANGERS X 1.) H)
|
|
(STORE (ASL-PNUM-DANGERS X 2.) I)))
|
|
'(4. 3. 2. 1. 0.)
|
|
'((14.) (6. 10. 12. 13.) (4. 7. 11.) (0. 3. 5.) (1.))
|
|
'((14.) (6. 9. 10. 12. 13.) (4. 7. 11.) (0. 3. 5.)
|
|
(1.))
|
|
'((12. 13.) (6. 8. 9. 10. 11. 15.) (4. 7.)
|
|
(0. 2. 3. 5. 19.) (1.))
|
|
'((14.) (12. 13.) (4. 7. 11.) (3. 5.) (1.))
|
|
'((14.) (12. 13.) (4. 7. 11.) (3. 5.) (1.))
|
|
'((12. 13.) (11.) (4. 7.) (3. 5. 19.) (1.))
|
|
'(4. 3. 3. 2. 1.)
|
|
'(2. 3. 3. 2. 1.)
|
|
'(2. 1. 1. 1. 1.))
|
|
(MAPC (FUNCTION (LAMBDA (W A B C D E)
|
|
(STORE (ASL-PHASE W) 0.)
|
|
(STORE (ASL-WORK-ON-RULES W)
|
|
(ASL-PHASE-RULES 0. W))
|
|
(STORE (AEG-ENCOUNTER W) A)
|
|
(STORE (AEG-WARNING-PRES W) B)
|
|
(STORE (AEG-WARNING-PAST W) C)
|
|
(STORE (AEG-DANGER-SING W) D)
|
|
(STORE (AEG-DANGER-PLUR W) E)))
|
|
'(0. 1. 2.)
|
|
'((|were| |picked up by|) (|fell| |into|)
|
|
(|were| |eaten by|))
|
|
'((|hear squeaking|) (|feel a breeze|)
|
|
(|smell the Wumpus|))
|
|
'((|heard squeaking|) (|felt a breeze|)
|
|
(|smelled the Wumpus|))
|
|
'((|bats|) (|a pit|) (|the Wumpus|))
|
|
'((|bats|) (|pits|) (|the Wumpus|)))
|
|
(MAPC (FUNCTION (LAMBDA (X Y) (STORE (AEG-NUMBER X) Y)))
|
|
'(9. 8. 7. 6. 5. 4. 3. 2. 1. 0.)
|
|
'((|ten|) (|nine|) (|eight|) (|seven|) (|six|)
|
|
(|five|) (|four|) (|three|) (|two|) (|one|)))
|
|
(MAPC (FUNCTION (LAMBDA (X Y) (STORE (AWE-EXPL-RULES X) Y)))
|
|
'(15. 14. 13. 12. 11. 10. 9. 8. 7. 6. 5. 4. 3. 2. 1. 0.)
|
|
'((|P15, Shooting Principle, Whenever the probability of|
|
|
|the Wumpus being in a cave exceeds 0.25, it is safer to|
|
|
|shoot into the cave before visitng it. Hence, the more|
|
|
|likely it is that the Wumpus is in the cave, the less|
|
|
|likely it is that the player will be killed.|)
|
|
(|P14, Adjust For Multiple Evidence Principle, In cases|
|
|
|where P13 is applied, the other members of said|
|
|
|cave-set are less likely to contain the danger.|)
|
|
(|P13, Multiple Evidence Principle, if there is multiple|
|
|
|evidence that a given cave contains a danger (i.e. it|
|
|
|is a member of two cave-sets), then it is more likely|
|
|
|that the given cave contains the danger.|)
|
|
(|P12, Explain Away Evidence Principle, When it is noted|
|
|
|that there are two cave-sets, one of which is a subset|
|
|
|of the other, there is no evidence that those caves|
|
|
|in the superset and not in the subset whether or|
|
|
|not said caves contain a danger (as the caves in the|
|
|
|subset completely explain the warning) so the|
|
|
|probability is reduced to some consistent value.|)
|
|
(|P11, Equal Likelihood Principle, An estimation of|
|
|
|the probability for a given cave is 1N, where N|
|
|
|is the number of caves in the smallest cave-set|
|
|
|of which said cave is a member.|)
|
|
(|L10, Certain caves can be marked as "more than zero|
|
|
|away" based on consideration of the different|
|
|
|complete cave-sets and the number of dangers. |)
|
|
(|L9, If the player encountered a danger in a cave,|
|
|
|then the cave does not contain a danger of higher|
|
|
|priority, i.e. the Wumpus eats the player before|
|
|
|he can fall into a pit, and he will fall into a|
|
|
|pit before he is picked up by bats.|)
|
|
(|L8, When the algorithm is creating cave-sets and|
|
|
|it encounters a cave which would be N caves away|
|
|
|but which is also "more than N away", then that cave|
|
|
|can not have any contributions to the cave-set. |)
|
|
(|L7, If a cave is "more than (N-1) away" and|
|
|
|"less than (N+1) away", then it is "N away". |)
|
|
(|L6, If all of a caves neighbors are "more than|
|
|
|(N-1) away", then it can be marked "more than N away". |)
|
|
(|L5, If a cave is marked "more than N away" then all|
|
|
|of its neighbors can be marked as "more than (N-1) away". |)
|
|
(|L4, If a cave is visited and there is a warning,|
|
|
|then that cave is "less than (N-1) away". |)
|
|
(|L3, If a cave is visited and there is not a warning,|
|
|
|then that cave is "more than N away" where N|
|
|
|is the distance that the warning propagates. |)
|
|
(|L2, If the player shoots an arrow into a cave|
|
|
|and does not kill the Wumpus, then that cave can|
|
|
|be marked as "more than zero away" (Wumpus). |)
|
|
(|L1, A cave can be marked as "more than zero|
|
|
|away" if it was safely visited. |)
|
|
(|L0, A cave can be marked as "zero away" if it|
|
|
|was visited and found to contain a danger. |)))
|
|
;;; The other dangers are set when it is known how many there are.
|
|
(MAPC (FUNCTION (LAMBDA (W A X Y Z)
|
|
(STORE (AEG-TELL-AVOID W Z) A)
|
|
(STORE (ADB-TELL-WARNING W Z) X)
|
|
(STORE (ADB-TELL-DANGER W Z) Y)))
|
|
'(0. 1. 2. 0. 1. 2. 0. 1. 2.)
|
|
'((APPEND '(|it is not wise to visit caves with bats|
|
|
|because while THEY will not harm us|
|
|
|they will carry us to another cave which|
|
|
|could contain|) (AEG-DANGER-SING 1.) '(|or|) (AEG-DANGER-SING 2.))
|
|
(APPEND
|
|
'(|we should avoid bats because they|
|
|
|could drop us in a cave with|)
|
|
(AEG-DANGER-SING 1.)
|
|
'(|or|)
|
|
(AEG-DANGER-SING 2.))
|
|
'(|it is best to avoid bats as they could carry us to a fatal cave|)
|
|
(APPEND '(|we should try not to stumble into|)
|
|
(AEG-DANGER-SING 1.)
|
|
'(|as it would be fatal|))
|
|
'(|we should avoid pits as they are fatal|)
|
|
'(|pits are dangerous as falling into one is fatal|)
|
|
(APPEND '(|it is best to avoid|)
|
|
(AEG-DANGER-PLUR 2.)
|
|
'(|as|)
|
|
(AEG-DANGER-PLUR 2.)
|
|
'(|eats unwary players who stumble into his lair|))
|
|
'(|we should avoid Wumpii as they eat unwary players|)
|
|
'(|Wumpii are dangerous as they have insatiable|
|
|
|appetites for bumbling players|))
|
|
'((|Squeak. I hear bats, they must be in one of the neighboring caves. |)
|
|
(|Squeak. I hear bats. |) (|Squeak. |)
|
|
(|Brrrr. I feel a breeze! We must be next to a pit. |)
|
|
(|Brrrr. I feel a breeze. |) (|Brrrr. |)
|
|
(|Whew, what a stench! That is the smell of the Wumpus. |
|
|
|It means that we are within two caves of the Wumpus. |)
|
|
(|What a stench! The Wumpus is near. |)
|
|
(|What a stench! |))
|
|
'((|Bon Voyage! We have been picked up by bats! |)
|
|
(|Bon Voyage! Bats have picked us up. |)
|
|
(|Bon Voyage! |)
|
|
(|So Loonnngggggggg. We have fallen into a pit. |)
|
|
(|So Loonnngggggggg. We have fallen in a pit. |)
|
|
(|So Loonnngggggggg. |)
|
|
(|Oh no, the Wumpus is in here! Chomp Chomp Chomp. |)
|
|
(|Oh no, it's the Wumpus! Chomp Chomp Chomp. |)
|
|
(|Chomp Chomp Chomp. |))
|
|
'(0. 0. 0. 1. 1. 1. 2. 2. 2.))
|
|
(terpri)
|
|
(load '((dsk games) wa fasl))
|
|
(princ '|thanks for waiting, we are about to begin|)
|
|
(restart))
|
|
|
|
|