Post Reply 
(71B) The Devil's Dungeon game
12-18-2019, 08:12 PM
Post: #1
(71B) The Devil's Dungeon game
This is the BASIC listing for:

The Devil's Dungeon Game

From:
Stimulating Simulations, Second Edition, 1982, ISBN 0-8104-5170-0

The game, as listed in the book, relies on IF commands as the first command in a multi-command line. If the condition of the IF is true, then the rest of the multi-command line is executed, if the condition of the IF is false, the rest of the multi-command line is ignored. This is apparently not legal in HP-71B BASIC, so I had to refactor the program so as to not have any multi-command lines that begin with an IF command.

The game code had some 2-letter variables like YS. These were changed to 1 letter and 1 digit variables, like Y1.

The game code has a number of array variables, and it also had some single instance variables using the same character, like X and X(16). These were changed to discriminate between them, like X0 and X(16).

I have run the game a number of times, and it appears to be running properly, per the description and instructions in the book. This game runs well on the HP-71B with PIL-Box and the pyILPer application on an attached PC. If you have access to the Stimulating Simulations book for the instructions and examples, hopefully you may enjoy this game, too.

Code:

1 REM The Devil's Dungeon Game
2 REM Stimulating Simulations, 2nd Edition, 1982
4 REM Adapted to HP-71B, December 2019, smp
6 REM
7 REM Set Room 1
8 REM
10 DIM R(16),L(65),F(16),X(19),B(16)
15 REAL L0,G,E,D,I,J,F0,N,Q,R0,S,M,T,X0
20 L0=1 @ G=0 @ E=0 @ X0=16
30 D=1 @ Y1=101 @ Y2=101
40 FOR I=0 TO 65 @ L(I)=0 @ NEXT I
50 FOR I=1 TO X0
55 N=INT((3*RND)+1)
60 IF I=1 THEN N=3
70 FOR J=1 TO N
80 R0=INT(64*RND+1)
90 IF L(R0)<>0 THEN 80
100 L(R0)=I
110 NEXT J
120 R(I)=INT(524287*RND) @ B(I)=0
130 NEXT I 
140 B(L0)=1 @ R(1)=24576 @ FOR I=1 TO 19 @ X(I)=0 @ NEXT I
144 REM
145 REM Hazards
146 REM
150 IF RND>=0.01 THEN 160
155 DISP"Tremor!" @ FOR I=1 TO 20 @ L(I)=INT(X0*RND+1) @ NEXT I
160 IF RND>=0.01 THEN 170
165 DISP"Tremor!" @ FOR I=1 TO 20 @ L(I)=0 @ NEXT I
170 IF X(1)*X(12)<>1 OR RND>=0.4 THEN 180
175 DISP"Cursed by demon!" @ Y2=INT(0.5*Y2)
180 IF X(9)*X(11)<>1 OR RND>=0.4 THEN 190
182 DISP"Gassed!" @ Y1=INT(0.5*Y1)
185 REM
186 REM Decrement & Test
187 REM
190 Y2=Y2-D
200 Y1=Y1-D
210 IF Y1>0 AND Y2>0 THEN 220
211 DISP"You're dead!" @ END
214 REM
215 REM Output Status
216 REM
220 DISP
230 DISP"Gold: ";G;" Exp: ";E;" Depth: ";D
240 DISP"Speed: ";Y2;" Strength: ";Y1 @ GOSUB 250 @ GOTO 310
244 REM
245 REM Adjacent Rooms
246 REM
250 FOR I=1 TO X0 @ F(I)=0 @ NEXT I
260 FOR I=1 TO 64
270 IF L0<>L(I) THEN 300
280 IF L(I+1)<>0 AND L(I+1)<>L0 THEN F(L(I+1))=1
290 IF L(I-1)<>0 AND L(I-1)<>L0 THEN F(L(I-1))=1
300 NEXT I @ RETURN
304 REM
305 REM Convert
306 REM
310 N=R(L0)
320 FOR I=1 TO 19 @ Q=INT(N/2) @ X(I)=2*(N/2-Q) @ N=Q @ NEXT I
324 REM
325 REM Monsters, Demons, Gas
326 REM
330 IF X(2)<>0 THEN 340
332 M1=0 @ GOTO 380
340 IF F0=1 THEN 370
350 M1=D*(X(3)+2*X(4)+4*X(5)+L0)
360 M2=D*(X(6)+2*X(7)+4*X(8)+L0)
370 DISP"Monster's Speed: ";M2;" Strength: ";M1
380 IF X(1)*X(12)=1 THEN DISP"Demons!"
390 IF X(9)*X(11)=1 THEN DISP"Poison Gas!"
394 REM
395 REM Treasure
396 REM
400 IF X(10)=1 THEN 410
402 T=0 @ GOTO 430
410 T=X(11)+2*X(12)+4*X(13)+1
420 DISP"Maximum Gold: ";T*L0*D+1
424 REM
425 REM Slides & Drop-offs
426 REM
430 S=X(15)+2*X(16)+4*X(17)+8*X(18)+1
440 IF S>X0 THEN S=1
450 IF S=0 THEN S=1
460 IF X(14)=0 OR S=L0 THEN 480
470 DISP"Slide To: ";S
480 IF X(19)*X(13)=1 THEN DISP"Drop-off"
484 REM
485 REM Input Move
486 REM
490 DISP"Move From: ";L0;" To: ";
500 FOR I=1 TO X0
510 IF F(I)=1 AND I<>L0 THEN DISP I;
520 NEXT I
530 INPUT M
535 IF M=88 THEN 1000
540 IF M=>0 OR X(19)*X(13)<>1 THEN 550
545 D=D+1 @ F0=0 @ GOTO 40
550 IF M=>0 THEN 560
555 DISP"No drop-off" @ GOTO 150
560 IF M<=X0 OR L0<>1 THEN 570
565 DISP"You found ";G;" pieces of gold!" @ END
570 IF M<=X0 THEN 600
574 REM
575 REM Magic Wand
576 REM
580 IF RND>=0.4 THEN 590
582 DISP"Backfire!" @ Y1=INT(0.5*Y1) @ Y2=INT(0.5*Y2) @ GOTO 150
590 DISP"Wand works!" @ R(L0)=266240 @ GOTO 220
594 REM
595 REM Move Trade
596 REM
600 IF M1>0 THEN 700
610 IF M<>0 OR L0<>1 THEN 920
620 DISP"Experience: ";E;" Speed: ";Y2;" Strength: ";Y1 @ INPUT"Add Speed: ";N
630 IF E-N<0 THEN DISP"Need more experience!" @ GOTO 620
640 E=E-N @ Y2=Y2+N @ DISP"Experience left: ";E
650 INPUT"Add Strength: ";N
660 IF E-N<0 THEN DISP"Need more experience!" @ GOTO 650
670 E=E-N @ Y1=Y1+N @ DISP"Experience left: ";E
680 GOTO 220
694 REM
695 REM Fight
696 REM
700 F0=1
710 IF M>0 THEN 900
720 Y3=INT(RND*Y1) @ M3=INT(RND*M1)
730 IF Y3>M1 THEN Y3=M1
740 IF M3>Y1 THEN M3=Y1
750 IF RND*Y2>RND*M2 THEN 780
760 DISP"Monster attacks!" @ Y1=Y1-M3 @ M1=M1-INT(0.5*Y3)
770 GOTO 800
780 DISP"You attack!" @ M1=M1-Y3 @ Y1=Y1-INT(0.5*M3)
800 E=E+2*Y3
810 IF M1>0 THEN 820
812 DISP"Monster is dead!" @ R(L0)=R(L0)-2 @ GOTO 150
820 DISP"Monster still alive!" @ GOTO 150
894 REM
895 REM Run
896 REM
900 IF RND*Y2<=RND*M2 THEN 910
902 DISP"Escaped!" @ GOTO 970
910 DISP"Monster hit you!" @ Y1=Y1-INT(0.2*M1) @ GOTO 970
914 REM
915 REM Treasure
916 REM
920 IF T=0 THEN 970
930 G1=INT(RND*T*L0*D)+1
940 IF X(1)*X(12)<>1 OR RND>=0.4 THEN 950
942 DISP"Demon got gold!" @ G1=0
950 DISP"You found ";G1;" pieces of gold!" @ G=G+G1 @ R(L0)=R(L0)-512
960 E=E+G1
964 REM
965 REM Move
966 REM
970 IF F(M)<>1 AND M<>S THEN 980
972 L0=M @ F0=0 @ E=E+D @ B(L0)=1 @ GOTO 150
980 DISP"Not adjacent" @ GOTO 150
994 REM
995 REM Print Rooms
996 REM
1000 L1=L0 @ FOR K=1 TO X0
1010 IF B(K)<>1 THEN 1070
1020 DISP K;"--";
1030 L0=K @ GOSUB 250
1040 FOR J=1 TO X0
1050 IF F(J)=1 AND J<>K THEN DISP J;
1060 NEXT J @ DISP
1070 NEXT K
1080 L0=L1 @ GOTO 220
2000 END

