23 - WUMPUS - Hunt the Wumpus

Post Reply
Peet
Posts: 257
Joined: Tue Sep 29, 2020 12:01 am
Location: Germany

23 - WUMPUS - Hunt the Wumpus

Post by Peet »

HP41 Users Library - Games
Changes (among others): Initialization, Display

Unfortunately my code-optimized version from the 1980th is lost, so this contains only a few small changes.
Hunt the Wumpus was one of my favority HP41-Games so it has to be in this collection.

more info: https://en.wikipedia.org/wiki/Hunt_the_Wumpus

Usage: XEQ "WUMPUS"
Display: "A:M B:S C:I E:N" <R/S> or <E> to start
Display: warning messages (if next to a non empty cave)
Display: (e.g.) 13: 19-14-12 (you are in cave 19 and next to 19,14,12)

Input:
# <A> move to cave #
# <B> shoots an arrow to cave #
<C> info: repeat warning messages
<E> new game

Wumpus Cave-Map:

Code: Select all

  ___________1__________
 /           |          \
 |   7-------6------15  |
 |   | \          / |   |
 |   |  16------20  |   |
 2---8   |      |   14--5
 |   |   |      |   |   |
 |   |  17      19  |   |
 |   9_/ \__18__/ \_13  |
 |   |       |      |   |
 |  10------11------12  |
 | /                  \ |               
 3______________________4

Code: Select all

LBL "WUMPUS"
SF 27
"A:M B:S C:I E:N" ; local alpha info  
PROMPT
LBL E
FIX 0
CF 29
1.006
STO 10
LBL 13
RCL 10
INT
1
-
STO 11
20
XEQ 99
1
+
LBL 12
RCL IND 11
X<>Y
X=Y?
GTO 13
DSE 11
GTO 12
STO IND 10
ISG 10
GTO 13
LBL C
LBL 20
RCL 01
XEQ 50
"SMELL WUMPUS"
RCL 02
XEQ 21
"NEAR PIT"
RCL 03
XEQ 21
RCL 04
XEQ 21
"HEAR BATS"
RCL 05
XEQ 21
RCL 06
XEQ 21
LBL 22
CLA
ARCL 01
"|-: "
ARCL 07
"|--"
ARCL 08
"|--"
ARCL 09
AVIEW
RTN
LBL 01 ; AVIEW with PSE
AVIEW
PSE
RTN
LBL 21
RCL 07
X<>Y
X=Y?
XEQ 01
RCL 08
X<>Y
X=Y?
XEQ 01
RCL 09
X=Y?
XEQ 01
RTN
LBL A
XEQ 14
FS? 00
GTO 22
STO 01
GTO 09
LBL B
XEQ 14
FS? 00
GTO 22
RCL 02
X=Y?
GTO 11
XEQ 50
3
XEQ 99
7
+
RCL IND X
STO 02
RCL 01
XEQ 50
LBL 09
2.006
STO 10
RCL 01
LBL 08
RCL IND 10
X<>Y
X=Y?
GTO IND 10
ISG 10
GTO 08
GTO 20
LBL 02
"CHOMP" ; run into wumpus
XEQ 01
RTN
LBL 03
LBL 04
"FALL"	; fall into pit
XEQ 01
RTN
LBL 05
LBL 06
"SNATCH" ; grabbed by bats
XEQ 01
20
XEQ 99
1
+
STO 01
"MOVED TO "
ARCL 01
AVIEW
PSE
GTO 09
LBL 11
"GOT HIM"
AVIEW
BEEP 	; XEQ "TO" (from Basics) or BEEP
PSE
RTN
LBL 14
CF 00
RCL 07
X=Y?
RTN
X<>Y
RCL 08
X=Y?
RTN
X<>Y
RCL 09
X=Y?
RTN
"ILLEGAL CAVE"
AVIEW
PSE
SF 00
RTN
LBL 99
XROM 26,36	; XEQ "ZZ" (Basics), XROM 26,36 (TRNG - DM41X), XROM 01,49 (RAN - DM42)
*
INT
RTN
LBL 50
CF 00
5
X<>Y
STO 10
X<=Y?
GTO 10
15
X<>Y
X<=Y?
GTO 11
2
*
25
-
STO 07
21
RCL 10
1
+
16
RDN
X=Y?
R^
STO 08
15
RCL 10
1
-
X=Y?
20
X=0?
RDN
STO 09
RTN
LBL 10
1
+
X>Y?
1
STO 07
RCL 10
1
-
X=0?
5
STO 08
RCL 10
2
*
4
+
STO 09
RTN
LBL 11
2
/
FRC
X=0?
SF 00
25
RCL 10
FS? 00
4
FS? 00
CHS
CF 00
+
2
/
STO 07
16
RCL 10
1
+
X=Y?
6
STO 08
5
RCL 10
1
-
15
RDN
X=Y?
R^
STO 09
RTN
END
Attachments
23_WUMPUS.raw
(461 Bytes) Downloaded 234 times
My programmable calculators - former: CBM PR100, HP41CV, HP28S, HP11C - current: HP48G(256kB), HP35S, Prime, DM41X, DM42
Post Reply