Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Apple » Apple II » Fun little maze program
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Fun little maze program [message #368118] Wed, 23 May 2018 23:54 Go to next message
zellyn is currently offline  zellyn
Messages: 173
Registered: April 2013
Karma: 0
Senior Member
With a bit of help from comp.sys.apple2.programmers (thanks, michaeljmahon!), here's a recreation of one of my oldest and most frequently-written programs. It's a *lot* slower than I remember: perhaps I did it in low-res graphics when I was a teenager :-) Enjoy.

0 W=19:H=19:GOTO 10: REM W=275, H=189
1 C = INT(RND(1) * 4)
2 IF C > 1 THEN GOTO 4
3 C=C*2-1:D=0:RETURN
4 D=C*2-5:C=0:RETURN
10 HGR : X=PEEK(49234)
20 HCOLOR= 3
30 FOR I = 1 TO H
40 HPLOT 1,I TO W,I
50 NEXT
60 HPLOT 0,H+2 TO W+2,H+2
70 HPLOT W+2,0 TO W+2,H+2
80 HCOLOR=0
90 I=2:J=2: XDRAW 1 AT 2,2
100 XDRAW 2 AT I,J:XDRAW 2 AT I,J:S=PEEK(234)
110 IF NOT S THEN GOTO 500
120 GOSUB 1
130 XDRAW 1 AT I+C*2,J+D*2:XDRAW 1 AT I+C*2,J+D*2
140 IF NOT PEEK(234) THEN GOTO 120
150 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C*2,J+D*2: XDRAW 1 AT I+1,J+1
160 I=I+C*2:J=J+D*2
170 GOTO 100
499 REM === BACKTRACK ===
500 XDRAW 2 AT I+1,J+1:XDRAW 2 AT I+1,J+1: IF PEEK(234)=4 THEN GOTO 600
510 X = -1
520 X = X + 1: C = X: GOSUB 2
530 XDRAW 1 AT I+2*C+1, J+2*D+1: XDRAW 1 AT I+2*C+1, J+2*D+1
540 IF PEEK(234) THEN GOTO 520
550 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C,J+D:
560 IF PEEK(234) THEN GOTO 520
570 XDRAW 1 AT I+2*C+1, J+2*D+1
580 I=I+2*C: J=J+2*D
590 GOTO 100
600 HPLOT 0,H+2 TO W+2,H+2
610 HPLOT W+2,0 TO W+2,H+2
620 END
9000 DATA 2,0,6,0,8,0,4,0,18,199,96,8,149,57,0,-1
9010 POKE 232,0
9020 POKE 233,3
9030 ROT=0:SCALE=1
9040 A = 768
9050 READ D
9060 IF D=-1 THEN RETURN
9070 POKE A,D
9080 A=A+1
9090 GOTO 9050
Re: Fun little maze program [message #368126 is a reply to message #368118] Thu, 24 May 2018 07:51 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Melody Ayres-Griffiths

It's missing a GOSUB to 9000 to initialise the shape...

On Thursday, May 24, 2018 at 1:54:33 PM UTC+10, Zellyn wrote:
> With a bit of help from comp.sys.apple2.programmers (thanks, michaeljmahon!), here's a recreation of one of my oldest and most frequently-written programs. It's a *lot* slower than I remember: perhaps I did it in low-res graphics when I was a teenager :-) Enjoy.
>
> 0 W=19:H=19:GOTO 10: REM W=275, H=189
> 1 C = INT(RND(1) * 4)
> 2 IF C > 1 THEN GOTO 4
> 3 C=C*2-1:D=0:RETURN
> 4 D=C*2-5:C=0:RETURN
> 10 HGR : X=PEEK(49234)
> 20 HCOLOR= 3
> 30 FOR I = 1 TO H
> 40 HPLOT 1,I TO W,I
> 50 NEXT
> 60 HPLOT 0,H+2 TO W+2,H+2
> 70 HPLOT W+2,0 TO W+2,H+2
> 80 HCOLOR=0
> 90 I=2:J=2: XDRAW 1 AT 2,2
> 100 XDRAW 2 AT I,J:XDRAW 2 AT I,J:S=PEEK(234)
> 110 IF NOT S THEN GOTO 500
> 120 GOSUB 1
> 130 XDRAW 1 AT I+C*2,J+D*2:XDRAW 1 AT I+C*2,J+D*2
> 140 IF NOT PEEK(234) THEN GOTO 120
> 150 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C*2,J+D*2: XDRAW 1 AT I+1,J+1
> 160 I=I+C*2:J=J+D*2
> 170 GOTO 100
> 499 REM === BACKTRACK ===
> 500 XDRAW 2 AT I+1,J+1:XDRAW 2 AT I+1,J+1: IF PEEK(234)=4 THEN GOTO 600
> 510 X = -1
> 520 X = X + 1: C = X: GOSUB 2
> 530 XDRAW 1 AT I+2*C+1, J+2*D+1: XDRAW 1 AT I+2*C+1, J+2*D+1
> 540 IF PEEK(234) THEN GOTO 520
> 550 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C,J+D:
> 560 IF PEEK(234) THEN GOTO 520
> 570 XDRAW 1 AT I+2*C+1, J+2*D+1
> 580 I=I+2*C: J=J+2*D
> 590 GOTO 100
> 600 HPLOT 0,H+2 TO W+2,H+2
> 610 HPLOT W+2,0 TO W+2,H+2
> 620 END
> 9000 DATA 2,0,6,0,8,0,4,0,18,199,96,8,149,57,0,-1
> 9010 POKE 232,0
> 9020 POKE 233,3
> 9030 ROT=0:SCALE=1
> 9040 A = 768
> 9050 READ D
> 9060 IF D=-1 THEN RETURN
> 9070 POKE A,D
> 9080 A=A+1
> 9090 GOTO 9050
Re: Fun little maze program [message #368130 is a reply to message #368126] Thu, 24 May 2018 09:07 Go to previous messageGo to next message
zellyn is currently offline  zellyn
Messages: 173
Registered: April 2013
Karma: 0
Senior Member
On Thursday, May 24, 2018 at 7:51:24 AM UTC-4, Melody Ayres-Griffiths wrote:
> It's missing a GOSUB to 9000 to initialise the shape...

Ugh, thanks, indeed it is. I tested before posting with a NEW and then re-loading. But should have rebooted!

0 W=19:H=19:GOTO 10: REM W=275, H=189
1 C = INT(RND(1) * 4)
2 IF C > 1 THEN GOTO 4
3 C=C*2-1:D=0:RETURN
4 D=C*2-5:C=0:RETURN
10 HGR : X=PEEK(49234)
15 GOSUB 9000
20 HCOLOR= 3
30 FOR I = 1 TO H
40 HPLOT 1,I TO W,I
50 NEXT
60 HPLOT 0,H+2 TO W+2,H+2
70 HPLOT W+2,0 TO W+2,H+2
80 HCOLOR=0
90 I=2:J=2: XDRAW 1 AT 2,2
100 XDRAW 2 AT I,J:XDRAW 2 AT I,J:S=PEEK(234)
110 IF NOT S THEN GOTO 500
120 GOSUB 1
130 XDRAW 1 AT I+C*2,J+D*2:XDRAW 1 AT I+C*2,J+D*2
140 IF NOT PEEK(234) THEN GOTO 120
150 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C*2,J+D*2: XDRAW 1 AT I+1,J+1
160 I=I+C*2:J=J+D*2
170 GOTO 100
499 REM === BACKTRACK ===
500 XDRAW 2 AT I+1,J+1:XDRAW 2 AT I+1,J+1: IF PEEK(234)=4 THEN GOTO 600
510 X = -1
520 X = X + 1: C = X: GOSUB 2
530 XDRAW 1 AT I+2*C+1, J+2*D+1: XDRAW 1 AT I+2*C+1, J+2*D+1
540 IF PEEK(234) THEN GOTO 520
550 XDRAW 1 AT I+C,J+D:XDRAW 1 AT I+C,J+D:
560 IF PEEK(234) THEN GOTO 520
570 XDRAW 1 AT I+2*C+1, J+2*D+1
580 I=I+2*C: J=J+2*D
590 GOTO 100
600 HPLOT 0,H+2 TO W+2,H+2
610 HPLOT W+2,0 TO W+2,H+2
620 END
9000 DATA 2,0,6,0,8,0,4,0,18,199,96,8,149,57,0,-1
9010 POKE 232,0
9020 POKE 233,3
9030 ROT=0:SCALE=1
9040 A = 768
9050 READ D
9060 IF D=-1 THEN RETURN
9070 POKE A,D
9080 A=A+1
9090 GOTO 9050
Re: Fun little maze program [message #368215 is a reply to message #368130] Mon, 28 May 2018 03:17 Go to previous messageGo to next message
barrym95838 is currently offline  barrym95838
Messages: 130
Registered: April 2013
Karma: 0
Senior Member
On Thursday, May 24, 2018 at 6:07:05 AM UTC-7, Zellyn wrote:
> On Thursday, May 24, 2018 at 7:51:24 AM UTC-4, Melody Ayres-Griffiths wrote:
>> It's missing a GOSUB to 9000 to initialise the shape...
>
> Ugh, thanks, indeed it is. I tested before posting with a NEW and then re-loading. But should have rebooted!
>
> ...
>

When I paste it and RUN it in AppleWin it plots a tiny little maze in the
upper left corner ... too tiny to even bear much resemblance to a maze ...

Mike B.
Re: Fun little maze program [message #368216 is a reply to message #368215] Mon, 28 May 2018 03:20 Go to previous messageGo to next message
barrym95838 is currently offline  barrym95838
Messages: 130
Registered: April 2013
Karma: 0
Senior Member
On Monday, May 28, 2018 at 12:17:30 AM UTC-7, barrym95838 wrote:
> On Thursday, May 24, 2018 at 6:07:05 AM UTC-7, Zellyn wrote:
>> On Thursday, May 24, 2018 at 7:51:24 AM UTC-4, Melody Ayres-Griffiths wrote:
>>> It's missing a GOSUB to 9000 to initialise the shape...
>>
>> Ugh, thanks, indeed it is. I tested before posting with a NEW and then re-loading. But should have rebooted!
>>
>> ...
>>
>
> When I paste it and RUN it in AppleWin it plots a tiny little maze in the
> upper left corner ... too tiny to even bear much resemblance to a maze ...
>
> Mike B.

.... oh, I missed the significance of the REM in line 0 ... Doh!

Mike B.
Re: Fun little maze program [message #368217 is a reply to message #368216] Mon, 28 May 2018 05:17 Go to previous messageGo to next message
barrym95838 is currently offline  barrym95838
Messages: 130
Registered: April 2013
Karma: 0
Senior Member
On Monday, May 28, 2018 at 12:20:54 AM UTC-7, barrym95838 wrote:
> ...

You inspired me dig up an old lores version I wrote long ago and try it
again. I was disappointed with its performance ... I think my maze
generation algorithm left a bit to be desired :-(

10 HOME : GR : INPUT "ENTER MAZE DIMENSIONS (MAX 18,18)";H,V
15 ON H < 1 OR V < 1 OR H > 18 OR V > 18 GOTO 10:C = H * V
20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
35 M = X * 2:N = Y * 2
40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
50 IF L OR R OR U OR D THEN 65
55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
65 IF L * RND (1) > .75 THEN PLOT M - 1,N:X = X - 1: GOTO 30
70 IF R * RND (1) > .75 THEN PLOT M + 1,N:X = X + 1: GOTO 30
75 IF U * RND (1) > .75 THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
80 IF D * RND (1) > .75 THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
85 GOTO 65
90 PLOT INT ( RND (1) * H) * 2,1 + V * 2 : END

Mike B.
Re: Fun little maze program [message #368225 is a reply to message #368217] Mon, 28 May 2018 14:36 Go to previous messageGo to next message
barrym95838 is currently offline  barrym95838
Messages: 130
Registered: April 2013
Karma: 0
Senior Member
On Monday, May 28, 2018 at 2:17:40 AM UTC-7, barrym95838 wrote:
> ...
>
I fiddled with it a bit this morning, and came up with an obvious
performance improvement, without any obvious loss of quality.

Fixed an intermittent exit door bug too :-)

Play-time is over now, at least while the sun's up. Got too many
big-boy chores waiting ...

10 HOME : GR : INPUT "ENTER MAZE DIMENSIONS (MAX 18,18)";H,V
15 ON H < 1 OR V < 1 OR H > 18 OR V > 18 GOTO 10:C = H * V
20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
35 M = X * 2:N = Y * 2
40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
85 GOTO 65
90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2 : END

Mike B.
Re: Fun little maze program [message #368255 is a reply to message #368225] Tue, 29 May 2018 14:28 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

On 2018-05-28 13:36, barrym95838 wrote:
> On Monday, May 28, 2018 at 2:17:40 AM UTC-7, barrym95838 wrote:
>> ...
>>
> I fiddled with it a bit this morning, and came up with an obvious
> performance improvement, without any obvious loss of quality.
>
> Fixed an intermittent exit door bug too :-)
>
> 10 HOME : GR : INPUT "ENTER MAZE DIMENSIONS (MAX 18,18)";H,V
> 15 ON H < 1 OR V < 1 OR H > 18 OR V > 18 GOTO 10:C = H * V
> 20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
> 25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
> 30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
> 35 M = X * 2:N = Y * 2
> 40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
> 45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
> 50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
> 55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
> 60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
> 65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
> 70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
> 75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
> 80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
> 85 GOTO 65
> 90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2 : END
>
> Mike B.

I added a couple of things to make it attempt DGR if in 80-column mode.
Then i added machine checking, so it'll force DGR on a IIgs,IIc,IIc+,
and LGR on anything else. (Tested on GSplus, and AppleWin; so the IIc
check hasn't been tested.)

10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
POKE 773,133: POKE 774,6: POKE 777,96: CALL 768
11 HOME : PRINT CHR$ (17);: POKE 49247,.: IF PEEK (6) < 128 OR (
PEEK (64435) = 6 AND PEEK (64448) = 0) THEN PRINT CHR$ (18);: POKE
49246,.
12 GR : HOME :HM = PEEK (33) / 2 - 2: PRINT "MAZE DIMENSIONS (MAX
"HM",18)";: INPUT ": ";H,V
15 ON H < 1 OR V < 1 OR H > HM OR V > 18 GOTO 12:C = H * V

(Sorry about the long lines.)

Have a II-riffic day! :)
Re: Fun little maze program [message #368262 is a reply to message #368255] Tue, 29 May 2018 20:04 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: John Brooks

On Tuesday, May 29, 2018 at 11:28:06 AM UTC-7, Brian Patrie wrote:
> On 2018-05-28 13:36, barrym95838 wrote:
>> On Monday, May 28, 2018 at 2:17:40 AM UTC-7, barrym95838 wrote:
>>> ...
>>>
>> I fiddled with it a bit this morning, and came up with an obvious
>> performance improvement, without any obvious loss of quality.
>>
>> Fixed an intermittent exit door bug too :-)
>>
>> 10 HOME : GR : INPUT "ENTER MAZE DIMENSIONS (MAX 18,18)";H,V
>> 15 ON H < 1 OR V < 1 OR H > 18 OR V > 18 GOTO 10:C = H * V
>> 20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
>> 25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
>> 30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
>> 35 M = X * 2:N = Y * 2
>> 40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
>> 45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
>> 50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
>> 55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
>> 60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
>> 65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
>> 70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
>> 75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
>> 80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
>> 85 GOTO 65
>> 90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2 : END
>>
>> Mike B.
>
> I added a couple of things to make it attempt DGR if in 80-column mode.
> Then i added machine checking, so it'll force DGR on a IIgs,IIc,IIc+,
> and LGR on anything else. (Tested on GSplus, and AppleWin; so the IIc
> check hasn't been tested.)
>
> 10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
> POKE 773,133: POKE 774,6: POKE 777,96: CALL 768
> 11 HOME : PRINT CHR$ (17);: POKE 49247,.: IF PEEK (6) < 128 OR (
> PEEK (64435) = 6 AND PEEK (64448) = 0) THEN PRINT CHR$ (18);: POKE
> 49246,.
> 12 GR : HOME :HM = PEEK (33) / 2 - 2: PRINT "MAZE DIMENSIONS (MAX
> "HM",18)";: INPUT ": ";H,V
> 15 ON H < 1 OR V < 1 OR H > HM OR V > 18 GOTO 12:C = H * V
>
> (Sorry about the long lines.)
>
> Have a II-riffic day! :)

Looks like a bug in line 10 as 775 & 776 are not initialized. Perhaps the last poke should be poke 775,96?

-JB
@JBrooksBSI
Re: Fun little maze program [message #368290 is a reply to message #368262] Wed, 30 May 2018 03:15 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

On 2018-05-29 19:04, John Brooks wrote:
> On Tuesday, May 29, 2018 at 11:28:06 AM UTC-7, Brian Patrie wrote:
>> On 2018-05-28 13:36, barrym95838 wrote:
>>> On Monday, May 28, 2018 at 2:17:40 AM UTC-7, barrym95838 wrote:
>>>> ...
>>>>
>>> I fiddled with it a bit this morning, and came up with an obvious
>>> performance improvement, without any obvious loss of quality.
>>>
>>> Fixed an intermittent exit door bug too :-)
>>>
>>> 10 HOME : GR : INPUT "ENTER MAZE DIMENSIONS (MAX 18,18)";H,V
>>> 15 ON H < 1 OR V < 1 OR H > 18 OR V > 18 GOTO 10:C = H * V
>>> 20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
>>> 25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
>>> 30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
>>> 35 M = X * 2:N = Y * 2
>>> 40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
>>> 45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
>>> 50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
>>> 55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
>>> 60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
>>> 65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
>>> 70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
>>> 75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
>>> 80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
>>> 85 GOTO 65
>>> 90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2 : END
>>>
>>> Mike B.
>>
>> I added a couple of things to make it attempt DGR if in 80-column mode.
>> Then i added machine checking, so it'll force DGR on a IIgs,IIc,IIc+,
>> and LGR on anything else. (Tested on GSplus, and AppleWin; so the IIc
>> check hasn't been tested.)
>>
>> 10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
>> POKE 773,133: POKE 774,6: POKE 777,96: CALL 768
>> 11 HOME : PRINT CHR$ (17);: POKE 49247,.: IF PEEK (6) < 128 OR (
>> PEEK (64435) = 6 AND PEEK (64448) = 0) THEN PRINT CHR$ (18);: POKE
>> 49246,.
>> 12 GR : HOME :HM = PEEK (33) / 2 - 2: PRINT "MAZE DIMENSIONS (MAX
>> "HM",18)";: INPUT ": ";H,V
>> 15 ON H < 1 OR V < 1 OR H > HM OR V > 18 GOTO 12:C = H * V
>>
>> (Sorry about the long lines.)
>>
>> Have a II-riffic day! :)
>
> Looks like a bug in line 10 as 775 & 776 are not initialized. Perhaps the last poke should be poke 775,96?
>
> -JB
> @JBrooksBSI

Sorry; i had an attack of the stupids whilst removing an unneeded STY
$07 (which was there for something else that i used it for, where i
wanted the ROM version), and i failed to suck the RTS back to the new
endpoint. (Missed it because the removed bytes were still in memory
from the previous run.)

10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
POKE 773,133: POKE 774,6: POKE 775,96: CALL 768
Re: Fun little maze program [message #368291 is a reply to message #368290] Wed, 30 May 2018 03:19 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

Oh, and it lazily selects 80-column mode--i.e. the firmware has to be
enabled. I should throw a PR#3 in there.
Re: Fun little maze program [message #368294 is a reply to message #368291] Wed, 30 May 2018 04:20 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

Ok. All fixed up, now (i think).

1 REM LGR MAZE GENERATOR BY MIKE BARRY
2 REM MOD'D FOR DGR ON IIGS,IIC,IIC+ BY BRIAN PATRIE
10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
POKE 773,133: POKE 774,6: POKE 775,96: CALL 768
11 HOME : PRINT CHR$ (17);: POKE 49247,.: IF PEEK (6) < 128 OR ( PEEK
(64435) = 6 AND PEEK (64448) = 0) THEN PRINT CHR$ (4)"PR#3": PRINT :
POKE 49246,.
12 GR : HOME :HM = PEEK (33) / 2 - 2: PRINT "MAZE DIMENSIONS (MAX
"HM",18)";: INPUT ": ";H,V
15 ON H < 1 OR V < 1 OR H > HM OR V > 18 GOTO 12:C = H * V
20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
35 M = X * 2:N = Y * 2
40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
85 GOTO 65
90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2: END

[Cringes. Sends.]
--
Have a II-riffic day!
Re: Fun little maze program [message #368312 is a reply to message #368294] Wed, 30 May 2018 14:24 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: John Brooks

On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
> Ok. All fixed up, now (i think).
>
> 1 REM LGR MAZE GENERATOR BY MIKE BARRY
> 2 REM MOD'D FOR DGR ON IIGS,IIC,IIC+ BY BRIAN PATRIE
> 10 POKE 768,56: POKE 769,32: POKE 770,31: POKE 771,254: POKE 772,106:
> POKE 773,133: POKE 774,6: POKE 775,96: CALL 768
> 11 HOME : PRINT CHR$ (17);: POKE 49247,.: IF PEEK (6) < 128 OR ( PEEK
> (64435) = 6 AND PEEK (64448) = 0) THEN PRINT CHR$ (4)"PR#3": PRINT :
> POKE 49246,.
> 12 GR : HOME :HM = PEEK (33) / 2 - 2: PRINT "MAZE DIMENSIONS (MAX
> "HM",18)";: INPUT ": ";H,V
> 15 ON H < 1 OR V < 1 OR H > HM OR V > 18 GOTO 12:C = H * V
> 20 COLOR= 4: FOR X = 1 TO 1 + H * 2: VLIN 1,1 + V * 2 AT X: NEXT
> 25 COLOR= 0:X = INT (1 + RND (1) * H):Y = 1: PLOT X * 2,Y
> 30 PLOT X * 2,Y * 2:C = C - 1: IF C < 1 THEN 90
> 35 M = X * 2:N = Y * 2
> 40 L = X > 1 AND SCRN( M - 2,N):R = X < H AND SCRN( M + 2,N)
> 45 U = Y > 1 AND SCRN( M,N - 2):D = Y < V AND SCRN( M,N + 2)
> 50 ON (L OR R OR U OR D) * (1 + RND (1) * 4) GOTO 65,70,75,80
> 55 Y = Y + 1: IF Y > V THEN Y = 1:X = X + 1: IF X > H THEN X = 1
> 60 ON SCRN( X * 2,Y * 2) + 1 GOTO 35: GOTO 55
> 65 IF L THEN PLOT M - 1,N:X = X - 1: GOTO 30
> 70 IF R THEN PLOT M + 1,N:X = X + 1: GOTO 30
> 75 IF U THEN PLOT M,N - 1:Y = Y - 1: GOTO 30
> 80 IF D THEN PLOT M,N + 1:Y = Y + 1: GOTO 30
> 85 GOTO 65
> 90 PLOT INT (1 + RND (1) * H) * 2,1 + V * 2: END
>
> [Cringes. Sends.]
> --
> Have a II-riffic day!

Here is a version which is a bit more compact and ~2x faster:
18x18 on a 1Mhz Apple ][ in ~29 seconds
38x18 on a 2.8MHz Apple IIGS in ~25 seconds

5 GR : COLOR= 4: HOME : GOTO 100
10 IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
15 IF SCRN( X,Y) THEN X = X + 2: GOTO 10
20 SX = X:SY = Y: GOTO 55
25 IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : END
30 IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : END
35 IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : END
40 IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : END
45 GOTO 25
50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
55 L = SCRN( X - 2,Y):R = SCRN( X + 2,Y)
60 U = SCRN( X,Y - 2):D = SCRN( X,Y + 2)
65 IF L + R + U + D THEN ON 1 + RND (1) * 4 GOTO 25,30,35,40
70 X = SX + 2:Y = SY: GOTO 10
100 M = 18: IF PEEK ( - 1250) < > 76 THEN PRINT CHR$ (17): GOTO 115
110 IF PEEK (33) = 80 THEN POKE 49246,0:M = 38
115 PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";H,V
120 C = H * V: IF H < 1 OR V < 1 OR H > M OR V > 18 GOTO 115
125 H = H + H:V = V + V: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
130 COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50

-JB
@JBrooksBSI
Re: Fun little maze program [message #368317 is a reply to message #368312] Wed, 30 May 2018 14:38 Go to previous messageGo to next message
David Schmidt is currently offline  David Schmidt
Messages: 993
Registered: October 2012
Karma: 0
Senior Member
On 5/30/2018 2:24 PM, John Brooks wrote:
> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>> Ok. All fixed up, now (i think).
>>
> Here is a version which is a bit more compact and ~2x faster:
> 18x18 on a 1Mhz Apple ][ in ~29 seconds
> 38x18 on a 2.8MHz Apple IIGS in ~25 seconds

Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)
Re: Fun little maze program [message #368318 is a reply to message #368317] Wed, 30 May 2018 16:16 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: John Brooks

On Wednesday, May 30, 2018 at 11:38:44 AM UTC-7, schmidtd wrote:
> On 5/30/2018 2:24 PM, John Brooks wrote:
>> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>> Ok. All fixed up, now (i think).
>>>
>> Here is a version which is a bit more compact and ~2x faster:
>> 18x18 on a 1Mhz Apple ][ in ~29 seconds
>> 38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>
> Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)

Ah, good catch.

Here is a revised version:
- Smallest maze allowed is 2x2
- Auto-enables 80-col and dbl lores on GS and IIc, IIc+

5 GOTO 100
10 IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
15 IF SCRN( X,Y) THEN X = X + 2: GOTO 10
20 SX = X:SY = Y: GOTO 55
25 IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : END
30 IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : END
35 IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : END
40 IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : END
45 GOTO 25
50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
55 L = SCRN( X - 2,Y):R = SCRN( X + 2,Y)
60 U = SCRN( X,Y - 2):D = SCRN( X,Y + 2)
65 IF L + R + U + D THEN ON 1 + RND (1) * 4 GOTO 25,30,35,40
70 X = SX + 2:Y = SY: GOTO 10
100 M = 18: IF PEEK ( - 1250) = 76 THEN 110
105 IF PEEK ( - 1088) THEN PRINT CHR$ (17): GR : GOTO 115
110 PRINT CHR$ (4)"PR#3": HOME : POKE 49246,0:M = 38: GR
115 HOME : PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";X,Y
120 H = X + X:V = Y + Y: IF X < 2 OR Y < 2 OR X > M OR Y > 18 GOTO 115
125 C = X * Y: COLOR= 4: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
130 COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50

-JB
@JBrooksBSI
Re: Fun little maze program [message #368324 is a reply to message #368318] Wed, 30 May 2018 17:05 Go to previous messageGo to next message
David Schmidt is currently offline  David Schmidt
Messages: 993
Registered: October 2012
Karma: 0
Senior Member
On 5/30/2018 4:16 PM, John Brooks wrote:
> On Wednesday, May 30, 2018 at 11:38:44 AM UTC-7, schmidtd wrote:
>> On 5/30/2018 2:24 PM, John Brooks wrote:
>>> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>>> Ok. All fixed up, now (i think).
>>>>
>>> Here is a version which is a bit more compact and ~2x faster:
>>> 18x18 on a 1Mhz Apple ][ in ~29 seconds
>>> 38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>>
>> Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)
>
> Ah, good catch.
>
> Here is a revised version:
> - Smallest maze allowed is 2x2
> - Auto-enables 80-col and dbl lores on GS and IIc, IIc+

Hmmm. On a GS that doesn't have 80 column active, running gives the
option to have max of 38x18 - but you get an ?illegal quantity error in
125 if you actually go above 18 in the horizontal. (PR#3 and re-running
fixes it.)
Re: Fun little maze program [message #368327 is a reply to message #368324] Wed, 30 May 2018 18:29 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: John Brooks

On Wednesday, May 30, 2018 at 2:05:14 PM UTC-7, schmidtd wrote:
> On 5/30/2018 4:16 PM, John Brooks wrote:
>> On Wednesday, May 30, 2018 at 11:38:44 AM UTC-7, schmidtd wrote:
>>> On 5/30/2018 2:24 PM, John Brooks wrote:
>>>> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>>> > Ok. All fixed up, now (i think).
>>>> >
>>>> Here is a version which is a bit more compact and ~2x faster:
>>>> 18x18 on a 1Mhz Apple ][ in ~29 seconds
>>>> 38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>>>
>>> Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)
>>
>> Ah, good catch.
>>
>> Here is a revised version:
>> - Smallest maze allowed is 2x2
>> - Auto-enables 80-col and dbl lores on GS and IIc, IIc+
>
> Hmmm. On a GS that doesn't have 80 column active, running gives the
> option to have max of 38x18 - but you get an ?illegal quantity error in
> 125 if you actually go above 18 in the horizontal. (PR#3 and re-running
> fixes it.)

Whoops, forgot to do a print after PR# so 80-col firmware would be set up for GR:

5 GOTO 100
10 IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
15 IF SCRN( X,Y) THEN X = X + 2: GOTO 10
20 SX = X:SY = Y: GOTO 55
25 IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : END
30 IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : END
35 IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : END
40 IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : END
45 GOTO 25
50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
55 L = SCRN( X - 2,Y):R = SCRN( X + 2,Y)
60 U = SCRN( X,Y - 2):D = SCRN( X,Y + 2)
65 IF L + R + U + D THEN ON 1 + RND (1) * 4 GOTO 25,30,35,40
70 X = SX + 2:Y = SY: GOTO 10
100 M = 18: IF PEEK ( - 1250) = 76 THEN 110
105 IF PEEK ( - 1088) THEN PRINT CHR$ (17): GR : GOTO 115
110 PRINT CHR$ (4)"PR#3": PRINT : POKE 49246,0:M = 38: GR
115 HOME : PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";X,Y
120 H = X + X:V = Y + Y: IF X < 2 OR Y < 2 OR X > M OR Y > 18 GOTO 115
125 C = X * Y: COLOR= 4: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
130 COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50

The safest approach would be to require the user to activate 80 col beforehand and then the code could just check for 80-col via peek(33).

But auto-enableis more convenient.

-JB
@JBrooksBSI
Re: Fun little maze program [message #368329 is a reply to message #368317] Wed, 30 May 2018 20:35 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

On 2018-05-30 13:38, David Schmidt wrote:
> On 5/30/2018 2:24 PM, John Brooks wrote:
>> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>> Ok.  All fixed up, now (i think).
>>>
>> Here is a version which is a bit more compact and ~2x faster:
>>   18x18 on a 1Mhz Apple ][ in ~29 seconds
>>   38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>
> Love code golf.  John - yours loops endlessly at 1x1.  Brian's doesn't. :-)

You mean Mike's; all i did was add some plumbing to throw it into DGR mode.

--Brian
Re: Fun little maze program [message #368333 is a reply to message #368327] Wed, 30 May 2018 20:50 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Brian Patrie

On 2018-05-30 17:29, John Brooks wrote:
> The safest approach would be to require the user to activate 80 col beforehand and then the code could just check for 80-col via peek(33).
>
> But auto-enableis more convenient.
>
> -JB
> @JBrooksBSI

That's essentially what my DGR setup did at one point--spit out CHR$(18)
and check PEEK(33). But then i figured that availability of 80-columns
on IIgs,IIc,IIc+ is a given, so i went ahead and put the PR#3 in.

--Brian
Re: Fun little maze program [message #368334 is a reply to message #368327] Wed, 30 May 2018 21:11 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Matthew Power

> But auto-enable is more convenient.
>
> -JB
> @JBrooksBSI

This version is awesome. Does anyone know a way to save the maze as an image so it could be printed from a graphics program to an ImageWriter or such ? The kids would love to play around with that. I think Zoom Grafix can do it with hi-res, but not lo-res.
Re: Fun little maze program [message #368335 is a reply to message #368329] Wed, 30 May 2018 21:21 Go to previous messageGo to next message
David Schmidt is currently offline  David Schmidt
Messages: 993
Registered: October 2012
Karma: 0
Senior Member
On 5/30/2018 8:35 PM, Brian Patrie wrote:
> On 2018-05-30 13:38, David Schmidt wrote:
>> On 5/30/2018 2:24 PM, John Brooks wrote:
>>> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>>> Ok.  All fixed up, now (i think).
>>>>
>>> Here is a version which is a bit more compact and ~2x faster:
>>>   18x18 on a 1Mhz Apple ][ in ~29 seconds
>>>   38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>>
>> Love code golf.  John - yours loops endlessly at 1x1.  Brian's
>> doesn't. :-)
>
> You mean Mike's; all i did was add some plumbing to throw it into DGR mode.

Ah, sorry - yes indeed. I'm just the tester here.
Re: Fun little maze program [message #368350 is a reply to message #368334] Thu, 31 May 2018 09:29 Go to previous messageGo to next message
zellyn is currently offline  zellyn
Messages: 173
Registered: April 2013
Karma: 0
Senior Member
On Wednesday, May 30, 2018 at 9:11:56 PM UTC-4, Matthew Power wrote:
>> But auto-enable is more convenient.
>>
>> -JB
>> @JBrooksBSI
>
> This version is awesome. Does anyone know a way to save the maze as an image so it could be printed from a graphics program to an ImageWriter or such ? The kids would love to play around with that. I think Zoom Grafix can do it with hi-res, but not lo-res.

Not retrocomputing, but I made this a while back for my kid: https://zellyn..github.io/mazes/maze.html

Source: https://github.com/zellyn/mazes

Zellyn
Re: Fun little maze program [message #368351 is a reply to message #368327] Thu, 31 May 2018 09:45 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: vavruska

On Wednesday, May 30, 2018 at 6:29:02 PM UTC-4, John Brooks wrote:
> On Wednesday, May 30, 2018 at 2:05:14 PM UTC-7, schmidtd wrote:
>> On 5/30/2018 4:16 PM, John Brooks wrote:
>>> On Wednesday, May 30, 2018 at 11:38:44 AM UTC-7, schmidtd wrote:
>>>> On 5/30/2018 2:24 PM, John Brooks wrote:
>>>> > On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>>> >> Ok. All fixed up, now (i think).
>>>> >>
>>>> > Here is a version which is a bit more compact and ~2x faster:
>>>> > 18x18 on a 1Mhz Apple ][ in ~29 seconds
>>>> > 38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>>>>
>>>> Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)
>>>
>>> Ah, good catch.
>>>
>>> Here is a revised version:
>>> - Smallest maze allowed is 2x2
>>> - Auto-enables 80-col and dbl lores on GS and IIc, IIc+
>>
>> Hmmm. On a GS that doesn't have 80 column active, running gives the
>> option to have max of 38x18 - but you get an ?illegal quantity error in
>> 125 if you actually go above 18 in the horizontal. (PR#3 and re-running
>> fixes it.)
>
> Whoops, forgot to do a print after PR# so 80-col firmware would be set up for GR:
>
> 5 GOTO 100
> 10 IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
> 15 IF SCRN( X,Y) THEN X = X + 2: GOTO 10
> 20 SX = X:SY = Y: GOTO 55
> 25 IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : END
> 30 IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : END
> 35 IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : END
> 40 IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : END
> 45 GOTO 25
> 50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
> 55 L = SCRN( X - 2,Y):R = SCRN( X + 2,Y)
> 60 U = SCRN( X,Y - 2):D = SCRN( X,Y + 2)
> 65 IF L + R + U + D THEN ON 1 + RND (1) * 4 GOTO 25,30,35,40
> 70 X = SX + 2:Y = SY: GOTO 10
> 100 M = 18: IF PEEK ( - 1250) = 76 THEN 110
> 105 IF PEEK ( - 1088) THEN PRINT CHR$ (17): GR : GOTO 115
> 110 PRINT CHR$ (4)"PR#3": PRINT : POKE 49246,0:M = 38: GR
> 115 HOME : PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";X,Y
> 120 H = X + X:V = Y + Y: IF X < 2 OR Y < 2 OR X > M OR Y > 18 GOTO 115
> 125 C = X * Y: COLOR= 4: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
> 130 COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50
>
> The safest approach would be to require the user to activate 80 col beforehand and then the code could just check for 80-col via peek(33).
>
> But auto-enableis more convenient.
>
> -JB
> @JBrooksBSI

To make JB's code into a game change the ENDs on lines 25-40 to GOTO 200 and add the following:

200 X = 2: Y = 1
205 COLOR= 8: PLOT X,Y : IF X = H AND Y = V + 1 THEN TEXT : HOME :PRINT "YOU WON!" : END
210 PRINT "MOVE I,J,K,M";
215 GET M$ : NX = X : NY = Y
220 IF M$ = "I" AND Y - 1 > 0 THEN NY = NY - 1: PRINT "UP"
230 IF M$ = "M" AND Y - 1 > 0 THEN NY = NY + 1: PRINT "DOWN"
240 IF M$ = "J" AND Y - 1 > 0 THEN NX = NX - 1: PRINT "LEFT"
250 IF M$ = "K" AND Y - 1 > 0 THEN NX = NX + 1: PRINT "RIGHT"
260 IF M$ = "Q" THEN TEXT : HOME : PRINT "QUIT": END
265 IF Y = NY AND X = NX THEN 215
270 IF SCRN( NX,NY) = 0 THEN COLOR= 0: PLOT X,Y:X = NX: Y = NY
280 GOTO 205
Re: Fun little maze program [message #368356 is a reply to message #368351] Thu, 31 May 2018 11:50 Go to previous message
Anonymous
Karma:
Originally posted by: John Brooks

On Thursday, May 31, 2018 at 6:45:35 AM UTC-7, vavr...@gmail.com wrote:
> On Wednesday, May 30, 2018 at 6:29:02 PM UTC-4, John Brooks wrote:
>> On Wednesday, May 30, 2018 at 2:05:14 PM UTC-7, schmidtd wrote:
>>> On 5/30/2018 4:16 PM, John Brooks wrote:
>>>> On Wednesday, May 30, 2018 at 11:38:44 AM UTC-7, schmidtd wrote:
>>>> > On 5/30/2018 2:24 PM, John Brooks wrote:
>>>> >> On Wednesday, May 30, 2018 at 1:20:57 AM UTC-7, Brian Patrie wrote:
>>>> >>> Ok. All fixed up, now (i think).
>>>> >>>
>>>> >> Here is a version which is a bit more compact and ~2x faster:
>>>> >> 18x18 on a 1Mhz Apple ][ in ~29 seconds
>>>> >> 38x18 on a 2.8MHz Apple IIGS in ~25 seconds
>>>> >
>>>> > Love code golf. John - yours loops endlessly at 1x1. Brian's doesn't. :-)
>>>>
>>>> Ah, good catch.
>>>>
>>>> Here is a revised version:
>>>> - Smallest maze allowed is 2x2
>>>> - Auto-enables 80-col and dbl lores on GS and IIc, IIc+
>>>
>>> Hmmm. On a GS that doesn't have 80 column active, running gives the
>>> option to have max of 38x18 - but you get an ?illegal quantity error in
>>> 125 if you actually go above 18 in the horizontal. (PR#3 and re-running
>>> fixes it.)
>>
>> Whoops, forgot to do a print after PR# so 80-col firmware would be set up for GR:
>>
>> 5 GOTO 100
>> 10 IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
>> 15 IF SCRN( X,Y) THEN X = X + 2: GOTO 10
>> 20 SX = X:SY = Y: GOTO 55
>> 25 IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : END
>> 30 IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : END
>> 35 IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : END
>> 40 IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : END
>> 45 GOTO 25
>> 50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
>> 55 L = SCRN( X - 2,Y):R = SCRN( X + 2,Y)
>> 60 U = SCRN( X,Y - 2):D = SCRN( X,Y + 2)
>> 65 IF L + R + U + D THEN ON 1 + RND (1) * 4 GOTO 25,30,35,40
>> 70 X = SX + 2:Y = SY: GOTO 10
>> 100 M = 18: IF PEEK ( - 1250) = 76 THEN 110
>> 105 IF PEEK ( - 1088) THEN PRINT CHR$ (17): GR : GOTO 115
>> 110 PRINT CHR$ (4)"PR#3": PRINT : POKE 49246,0:M = 38: GR
>> 115 HOME : PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";X,Y
>> 120 H = X + X:V = Y + Y: IF X < 2 OR Y < 2 OR X > M OR Y > 18 GOTO 115
>> 125 C = X * Y: COLOR= 4: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
>> 130 COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50
>>
>> The safest approach would be to require the user to activate 80 col beforehand and then the code could just check for 80-col via peek(33).
>>
>> But auto-enableis more convenient.
>>
>> -JB
>> @JBrooksBSI
>
> To make JB's code into a game change the ENDs on lines 25-40 to GOTO 200 and add the following:
>
> 200 X = 2: Y = 1
> 205 COLOR= 8: PLOT X,Y : IF X = H AND Y = V + 1 THEN TEXT : HOME :PRINT "YOU WON!" : END
> 210 PRINT "MOVE I,J,K,M";
> 215 GET M$ : NX = X : NY = Y
> 220 IF M$ = "I" AND Y - 1 > 0 THEN NY = NY - 1: PRINT "UP"
> 230 IF M$ = "M" AND Y - 1 > 0 THEN NY = NY + 1: PRINT "DOWN"
> 240 IF M$ = "J" AND Y - 1 > 0 THEN NX = NX - 1: PRINT "LEFT"
> 250 IF M$ = "K" AND Y - 1 > 0 THEN NX = NX + 1: PRINT "RIGHT"
> 260 IF M$ = "Q" THEN TEXT : HOME : PRINT "QUIT": END
> 265 IF Y = NY AND X = NX THEN 215
> 270 IF SCRN( NX,NY) = 0 THEN COLOR= 0: PLOT X,Y:X = NX: Y = NY
> 280 GOTO 205


Fixed a couple bugs in the 'game' version and added a moves ctr:

 5  GOTO 100
 10  IF X > H THEN X = 2:Y = Y + 2: IF Y > V THEN Y = 2
 15  IF  SCRN( X,Y) THEN X = X + 2: GOTO 10
 20 SX = X:SY = Y: GOTO 55
 25  IF L THEN X = X - 2: HLIN X,X + 1 AT Y: NEXT : GOTO 200
 30  IF R THEN X = X + 2: HLIN X - 1,X AT Y: NEXT : GOTO 200
 35  IF U THEN Y = Y - 2: VLIN Y,Y + 1 AT X: NEXT : GOTO 200
 40  IF D THEN Y = Y + 2: VLIN Y - 1,Y AT X: NEXT : GOTO 200
 45  GOTO 25
 50 X = 2:Y = 2:SX = X:SY = Y: FOR I = 2 TO C
 55 L =  SCRN( X - 2,Y):R =  SCRN( X + 2,Y)
 60 U =  SCRN( X,Y - 2):D =  SCRN( X,Y + 2)
 65  IF L OR R OR U OR D THEN  ON 1 +  RND (1) * 4 GOTO 25,30,35,40
 70 X = SX + 2:Y = SY: GOTO 10
 100 M = 18: IF  PEEK ( - 1250) = 76 THEN 110
 105  IF  PEEK ( - 1088) THEN  PRINT  CHR$ (17): GR : GOTO 115
 110  PRINT  CHR$ (4)"PR#3": PRINT : POKE 49246,0:M = 38: GR
 115  HOME : PRINT "MAZE DIMENSIONS (MAX "M",18)";: INPUT " = ";X,Y
 120 H = X + X:V = Y + Y: IF X < 2 OR Y < 2 OR X > M OR Y > 18 GOTO 115
 125 C = X * Y: COLOR= 4: FOR Y = 1 TO 1 + V: HLIN 1,1 + H AT Y: NEXT
 130  COLOR= 0: VLIN 1,2 AT 2: PLOT H,1 + V: GOTO 50

 200 N = 1:X = 2:Y = 1
 205  COLOR= 8: PLOT X,Y
 210  PRINT : PRINT "MOVE "N": I,J,K,M OR Q ";: GET M$:NX = X:NY = Y
 215  IF  ASC (M$) > 96 THEN M$ =  CHR$ ( ASC (M$) - 32)
 220  IF M$ = "I" THEN  PRINT "UP";: IF Y > 1 THEN NY = NY - 1
 230  IF M$ = "M" THEN  PRINT "DOWN";: IF Y <  = V THEN NY = NY + 1
 240  IF M$ = "J" THEN  PRINT "LEFT";: IF X > 2 THEN NX = NX - 1
 250  IF M$ = "K" THEN  PRINT "RIGHT";: IF X < H THEN NX = NX + 1
 260  IF M$ = "Q" THEN  TEXT : HOME : PRINT "QUIT": END
 265  IF  SCRN( NX,NY) OR (Y = NY AND X = NX) THEN 210
 270  COLOR= 0: PLOT X,Y:X = NX:Y = NY:N = N + 1: IF Y <  = V THEN 205
 275  PRINT : PRINT "YOU WON IN "N" MOVES!": END

Enjoy.

-JB
@JBrooksBSI
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Did my Apple iiGS Die?
Next Topic: entropy demo -- 122 bytes
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Apr 19 01:33:25 EDT 2024

Total time taken to generate the page: 0.01950 seconds