smp
Find all posts by this user
Quote this message in a reply
12-18-2019, 10:07 PM
Post: #2
RE: (71B) The Devil's Dungeon game
(12-18-2019 08:12 PM)smp Wrote:  The game, as listed in the book, relies on IF commands as the first command in a multi-command line. If the condition of the IF is true, then the rest of the multi-command line is executed, if the condition of the IF is false, the rest of the multi-command line is ignored. This is apparently not legal in HP-71B BASIC...

Unless I'm misunderstanding you, it is legal in HP-71 BASIC. For example:

IF 1=1 THEN DISP "TRUE" @ BEEP @ BEEP ELSE DISP "FALSE" @ BEEP

This displays TRUE and beeps twice. Change the 1=1 to 1=2 and it'll display FALSE and beep once.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
12-19-2019, 12:51 AM
Post: #3
RE: (71B) The Devil's Dungeon game
.
Hi,

(12-18-2019 10:07 PM)Joe Horn Wrote:  
(12-18-2019 08:12 PM)smp Wrote:  The game, as listed in the book, relies on IF commands as the first command in a multi-command line. If the condition of the IF is true, then the rest of the multi-command line is executed, if the condition of the IF is false, the rest of the multi-command line is ignored. This is apparently not legal in HP-71B BASIC...

