• Please review our updated Terms and Rules here

Maze Code Problem 2.0

Mister_Alex

Experienced Member
Joined
Sep 1, 2011
Messages
58
Sorry it took so long to get back to everyone. Here's the code I am currently using for that random maze generator:

5 text : home
10 print "Amazing Program"
20 print "Creative Computing"
30 print : print : print : print
100 input "WHAT ARE YOUR DIMENSIONS?";h,v
102 if h<>1 and v<>1 then 110
104 print "MEANINGLESS. TRY AGAIN" : goto 100
110 dim w(h,v) : dim p(h,v)
120 print
130 print
140 print
150 print
160 x=0 : z=0 : x=int(rnd(1)*h+1)
165 for i=1 to h
170 if i=x then 173
171 print ".--"; : goto 180
173 print ". ";
180 next i
190 print "."
195 c=1 : w(x,1)=c : c=c+1
200 r=x : s=1 : goto 260
210 if r<>h then 260
215 if s<>v then 230
220 r=1 : s=1 : goto 250
230 r=1 : s=s+1 : goto 250
240 r=r+1
250 if w(r-1,s)<>0 then 210
260 if r-1=0 then 530
265 if w(r-1,s)<>0 then 530
270 if s-1=0 then 390
280 if w(r,s-1)<>0 then 390
290 if r=h then 330
300 if w(r+1,s)<>0 then 330
310 if r=h then 350
320 if w(r+1,s)<>0 then 350
330 x=rnd(3)
340 on x goto 940,980,1020
350 if s<>v then 380
360 if z=1 then 410
370 q=1 : goto 390
380 if w(r,s+1)<>0 then 410
390 x=rnd(3)
400 on x goto 940,980,1090
410 x=rnd(2)
420 on x goto 940,980
430 if r=h then 530
440 if w(r+1,s)<>0 then 530
450 if s<>v then 480
460 if z=1 then 510
470 q=1 : goto 490
480 if w(r,s+1)<>0 then 510
490 x=rnd(3)
500 on x goto 940,1020,1090
510 x=rnd(2)
520 on x goto 940,1020
530 if s<>v then 560
540 if z=1 then 590
550 q=1 : goto 570
560 if w(r,s+1)<>0 then 590
570 x=int(rnd(0)*2+1)
580 on x goto 940,1090
590 goto 940
600 if s-1=0 then 790
610 if w(r,s-1)<>0 then 790
620 if r=h then 720
630 if w(r+1,s)<>0 then 720
640 if s<>v then 670
650 if z=1 then 700
660 q=1 : goto 680
670 if w(r,s+1)<>0 then 700
680 x=rnd(3)
690 on x goto 900,1020,1090
700 x=rnd(2)
710 on x goto 980,1020,1090
720 x=rnd(2)
730 if z=1 then 780
740 q=1 : goto 760
750 if w(r,s+1)<>0 then 780
760 x=rnd(2)
770 on x goto 980,1090
780 goto 980
790 if r=h then 800
800 if w(r+1,s)<>0 then 880
810 if s<>v then 840
820 if z=1 then 870
830 q=1 : goto 990
840 if w(r,s+1)<>0 then 870
850 x=rnd(2)
860 on x goto 1020,1090
870 goto 1020
880 if s<>v then 910
890 if z=1 then 930
900 q=1 : goto 920
910 if w(r,s+1)<>0 then 930
920 goto 1090
930 goto 1190
940 w(r-1,s)=c
950 c=c+1 : p(r-1,5)=2 : r=r-1
960 if c=h*v+1 then 1280
970 q=0 : goto 270
980 w(r,s-1)=c
990 c=c+1
1000 p(r,s-1)=1 : s=s-1 : if c=h*v+1 then 1200
1010 q=0 : goto 270
1020 w(r+1,s)=c
1030 c=c+1 : if p(r,s)=0 then 1050
1040 p(r,s)=3 : goto 1060
1050 p(r,s)=2
1060 r=r+1
1070 if c=h*v+1 then 1200
1080 goto 600
1090 if q=1 then 1150
1100 w(r,s+1)=c : c=c+1 : if p(r,s)=0 then 1120
1120 p(r,s)=1
1130 s=s+1 : if c=v*h+1 then 1200
1140 goto 270
1150 z=1
1160 if p(r,s)=0 then 1180
1170 p(r,s)=3 : q=0 : goto 1190
1180 p(r,s)=1 : q=0 : r=1 : s=1 : goto 260
1190 goto 210
1200 for j=1 to v
1210 print "i";
1220 for I=1 to h
1230 if p(i,j)<2 then 1260
1240 print " ";
1250 goto 1270
1260 print " I";
1270 next I
1280 print " "
1290 for I=1 to h
1300 if p(i,j)=0 then 1340
1310 if v(i,j)=2 then 1340
1320 print ": ";
1330 goto 1350
1340 print ";--";
1350 next I
1360 print ";"
1370 next j
1380 end

