The Museum of HP Calculators


Hunt The Wumpus for the HP-41C

This program was first published in the HP-41C Users' Library Solutions: Games by Hewlett-Packard and is used here by permission.

This program is supplied without representation or warranty of any kind. Hewlett-Packard Company and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

There are 20 caves each connected to 3 others. There are 6 occupied caves: 2 with super bats, 2 with pits, 1 with a wumpus, and 1 with a hunter (you). The object is to move from cave to cave, watching the warnings to see what is nearby, find the wumpus and shoot it with an arrow. You may only move or shoot into an adjacent cave.

The warnings are as follows:

          "SMELL WUMPUS" -- The wumpus is in an adjacent cave.

          "FEEL A DRAFT" -- Pits are in adjacent cave(s).

          "HEAR SQUEAKS" -- Super bats are in adjacent cave (s ) .

If you walk into the cave with the wumpus he will eat you. If you shoot an arrow and miss (by shooting into the wrong cave), you wake the wumpus up and he moves to one of his adjacent caves. If it's the cave you are in, he eats you. Since he has sucker feet he can walk into a cave with pits without falling. And, since he is too heavy for the bats, they cannot bother him. If you walk into a cave with pits, you fall and the game is ended. If you walk into a cave with super bats, they will carry you to some other cave randomly chosen. If the wumpus, pits, or more super bats are there, you will suffer their consequences. The bats then return to their original cave.

Each time you move you will first see the consequences (if any) of your move: "CHOMP" means you've been eaten by the wumpus, "YYIIIEEEE..." means you've fallen into a pit, and "SNATCH" followed by "MOVED TO ( )" means the super bats have grabbed you and moved you. After the consequences you see any warnings that are appropriate. Last, you will see the cave you are in followed by your adjacent caves.

The caves are arranged as a dodechedron with each vertex being a cave and each edge a tunnel.

dodechedron

Note: Requires 1 Memory Module on HP-41C

Instructions

Step

Instructions

Input Data/Units

Keys

Output Data/Units

1

Enter program

     

2

Initialize

 

[XEQ] WUMPUS 

SEED? 

3

Key in number between 0 and 1

seed 

[R/S]

(warnings)

 

 

 

 

(caves)

 4

To move:

 cave #

[A]

(consequences)

       

(warnings)

       

(caves)

To shoot an arrow:

  cave #

 [B]

 (consequences)

       

(warnings)

       

(caves)

6

To see warnings and caves again:  

[C]

(warnings)

       

(caves)

7

For another game:

 

[E]

(warnings)

 

 

 

 

(caves)

8

Go to step 4 or 5.

 

 

 

Example

   Keystrokes:          Display:
   [XEQ] [ALPHA] SIZE 
   [ALPHA] 012
   [XEQ] [ALPHA] 
   WUMPUS [ALPHA]       SEED?
   .1232123 [R/S]       HEAR SQUEAKS
   [R/S]                6-1,7,15
   1 [A]                SNATCH
   [R/S]                MOVED TO 3
   [R/S]                HEAR SQUEAKS
   [R/S]                3-4,2,10
   10 [A]               FEEL A DRAFT
   [R/S]                10-3,11,9
   11 [A]               SMELL WUMPUS
   [R/S]                11-18,12,10
   12 [B]               11-18,12,10
   18 [A]               SMELL WUMPUS
   [R/S]                18-11,19,17
   19 [B]               18-11,19,17
   17 [A]               SMELL WUMPUS
   [R/S]                FEEL A DRAFT
   [R/S]                17-9,18,16
   9 [A]                YYIIIEEEE 

(Note that you should have known pits were there from your pass through cave 10 and its warnings.)

The Program