Unless I'm misunderstanding you, it is legal in HP-71 BASIC. [...]


It depends on what statements follow after the initial IF. For instance, there's this sequence in the posted code:

       150 IF RND>=0.01 THEN 160
       155 DISP"Tremor!" @ FOR I=1 TO 20 @ L(I)=INT(X0*RND+1) @ NEXT I
       160 ...


If this was originally like this:

       150 IF RND<0.01 THEN DISP"Tremor!" @ FOR I=1 TO 20 @ L(I)=INT(X0*RND+1) @ NEXT I

then it would certainly not be legal in the HP-71B, as FOR..NEXT loops aren't admisible after either THEN or ELSE.

Regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-19-2019, 06:46 AM
Post: #4
RE: (71B) The Devil's Dungeon game
(12-19-2019 12:51 AM)Valentin Albillo Wrote:  ... FOR..NEXT loops aren't admisible after either THEN or ELSE.

Aha! Quite right. I had forgotten about that. Thanks, Valentin!

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
12-19-2019, 02:39 PM (This post was last modified: 12-19-2019 02:40 PM by smp.)
Post: #5
RE: (71B) The Devil's Dungeon game
Thanks very much for your comments, Valentin and Joe.
Indeed, you are both correct.
The original code made use of the condition being tested to execute or ignore the rest of the line, containing a for-next loop, as Valentin surmised.

smp
Find all posts by this user
Quote this message in a reply
12-20-2019, 04:18 PM (This post was last modified: 12-20-2019 04:21 PM by SlideRule.)
Post: #6
RE: (71B) The Devil's Dungeon game
Excerpt from The Devil's Dungeon

The Legend
… rumors of large quantities of gold hidden in a maze of caves … connecting passageways … monsters and demons … poisonous gas, tremors … the caves The Devil 's Dungeon …
The Dungeon
… gold … the stories … are true … sixteen rooms on each level of the dungeon … may be blocked by rockfalls … number of levels is unknown …
Rooms and Passageways
You will begin your adventure in Room #1 at Depth #1. The contents of the room you occupy and the numbers of the adjacent rooms will be listed. You may move to an adjacent room by entering one of the adjacent room numbers. If the output reads: MOVE FROM 2 TO?, all adjacent rooms on your present level are blocked. If a "slide" to a room is indicated, you may use it by entering that room number; however, it is a one-way passage and cannot be used to return to the first room … a list of the rooms … visited and their respective adjacent rooms … enter an 88.
Descending into the Dungeon
Movement to a lower depth … achieved by using a dropoff … to drop … enter any negative number when you are in one of these rooms. You will then find yourself in the same room on the next lower level … Once you have left a given depth, you can never return … you cannot move up.
A dropoff … created … Magic Wand … with you at all times … use … is very risky
… 40% … backfires … strength and speed are reduced by 50% … when … wand is …
only alternative … enter 99 … if the wand works … clear out everything in the room … create a dropoff … if the wand backfires … remain in place with 50% … strength and speed … Magic Wand can be used repeatedly in every room except Room #1. If you enter a 99 while in Room #1, the simulation will terminate
Tremors
… when a tremor occurs … some passageways may be blocked … others may be opened. To determine the effect … enter an 88 … get a listing of open adjacent rooms to the rooms you have visited …
Room #1
Room #1 is very important on every level. It i s the only room from which you may leave the dungeon by entering a 99. Room #1 is the only place at which you can increase your strength and speed. There are no hazards in this room. When you drop to a lower level , you will want to locate Room #1 as soon as possible.
Speed and Strength
… two qualities that must be maintained … to survive … both … needed to kill …speed alone … needed to run … monster … poisonous gas affects your strength … begin your journey with 100 units … speed and strength. Each time you move to another room … strength and speed decrease by your depth … any time … strength or speed … zero or less … declared dead …
Experience
… begin with zero experience points. Everytime you move, your experience points are increased by your depth level number … acquire up to … twice a monster's strength … by killing the monster … One point … every piece of gold found … can be traded for strength and speed, one for one … entering a zero while in Room #1 … be asked how many points … added …
Monsters
… monster … present … speed and strength … listed immediately after your speed and strength … elect to fight … enter a zero … monsters are faster and stronger
in rooms with larger numbers and … at lower depths … If a monster hits you on your way out of the room, you will lose 20% of the monster's strength. The monster cannot hit you if you use a dropoff or the Magic Wand in its room…
Demons and Poisonous Gas
… 25% of the rooms on each level have demons and about 25% of the
rooms have poisonous gas … Neither … can be eliminated … you can escape from them … are always in these rooms … should be avoided when possible … room with … 40% chance … cursed or gassed … if cursed … lose one-half … strength … escape
… by moving to a lower level …
Gold
… maximum amount … of gold … stated when you enter … directly related to the room number and depth … amount of gold … actually find … given when … leave the room … a percentage of the maximum, randomly determined … cannot take gold from a room unless you move to another room on the same level . Once you l eave a room carrying gold, the gold is yours for the rest of the journey. Sometimes demons in the room with the gold will steal it as you leave. But whether you leave the room with the gold or demons steal it, when you return to that room, there will no longer be any gold there. You can take gold from a room only one time. If a monster is present in a room containing gold, you must kill the monster before you can take the gold. If you leave the room without killing the monster, the gold and the monster will remain in the room and be there when you return …

BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
12-20-2019, 09:07 PM
Post: #7
RE: (71B) The Devil's Dungeon game
I have the Vic-20 version of this book. I should type in some of the programs, and see if any would be worth converting to the Casio fx-730P (now that I actually have a cassette recorder that works with it).
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)