It prints the first row flawlessly, but after that it returns an illegal quantity in line 940. Did I make a typo or something?
 
Did I make a typo or something?
Probably. But if you're using that Applesoft emulator, it's going to be hard to debug.

For example on an actual machine, when the program stops, all the values are still in memory.
So you could PRINT R or PRINT S to try to figure out what's wrong.
There's also a command to let you trace the program flow -- but probably not in that emulator.

Let me ask you this -- are you typing the program in exactly or are you changing things?
The reason I ask is because I see lines the look like X=RND(3)
I don't think that does what you think it does.
It's certainly different than what I see in the listing I have.
 
I'm doing the best I can. All the scans I find are blurry, even when enlarged, so it's hard to see precisely what I should be typing.

I revised some of it, and now it works for only a maze with dimensions 5x5

10 home: PRINT "AMAZING"
20 PRINT "COPYRIGHT BY"
30 PRINT "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
40 FOR II=1 TO 1500: NEXT
50 home: INPUT"WHAT ARE YOUR WIDTH AND LENGTH"; H,V
60 IF H<>1 AND V<>1 THEN 90
70 PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN"
80 FOR A=1 TO 500: NEXT A: GOTO 50
90 PRINT "PRINTOUT IS IN PROGRESS, PLEASE BE PATIENT"
100 FOR II=1 TO 1500: NEXT
110 DIM W(H,V), V(H,V)
120 Q=0: Z=0: X=int(rnd(1)*h+1)
130 FOR I=1 TO H
140 IF I=X THEN 160
150 PRINT ":--";: GOTO 170
160 PRINT ": ";
170 NEXT I
180 PRINT ":"
190 C=1: W(X,1)=C: C=C+1
200 R=X: S=1: GOTO 270
210 IF R<>H THEN 250
220 IF S<>V THEN 240
230 R=1: S=1: GOTO 260
240 R=1: S=S+1: GOTO 260
250 R=R+1
260 IF W(R,S)=0 THEN 210
270 IF R-1=0 THEN 600
280 if r>1 and s>1 then IF W(R-1,S)<>0 THEN 600
290 IF S-1=0 THEN 430
300 IF W(R,S-1)<>0 THEN 430
310 IF R=H THEN 350
320 IF W(R+1,S)<>0 THEN 350
330 X=int(rnd(1)*3+1)
340 ON X GOTO 940,980,1020
350 IF S<>V THEN 380
360 IF Z=1 THEN 410
370 Q=1: GOTO 390
380 IF W(R,S+1)<>0 THEN 410
390 X=int(rnd(1)*2+1)
400 ON X GOTO 940,980,1090
410 X=int(rnd(1)*3+1)
420 ON X GOTO 940,980
430 IF R=H THEN 530
440 if r>1 and s>1 then IF W(R+1,S)<>0 THEN 530
450 IF S<>V THEN 480
460 IF Z=1 THEN 510
470 Q=1: GOTO 490
480 if r>1 and s>1 then IF W(R,S+1)<>0 THEN 510
490 X=int(RND(1)*3+1)
500 ON X GOTO 940,1020,1090
510 X=int(RND(1)*2+1)
520 ON X GOTO 940,1020
530 IF S<>V THEN 560
540 IF Z=1 THEN 590
550 Q=1: GOTO 570
560 if r>1 and s>1 then IF W(R,S+1)<>0 THEN 590
570 X=INT(RND(0)*2+1)
580 ON X GOTO 940,1090
590 GOTO 940
600 IF S-1=0 THEN 790
610 IF W(R,S-1)<>0 THEN 790
620 IF R=H THEN 720
630 IF W(R+1,S)<>0 THEN 720
640 IF S<>V THEN 670
650 IF Z=1 THEN 700
660 Q=1: GOTO 680
670 IF W(R,S+1)<>0 THEN 700
680 X=int(RND(1)*3+1)
690 ON X GOTO 980,1020,1090
700 X=int(rnd(1)*2+1)
710 ON X GOTO 980,1020
720 IF S<>V THEN 750
730 IF Z=1 THEN 780
740 Q=1: GOTO 760
750 IF W(R,S+1)<>0 THEN 780
760 X=int(RND(1)*2+1)
770 ON X GOTO 980,1090
780 GOTO 980
790 IF R=H THEN 880
800 IF W(R+1,S)<>0 THEN 880
810 IF S<>V THEN 840
820 IF Z=1 THEN 870
830 Q=1: GOTO 990
840 IF W(R,S+1)<>0 THEN 870
850 X=int(RND(1)*2)+1
860 ON X GOTO 1020,1090
870 GOTO 1020
880 IF S<>V THEN 910
890 IF Z=1 THEN 930
900 Q=1: GOTO 920
910 IF W(R,S+1)<>0 THEN 930
920 GOTO 1090
930 GOTO 1190
940 if r>1 and s>0 then W(R-1,S)=C
950 C=C+1
955 if r>1 and s>0 then v(r-1,s)=2
956 r=r-1
960 IF C=H*V+1 THEN 1200
970 Q=0: GOTO 270
980 W(R,S-1)=C
990 C=C+1
1000 V(R,S-1)=1: S=S-1: IF C=H*V+1 THEN 1200
1010 Q=0: GOTO 270
1020 W(R+1,S)=C
1030 C=C+1: IF V(R,S)=0 THEN 1050
1040 V(R,S)=3: GOTO 1060
1050 V(R,S)=2
1060 R=R+1
1070 IF C=H*V+1 THEN 1200
1080 GOTO 600
1090 IF Q=1 THEN 1150
1100 W(R,S+1)=C: C=C+1:IF V(R,S)=0 THEN 1120
1110 V(R,S)=3: GOTO 1130
1120 V(R,S)=1
1130 S=S+1: IF C=V*H+1 THEN 1200
1140 GOTO 270
1150 Z=1
1160 IF V(R,S)=0 THEN 1180
1170 V(R,S)=3: Q=0: GOTO 1190
1180 V(R,S)=1: Q=0: R=1: S=1: GOTO 260
1190 GOTO 210
1200 FOR J=1 TO V
1210 PRINT "I";
1220 FOR I=1 TO H
1230 IF V(I,J)<2 THEN 1260
1240 PRINT " ";
1250 GOTO 1270
1260 PRINT " I";
1270 NEXT I
1280 PRINT " "
1290 FOR I=1 TO H
1300 IF V(I,J)=0 THEN 1340
1310 IF V(I,J)=2 THEN 1340
1320 PRINT ": ";
1330 GOTO 1350
1340 PRINT ":--";
1350 NEXT I
1360 PRINT ":"
1370 NEXT J
1380 END
 
