Author Topic: MAZE for the DTSS BASIC  (Read 1383 times)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4185
    • View Profile
    • Portfolio
MAZE for the DTSS BASIC
« on: 2017-May-05 »
Here the news and code:
http://www.vintageisthenewold.com/the-maze-a-program-for-the-dtss-basic-simulator/#comment-5756

I gave a quick shot on trying to convert it to GLBasic with the idea of advance it a bit just for fun.
Bad move, the code is a bit complex for me so I gave up on this little giggle as it would take too long and specially because I already have another project on that line.

But if anyone would like to try, here is the original listing:
Code: GLBasic [Select]
10 LET N1=30
20 GOSUB 4100
30 GOSUB 6200
40 GOSUB 6600
110 GOSUB 1000
120 REM ASSIGN LOCKS AND KEYS
130 GOSUB 1300
139 REM TO DUMP MAZE ON SCREEN: FOR DEBUGGING AND CHEATING ONLY.
140 REM GOSUB 6000
150 REM START AT NODE 1
160 LET X=1
170 REM GET NEXT NODE
180 GOSUB 4200
190 IF X<>0 THEN 220
200 PRINT “MAZE DISSOLVED, THANK YOU FOR PLAYING”
210 STOP
220 IF X=N1 THEN 230
225 GOTO 180
230 PRINT***************************
240 PRINT “CONGRATULATIONS, YOU ARE OUT OF THE MAZE!
250 STOP
1000 LET I1 = 2
1005 FOR I0=1 TO N1
1010 LET I3=1
1020 IF I0>1 THEN 1050
1030 LET N2 = INT(RND(0)*2)+2
1040 GOTO 1060
1050 LET N2 = INT(RND(0)*3)+1
1060 IF I1+N2-1 <=N1 THEN 1080
1070 LET N2=0
1080 GOSUB 4000
1090 IF I2 = 0 THEN 1120
1100 LET M(I0,I3) = I2
1110 LET I3 = I3 + 1
1120 IF I1 > N1 THEN 1180
1130 FOR J = 1 TO N2
1140 LET M(I0,I3) = I1
1150 LET I1 = I1 + 1
1160 LET I3 = I3 + 1
1170 NEXT J
1180 GOSUB 5000
1200 NEXT I0
1210 RETURN
1300 FOR L0= 1 TO 3
1310 LET K0 = INT(RND(0)*28) + 2
1320 IF M(K0,5)<>0 THEN 1310
1329 REM FOLLOWING CODE INHIBITS LOCKING END NODES
1330 REM FOR L1=1 TO 4
1340 REM IF M(K0,L1)=0 THEN 1360
1350 REM LET K1=K1+1
1360 REM NEXT L1
1370 REM IF K1=1 THEN 1310
1380 LET M(K0,5) = INT(RND(0)*98)+1
1390 NEXT L0
1400 FOR L0=1 TO 30
1410 IF M(L0,5)=0 THEN 1540
1420 LET K0 = INT(RND(0)*29) + 1
1425 IF K0=L0 THEN 1420
1430 IF M(K0,6)<>0 THEN 1420
1440 LET K3=K0
1450 LET K2=0
1460 LET K2=K2+1
1470 IF K2>4 THEN 1530
1480 IF M(K3,K2)=0 THEN 1460
1490 IF M(K3,K2)>K3 THEN 1460
1500 IF M(K3,K2)=L0 THEN 1420
1510 LET K3=M(K3,K2)
1520 GOTO 1450
1530 LET M(K0,6) = L0*100 + M(L0,5)
1540 NEXT L0
1550 RETURN
4000 LET I2=0
4010 FOR L0= 1 TO I0-1
4020 FOR L1=1 TO 4
4030 IF M(L0,L1)=I0 THEN 4070
4040 NEXT L1
4050 NEXT L0
4060 GOTO 4080
4070 LET I2=L0
4075 REM PRINT I2
4080 RETURN
4100 DIM M(30,6)
4110 FOR A0=1 TO N1
4120 FOR A1=1 TO 6
4130 LET M(A0,A1) = 0
4140 NEXT A1
4150 NEXT A0
4160 RETURN
4200 PRINT*******************************************
4205 PRINT “YOU ARE IN A ROOM LABELED “;X
4210 PRINT
4212 IF M(X,6)=0 THEN 4220
4216 PRINT “THERE IS A KEY HERE CRYPTICALLY LABELED *;INT(M(X,6)/100);**;
4217 PRINT M(X,6)-INT(M(X,6)/100)*100;*
4218 PRINT
4220 PRINT “ENTER A NUMBER DEPENDING ON WHERE YOU WANT TO GO:
4230 PRINT
4235 PRINT0    HYPER JUMP”
4240 LET A1 = 0
4250 FOR A0=1 TO 4
4260 IF M(X,A0)=0 THEN 4290
4270 LET A1 = A1 + 1
4280 PRINT A1;”CORRIDOR “;A1
4290 NEXT A0
4300 PRINT5    EXIT”
4310 PRINT
4315 REM PRINT”A1 IS “;A1
4320 PRINTSELECT A NUMBER”;
4330 INPUT X0
4335 IF X0<>5 THEN 4340
4337 LET X=0
4338 RETURN
4340 IF X0<=A1 THEN 4350
4345 GOTO 4360
4350 IF X0>=0 THEN 4380
4360 PRINT “BAD CHOICE”
4370 GOTO 4310
4380 IF X0>0 THEN 4410
4385 LET X1 = X
4390 LET X = INT(RND(0)*29 + 1)
4395 IF M(X,5)<>0 THEN 4390
4397 IF X = X1 THEN 4390
4400 RETURN
4410 LET A1=1
4420 FOR A0=1 TO 4
4430 IF M(X,A0)=0 THEN 4470
4440 IF X0<>A1 THEN 4460
4450 GOSUB 5100
4460 LET A1=A1+1
4470 NEXT A0
4480 RETURN
5000 FOR M0= 4 TO 1 STEP -1
5010 LET M1=INT(RND(0)*M0+1)
5020 LET M2 = M(I0,M1)
5030 LET M(I0,M1)=M(I0,M0)
5040 LET M(I0,M0)=M2
5045 NEXT M0
5050 RETURN
5100 IF M(M(X,A0),5)<>0 THEN 5130
5110 LET X = M(X,A0)
5120 RETURN
5130 PRINT “ROOM”;M(X,A0);”IS LOCKED, WHAT IS THE KEY (NUMBERS ONLY);
5140 INPUT K0
5150 IF K0=M(M(X,A0),5) THEN 5110
5160 PRINT “WRONG KEY
5170 RETURN
6000 FOR K= 1 TO N1
6010 PRINT K;M(K,1);M(K,2);M(K,3);M(K,4);M(K,5);M(K,6)
6020 NEXT K
6030 RETURN
6200 PRINT ”        ***                **          **           **
6210 PRINT ”        **                  **          **           **        ”
6220 PRINT ”       **         *          **          **           **       ”
6230 PRINT ”      **         ***          **         ***           **      ”
6240 PRINT ”     **         ** **                   ** **           ***    ”
6250 PRINT ”    **         **   **                 ***  **           **    ”
6260 PRINT ”   **         **     **               ***    **           ***  ”
6270 PRINT ”  **          *       *               **      **           ***
6280 PRINT**         **         **            **        **           ***
6290 PRINT**         **           **          ***         **           **
6300 PRINT*         **WELCOME TO THE*        ** **                    **
6310 PRINT ”         **                       **                       **  ”
6320 PRINT ”        ** ****   ****     ****  ***********  ********    **   ”
6330 PRINT ”       ** *****  *****    ***** ** *****************   **    ”
6340 PRINT ”      **  **;**  ****’   ‘*******      ****  ***        **     ”
6350 PRINT ”     **   **;** ** **    **:****      ****   ***       **      ”
6360 PRINT ”    **   ***I*+** ***   *** ***      ****   I******** **       ”
6370 PRINT ”   **    ** **.** **   ***  ***    ****     ******** **        ”
6380 PRINT ”  ***   ‘** *****;**   ********   ****      ***     **         ”
6390 PRINT ”  **    *** **** ***  *********  ****      ‘****   **’         ”
6400 PRINT**     *** ***  **I ********** ********** *********           ”
6410 PRINT**      **  ***** ****   *** *********  ********.         **
6420 PRINT*                              2015 SALVADOR GARCIA         **
6430 PRINT ”           **            **        ***                     **  ”
6440 PRINT ”          **              **      **                      **   ”
6450 PRINT ”         **                **    **                      **    ”
6460 PRINT ”        **                  **  **                      **     ”
6470 PRINT ”       **          **        ****  ENTER AND ABANDON ALL HOPE  ”
6480 PRINT ”      **          **          **          **          **       ”
6490 RETURN
6600 PRINTSELECT A RANDOM SEED NUMBER 11000;
6610 INPUT I0
6620 IF I0>0 THEN 6630
6624 GOTO 6640
6630 IF I0<=1000 THEN 6660
6640 PRINT “BAD CHOICE”
6650 GOTO 6600
6660 FOR I= 1 TO I0
6670 LET I1 = RND(0)
6680 NEXT I
6690 RETURN
8000 END

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1456
    • View Profile
Re: MAZE for the DTSS BASIC
« Reply #1 on: 2017-May-05 »
Coverting to ZX Spectum easily - but seems a bit random - just jumping to empty locations...not sure what is supposed to happen and also could only use seed of 1 to 30 as the DIM limits this.

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4185
    • View Profile
    • Portfolio
Re: MAZE for the DTSS BASIC
« Reply #2 on: 2017-May-05 »
The instructions on the link is a bit off (at least to me) and I haven´t run it on emulators yet.
The code seems very attached to line jumping, I found it a bit hard to understand.