LINE  KEYS
001  LBL "WUMPUS"
002  0                  ;Initialize
003  "SEED?"    
004  PROMPT
005  STO 00
006  SF 27
007 <>LBL E
008  FIX 0
009  CF 29
010  1.006
011  STO 10             ;_________________
012 <>LBL 13
013  RCL 10
014  INT
015  1
016  -
017  STO 11
018  20
019  XEQ 99
020  1                  ; Pick a cave
021  +
022 <>LBL 12            ;_________________
023  RCL IND 11
024  X<>Y               ; Make sure it's not used
025  X=Y?
026  GTO 13
027  DSE 11
028  GTO 12
029  STO IND 10
030  ISG 10
031  GTO 13
032 <>LBL C             ;_________________
033 <>LBL 20
034  RCL 01             ; Check
035  XEQ 50             ; surroundings
036  "SMELL WUMPUS"
037  RCL 02
038  XEQ 21
039  "FEEL A DRAFT" 
040  RCL 03
041  XEQ 21
042  RCL 04
043  XEQ 21
044  "HEAR SQUEAKS"
045  RCL 05
046  XEQ 21 
047  RCL 06
048  XEQ 21
049 <>LBL 22            ;_________________
050  CLA
051  ARCL 01            ; Output current
052  "|-- "             ; position
053  ARCL 07
054  "|-, "
055  ARCL 08
056  "|-, " 
057  ARCL 09
058  AVIEW
059  RTN                ;_________________
060 <>LBL 21
061  RCL 07
062  X<>Y               ; Test surrounding
063  X=Y?               ; caves
064  AVIEW
065  RCL 08
066  X<>Y
067  X=Y?
068  AVIEW
069  RCL 09
070  X=Y?
071  AVIEW
072  RTN
073 <>LBL A             ;_________________
074  XEQ 14
075  FS? 00             ; Move
076  GTO 22
077  STO 01
078  GTO 09
079 <>LBL B             ;_________________
080  XEQ 14             ; Shoot
081  FS? 00
082  GTO 22
083  RCL 02
084  X=Y?               ; Hit
085  GTO 11     
086  XEQ 50
087  3
088  XEQ 99
089  7
090  +
091  RCL IND X
092  STO 02             ; New Wumpus
093  RCL 01             ; position
094  XEQ 50
095 <>LBL 09            ;_________________
096  2.006
097  STO 10
098  RCL 01
099 <>LBL 08           ; Check current
100  RCL IND 10         ; position for
101  X<>Y               ; dangers
102  X=Y?
103  GTO IND 10
104  ISG 10
105  GTO 08
106  GTO 20             ;_________________
107 <>LBL 02
108  "CHOMP"
109  AVIEW              ; eaten by Wumpus
110  RTN
111 <>LBL 03            ;_________________              
112 <>LBL 04            ; Fell into pit
113  "YYIIIEEEE. . ."
114  AVIEW
115  RTN
116 <>LBL 05            ;_________________
ll7 <>LBL 06
118  "SNATCH"           ; Super bat move
119  AVIEW
120  20
121  XEQ 99
122  1
123  +
124  STO 01
125  "MOVED TO"
126  ARCL 01
127  AVIEW
128  PSE
129  GTO 09             ;_________________
130 <>LBL 11
131  "GOT HIM"          ; Shoot Wumpus
132  BEEP
133  AVIEW
134  RTN
135 <>LBL 14            ;_________________
136  CF 00
137  RCL 07             ; Illegal cave
138  X=Y ?              ; test
139  RTN
140  X<>Y
141  RCL 08
142  X=Y?
143  RTN
144  X<>Y
145  RCL 09 
146  X=Y?
147  RTN
148  "ILLEGAL CAVE"
149  AVIEW
150  SF 00
151  RTN                ;_________________
152 <>LBL 99
153  RCL 00             ; Random  number
154  9821               ; generator
155  *
156  .21137
157  +
158  FRC
159  STO 00
160  *
161  INT
162  RTN
163 <>LBL 50
164  CF 00
165  5
166  X<>Y
167  STO 10
168  X<=Y?
169  GTO 10
170  15                 ; Determine which
171  X<>Y               ; ring tbe cave is in
172  X<=Y?
173  GTO 11             ;_________________
174  2
175  *
176  25                 ; Find adjacent
177  -                  ; caves for outside
178  STO 07             ; ring
179  21
180  RCL 10
181  1
182  +
183  16
184  RDN
185  X=Y?
186  roll up
187  STO 08
188  15
189  RCL 10
190  1
191  -
192  X=Y?
193  20
194  X=0?
195  RDN        
196  STO 09
197  RTN                ;_________________
l98 <>LBL 10
199  1                  ; Find adjacent
200  +                  ; caves for inside
201  X>Y?               ; ring
202  1
203  STO 07
204  RCL 10
205  1
206  -
207  X=0?
208  5
209  STO 08
210  RCL 10
211  2
212  *
213  4
214  +
215  STO 09
216  RTN                ;_________________
217 <>LBL 11
218  2
219  ÷                  ; find adjacent
220  FRC                ; caves for middle
221  X=0?               ; ring
222  SF 00
223  25
224  RCL 10
225  FS? 00
226  4
227  FS? 00
228  CHS
229  CF 00
230  +
231  2
232  ÷
233  STO 07
234  16
235  RCL 10
236  1
237  +
238  X=Y?
239  6
240  STO 08
241  5
242  RCL 10
243  1
244  - 
245  15
246  RDN
247  X=Y?
248  roll up
249  STO 09
250  RTN
251  .END.

Register Use

R00  Seed
R01  Hunter
R02  Wumpus
R03  Pits
R04  Pits
R05  S. bats
R06  S. bats
R07  Adj. cave
R08  Adj. cave
R00  Adj. cave
R10  Used                    
R11  Used
R12  Used

Flags

00 Used

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall