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
Post Reply 


Messages In This Thread
(71B) The Devil's Dungeon game - smp - 12-18-2019 08:12 PM
RE: (71B) The Devil's Dungeon game - smp - 12-19-2019, 02:39 PM



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