Last edited:
I have that book somewhere, I'll go digging for it -- I think some of the problem is a lot of your V's should be Y's, and a lot of your zero's should be Q's. The reason I'm thinking that is I'm seeing Q set, but not doing anything.
 
Here it is as it appears in my copy of "the yellow book", tested in GWBASIC as working.

Code:
10 PRINT TAB(28);"AMAZING PROGRAM"
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT:PRINT
100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH";H,Y
102 IF H<>1 AND Y<>1 THEN 110
104 PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN.":GOTO 100
110 DIM W(H,Y),V(H,Y)
120 PRINT
130 PRINT
140 PRINT
150 PRINT
160 Q=0:Z=0:X=INT(RND(1)*H+1)
165 FOR I=1 TO H
170 IF I=X THEN 173
171 PRINT ".--";:GOTO 180
173 PRINT ".  ";
180 NEXT I
190 PRINT "."
195 C=1:W(X,1)=C:C=C+1
200 R=X:S=1:GOTO 260
210 IF R<>H THEN 240
215 IF S<>Y THEN 230
220 R=1:S=1:GOTO 250
230 R=1:S=S+1:GOTO 250
240 R=R+1
250 IF W(R,S)=0 THEN 210
260 IF R-1=0 THEN 530
265 IF W(R-1,S)<>0 THEN 530
270 IF S-1=0 THEN 390
280 IF W(R,S-1)<>0 THEN 390
290 IF R=H THEN 330
300 IF W(R+1,S)<>0 THEN 330
310 X=INT(RND(1)*3+1)
320 ON X GOTO 790,820,860
330 IF S<>Y THEN 340
334 IF Z=1 THEN 370
338 Q=1:GOTO 350
340 IF W(R,S+1)<>0 THEN 370
350 X=INT(RND(1)*3+1)
360 ON X GOTO 790,820,910
370 X=INT(RND(1)*2+1)
380 ON X GOTO 790,820
390 IF R=H THEN 470
400 IF W(R+1,S)<>0 THEN 470
405 IF S<>Y THEN 420
410 IF Z=1 THEN 450
415 Q=1:GOTO 430
420 IF W(R,S+1)<>0 THEN 450
430 X=INT(RND(1)*3+1)
440 ON X GOTO 790,860,910
450 X=INT(RND(1)*2+1)
460 ON X GOTO 790,860
470 IF S<>Y THEN 490
480 IF Z=1 THEN 520
485 Q=1:GOTO 500
490 IF W(R,S+1)<>0 THEN 520
500 X=INT(RND(1)*2+1)
510 ON X GOTO 790,910
520 GOTO 790
530 IF S-1=0 THEN 670
540 IF W(R,S-1)<>0 THEN 670
545 IF R=H THEN 610
547 IF W(R+1,S)<>0 THEN 610
550 IF S<>Y THEN 560
552 IF Z=1 THEN 590
554 Q=1:GOTO 570
560 IF W(R,S+1)<>0 THEN 590
570 X=INT(RND(1)*3)+1
580 ON X GOTO 820,860,910
590 X=INT(RND(1)*2)+1
600 ON X GOTO 820,860
610 IF S<>Y THEN 630
620 IF Z=1 THEN 660
625 Q=1:GOTO 640
630 IF W(R,S+1)<>0 THEN 660
640 X=INT(RND(1)*2+1)
650 ON X GOTO 820,910
660 GOTO 820
670 IF R=H THEN 740
680 IF W(R+1,S)<>0 THEN 740
685 IF S<>Y THEN 700
690 IF Z=1 THEN 730
695 Q=1:GOTO 830
700 IF W(R,S+1)<>0 THEN 730
710 X=INT(RND(1)*2)+1
720 ON X GOTO 860,910
730 GOTO 860
740 IF S<>Y THEN 760
750 IF Z=1 THEN 780
755 Q=1:GOTO 770
760 IF W(R,S+1)<>0 THEN 780
770 GOTO 910
780 GOTO 1000
790 W(R-1,S)=C
800 C=C+1:V(R-1,S)=2:R=R-1
810 IF C=H*Y+1 THEN 1010
815 Q=0:GOTO 260
820 W(R,S-1)=C
830 C=C+1
840 V(R,S-1)=1:S=S-1:IF C=H*Y+1 THEN 1010
850 Q=0:GOTO 260
860 W(R+1,S)=C
870 C=C+1:IF V(R,S)=0 THEN 880
875 V(R,S)=3:GOTO 890
880 V(R,S)=2
890 R=R+1
900 IF C=H*Y+1 THEN 1010
905 GOTO 530
910 IF Q=1 THEN 960
915 IF S=Y THEN 930
920 W(R,S+1)=C:C=C+1:IF V(R,S)=0 THEN 940
930 V(R,S)=3:GOTO 950
940 V(R,S)=1
950 S=S+1:IF C=H*Y+1 THEN 1010
955 GOTO 260
960 Z=1
970 IF V(R,S)=0 THEN 980
975 V(R,S)=3:Q=0:GOTO 1000
980 V(R,S)=1:Q=0:R=1:S=1:GOTO 250
1000 GOTO 210
1010 FOR J=1 TO Y
1011 PRINT "I";
1012 FOR I=1 TO H
1013 IF V(I,J)<2 THEN 1030
1020 PRINT "   ";
1021 GOTO 1040
1030 PRINT "  I";
1040 NEXT I
1041 PRINT
1043 FOR I=1 TO H
1045 IF V(I,J)=0 THEN 1060
1050 IF V(I,J)=2 THEN 1060
1051 PRINT ":  ";
1052 GOTO 1070
1060 PRINT ":--";
1070 NEXT I
1071 PRINT "."
1072 NEXT J
1073 END

Gah, that's some fugly spaghetti... but of course basic == spaghetti code by definition. The print from most of creative computings source codes always sucked because their Y and V are nearly indistinguishable from each-other. Should work fine in Applesoft Basic too, though I'd switch the first few lines to:

Code:
5 TEXT:HOME
10 PRINT TAB(11);"AMAZING PROGRAM"
20 PRINT TAB(10);"CREATIVE COMPUTING"
25 PRINT TAB(8);"MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT
100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH? ";H,Y

Mind you, if you delcare a total height greater than ten cells, you'll probably get an out of range error in Applesoft basic -- I remember that about this program in particular, though damned if I remember what caused it.

-- EDIT -- actually, I think there's a flaw in it's range checking math. Sometimes it throws range errors, sometimes it doesn't... I'm double checking I typed it in right, but I think the flaw lies in the original code.... oops, typo line 360, should be 790 not 720.

-- edit edit -- and another typo fixed... Ok, that should work fine now.
 
Last edited:
Just tested this on my IIE platinum, works fine.

Code:
5 TEXT:HOME
10 PRINT TAB(11);"AMAZING PROGRAM"
20 PRINT TAB(10);"CREATIVE COMPUTING"
25 PRINT TAB(8);"MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT
100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH? ";H,Y
102 IF H<>1 AND Y<>1 THEN 110
104 PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN.":GOTO 100
110 DIM W(H,Y),V(H,Y)
120 PRINT
130 PRINT
140 PRINT
150 PRINT
160 Q=0:Z=0:X=INT(RND(1)*H+1)
165 FOR I=1 TO H
170 IF I=X THEN 173
171 PRINT "+--";:GOTO 180
173 PRINT "+  ";
180 NEXT I
190 PRINT "+"
195 C=1:W(X,1)=C:C=C+1
200 R=X:S=1:GOTO 260
210 IF R<>H THEN 240
215 IF S<>Y THEN 230
220 R=1:S=1:GOTO 250
230 R=1:S=S+1:GOTO 250
240 R=R+1
250 IF W(R,S)=0 THEN 210
260 IF R-1=0 THEN 530
265 IF W(R-1,S)<>0 THEN 530
270 IF S-1=0 THEN 390
280 IF W(R,S-1)<>0 THEN 390
290 IF R=H THEN 330
300 IF W(R+1,S)<>0 THEN 330
310 X=INT(RND(1)*3+1)
320 ON X GOTO 790,820,860
330 IF S<>Y THEN 340
334 IF Z=1 THEN 370
338 Q=1:GOTO 350
340 IF W(R,S+1)<>0 THEN 370
350 X=INT(RND(1)*3+1)
360 ON X GOTO 790,820,910
370 X=INT(RND(1)*2+1)
380 ON X GOTO 790,820
390 IF R=H THEN 470
400 IF W(R+1,S)<>0 THEN 470
405 IF S<>Y THEN 420
410 IF Z=1 THEN 450
415 Q=1:GOTO 430
420 IF W(R,S+1)<>0 THEN 450
430 X=INT(RND(1)*3+1)
440 ON X GOTO 790,860,910
450 X=INT(RND(1)*2+1)
460 ON X GOTO 790,860
470 IF S<>Y THEN 490
480 IF Z=1 THEN 520
485 Q=1:GOTO 500
490 IF W(R,S+1)<>0 THEN 520
500 X=INT(RND(1)*2+1)
510 ON X GOTO 790,910
520 GOTO 790
530 IF S-1=0 THEN 670
540 IF W(R,S-1)<>0 THEN 670
545 IF R=H THEN 610
547 IF W(R+1,S)<>0 THEN 610
550 IF S<>Y THEN 560
552 IF Z=1 THEN 590
554 Q=1:GOTO 570
560 IF W(R,S+1)<>0 THEN 590
570 X=INT(RND(1)*3)+1
580 ON X GOTO 820,860,910
590 X=INT(RND(1)*2)+1
600 ON X GOTO 820,860
610 IF S<>Y THEN 630
620 IF Z=1 THEN 660
625 Q=1:GOTO 640
630 IF W(R,S+1)<>0 THEN 660
640 X=INT(RND(1)*2+1)
650 ON X GOTO 820,910
660 GOTO 820
670 IF R=H THEN 740
680 IF W(R+1,S)<>0 THEN 740
685 IF S<>Y THEN 700
690 IF Z=1 THEN 730
695 Q=1:GOTO 830
700 IF W(R,S+1)<>0 THEN 730
710 X=INT(RND(1)*2)+1
720 ON X GOTO 860,910
730 GOTO 860
740 IF S<>Y THEN 760
750 IF Z=1 THEN 780
755 Q=1:GOTO 770
760 IF W(R,S+1)<>0 THEN 780
770 GOTO 910
780 GOTO 1000
790 W(R-1,S)=C
800 C=C+1:V(R-1,S)=2:R=R-1
810 IF C=H*Y+1 THEN 1010
815 Q=0:GOTO 260
820 W(R,S-1)=C
830 C=C+1
840 V(R,S-1)=1:S=S-1:IF C=H*Y+1 THEN 1010
850 Q=0:GOTO 260
860 W(R+1,S)=C
870 C=C+1:IF V(R,S)=0 THEN 880
875 V(R,S)=3:GOTO 890
880 V(R,S)=2
890 R=R+1
900 IF C=H*Y+1 THEN 1010
905 GOTO 530
910 IF Q=1 THEN 960
915 IF S=Y THEN 930
920 W(R,S+1)=C:C=C+1:IF V(R,S)=0 THEN 940
930 V(R,S)=3:GOTO 950
940 V(R,S)=1
950 S=S+1:IF C=H*Y+1 THEN 1010
955 GOTO 260
960 Z=1
970 IF V(R,S)=0 THEN 980
975 V(R,S)=3:Q=0:GOTO 1000
980 V(R,S)=1:Q=0:R=1:S=1:GOTO 250
1000 GOTO 210
1010 FOR J=1 TO Y
1011 PRINT "|";
1012 FOR I=1 TO H
1013 IF V(I,J)<2 THEN 1030
1020 PRINT "   ";
1021 GOTO 1040
1030 PRINT "  |";
1040 NEXT I
1041 PRINT
1043 FOR I=1 TO H
1045 IF V(I,J)=0 THEN 1060
1050 IF V(I,J)=2 THEN 1060
1051 PRINT "+  ";
1052 GOTO 1070
1060 PRINT "+--";
1070 NEXT I
1071 PRINT "+"
1072 NEXT J
1073 END

So there's your baseline. Those pesky V's that should be V's with V's that should be Y's can drive you nuts on CC's printouts. Well, that and they never heard of OR.
 
While I never tried Applesoft Basic, does it really have a limit on two dimensional arrays to 10x10 elements? Most other Basic dialects, at least the Microsoft derived ones usually only limit it to amount of available memory. If the dialect allows it, you could try to replace all V and W with V% and W% for integer values. Those usually are restricted to -32768 .. +32767 but in some implementations take far less memory than the regular floating point variables do.
 
While I never tried Applesoft Basic, does it really have a limit on two dimensional arrays to 10x10 elements? Most other Basic dialects, at least the Microsoft derived ones usually only limit it to amount of available memory. If the dialect allows it, you could try to replace all V and W with V% and W% for integer values. Those usually are restricted to -32768 .. +32767 but in some implementations take far less memory than the regular floating point variables do.

It ALLEGEDLY supports higher, but when you use more than 127 total elements it can... well... for some reason sometimes it works, sometimes it gives you an out of range error. I've never been able to nail down the how/why/when/where of it though. Literally sometimes you can do 255x64 and it will work just fine, other times you'll go to access [x,63] and it will claim out of range when it obviously isn't. Don't ask me -- it's just what I've seen it do.

Though the lack of proper range checking in this BASIC program doesn't help...

That last version I posted works fine on my IIE platinum right up to 8K elements (though the output is useless) -- since it's using two arrays of the same size that's 16k, which is basically all the available variable space on a 64k machine by the time ROM and other system stuff is in the way.

This was kinda fun BTW - I've not looked at BASIC for about 25 years...
 
Last edited:
Thank you VERY much, deathshadow. Earlier I was able to tweak my own code to finally generate a maze, but was concerned I made an error in that it creates the same maze for each dimension. Your example showed me that it truly isn't random. :)

Now all that needs to be done is to convert it into lo-res graphics mode. It should make that maze game demo of mine more playable-and hopefully more educational. :)

I'll try every possible coding angle before I ask help again. As a veteran coder I should be able to handle these things on my own. . .
 
Alex, I was going to suggest you get yourself a more functional emulator like AppleWin, so you can do some debugging.
 
Thank you VERY much, deathshadow. Earlier I was able to tweak my own code to finally generate a maze, but was concerned I made an error in that it creates the same maze for each dimension. Your example showed me that it truly isn't random. :)
That's a side effect of how most microsoft basic's make random numbers... computers can't actually make random values, it has to come from somewhere. GW-Basic/BasicA on the PC has the RANDOMIZE function which changes the base seed. I THINK applesoft basic uses rnd(-1) to do the same thing, though I forget if that makes a more random base off the system timer, or if it just resets it to zero.

Just checked, and the negative number seeds it -- and with the II having no timer to use as a 'random' seed... Aha, people use the keyboard idle counter...

a=rnd(-peek(78 ))

would do a decent job of randomize on the Apple II. Remember, RND isn't truly random.

NOT that the javascript simulator would be implementing peek's properly...
 
Last edited:
Back
Top