Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AppleSoft Maze/Dungeon Generation?

253 views
Skip to first unread message

Steve][

unread,
Feb 19, 2015, 6:38:46 PM2/19/15
to

Hey all. Can anyone recommend an AppleSoft BASIC (or Integer BASIC I
guess) program that will generate simple dungeons or mazes in
40-column ASCII?

Thanks.


Message has been deleted

gid...@sasktel.net

unread,
Feb 19, 2015, 9:47:19 PM2/19/15
to
Shoot me a PM, Steve, and I will send you a disk image of my collection of Mazes and Random Number routines.

wss...@gmail.com

unread,
Feb 20, 2015, 6:23:49 AM2/20/15
to
I took this as a fun challenge. Here is my result. It isn't super fast, but seems to work ok.
here's hoping I didn't screw anything up when adding the // comments in the text editor...

10 DIM W%(10): DIM H%(10): DIM X%(10): DIM Y%(10): DIM M%(40,24)
// init map to '#' walls
15 C = ASC ("#"): FOR I = 1 TO 40: FOR J = 1 TO 24:M%(I,J) = C: NEXT J: NEXT I
// C is room character, T is tunnel character (same char is ok)
16 C = ASC ("~"):T = ASC (".")
// number of rooms
20 NR% = 3 * RND (1) + 3 * RND (1) + 3
30 FOR I = 1 TO NR%
// width, height, xpos, ypos
40 W%(I) = 3 * RND (1) + 3 * RND (1) + 4
50 H%(I) = 2 * RND (1) + 2 * RND (1) + 3
60 X%(I) = (39 - W%(I)) * RND (1) + 2
70 Y%(I) = (23 - H%(I)) * RND (1) + 2
// draw room in map
80 FOR Y = Y%(I) TO Y%(I) + H%(I) - 1
90 FOR X = X%(I) TO X%(I) + W%(I) - 1
100 M%(X,Y) = C
110 NEXT X: NEXT Y
120 NEXT I
// for each room, build a tunnel to another room
200 FOR I = 1 TO NR%
205 PRINT I
// select a goal room
206 R = INT (NR% * RND (1)) + 1
207 IF R = I THEN 206
// pick a side of the room to start from
210 S = INT (4 * RND (1))
// change side if selected side runs off map
220 IF (S = 0) AND (X%(I) = 2) THEN S = 1
230 IF (S = 1) AND (Y%(I) = 2) THEN S = 2
240 IF (S = 2) AND (X%(I) + W%(I) = 40) THEN S = 3
250 IF (S = 3) AND (Y%(I) + H%(I) = 24) THEN S = 0: GOTO 220
// initialize tunnel position vars X & Y
300 IF S = 0 THEN X = X%(I) - 1:Y = INT (H%(I) * RND (1) + Y%(I)): GOTO 350
310 IF S = 1 THEN Y = Y%(I) - 1:X = INT (W%(I) * RND (1) + X%(I)): GOTO 350
320 IF S = 2 THEN X = X%(I) + W%(I):Y = INT (H%(I) * RND (1) + Y%(I)): GOTO 350
330 Y = Y%(I) + H%(I):X = INT (W%(I) * RND (1) + X%(I))
// if current position looks like a win, routine at 600 makes sure it is
350 IF M%(X,Y) = C THEN 600
// "dig" tunnel if necessary
360 IF M%(X,Y) < > C THEN M%(X,Y) = T
// if corridor distance not finished, go finish
365 IF D > 0 GOTO 450
// pick a new direction different than current direction
370 OS = S
371 S = INT (4 * RND (1))
372 IF S = OS GOTO 371
// if new direction is opposite direction from target room, try again
// (without this, too many tunnels going all over the map are generated)
374 IF S = 0 THEN IF X%(R) > X THEN 371
375 IF S = 1 THEN IF Y%(R) > Y THEN 371
376 IF S = 2 THEN IF X%(R) < X THEN 371
377 IF S = 3 THEN IF Y%(R) < Y THEN 371
// if can go no further in the selected direction, turn 90 degrees
380 IF (S = 0) AND (X = 2) THEN S = 1 + 2 * INT (2 * RND (1))
390 IF (S = 1) AND (Y = 2) THEN S = 2 * INT (2 * RND (1)): GOTO 380
400 IF (S = 2) AND (X = 39) THEN S = 1 + 2 * INT (2 * RND (1)): GOTO 390
410 IF (S = 3) AND (Y = 23) THEN S = 2 * INT (2 * RND (1)): GOTO 380
// randomly select a corridor length
420 D = INT (8 * RND (1)) + 4
425 PRINT "S=";S;" D=";D
// extend in the selected direction. if not possible, pick new direction
450 IF S = 0 THEN X = X - 1: IF X = 1 THEN X = X + 1: GOTO 370
460 IF S = 1 THEN Y = Y - 1: IF Y = 1 THEN Y = Y + 1: GOTO 370
470 IF S = 2 THEN X = X + 1: IF X = 40 THEN X = X - 1: GOTO 370
480 IF S = 3 THEN Y = Y + 1: IF Y = 24 THEN Y = Y - 1: GOTO 370
// "dig" tunnel if necessary
490 IF M%(X,Y) < > C THEN M%(X,Y) = T
500 D = D - 1
510 GOTO 350
// check for success (reaching a different room)
600 J = 1
// make sure current location is in a room at all
// (this allows characters C & T to be the same if desired)
610 IF (X < X%(J)) OR (X > = X%(J) + W%(J)) THEN 650
620 IF (Y < Y%(J)) OR (Y > = Y%(J) + H%(J)) THEN 650
// make sure it's a different room
630 IF J = I THEN 650
// succesfully tunneled to a different room
640 GOTO 700
650 J = J + 1: IF J < NR% THEN 610
// didn't find a different room
660 GOTO 360
// make tunnel from next room
700 NEXT I
// print generated map
1000 HOME
1010 FOR Y = 1 TO 24: FOR X = 1 TO 40
1020 PRINT CHR$ (M%(X,Y));
1030 NEXT X: NEXT Y

Marco Verpelli

unread,
Feb 21, 2015, 5:48:11 AM2/21/15
to
10 PRINT CHR$(47+(INT(RND(1)*2)*45)); : GOTO 10

Nick Montfort, Patsy Baudoin, John Bell, Ian Bogost, Jeremy Douglass, Mark C. Marino, Michael Mateas, Casey Reas, Mark Sample, Noah Vawter - 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 (Software Studies)

Marco

mmphosis

unread,
Feb 21, 2015, 1:53:35 PM2/21/15
to

Steve][

unread,
Mar 19, 2015, 12:18:02 PM3/19/15
to

I thought I remembered a kind of roguelike game written in AppleSoft
BASIC that generated a dungeon. Not Moria on the IIGS, but something
8-bit and AppleSoft. Maybe my memory is hazy on that one.

Thanks All!

On Thu, 19 Feb 2015 18:38:38 -0500, "Steve][" <ig...@hotmail.com>
wrote:

Steve Nickolas

unread,
Mar 19, 2015, 2:50:53 PM3/19/15
to
On Thu, 19 Mar 2015, Steve][ wrote:

>
> I thought I remembered a kind of roguelike game written in AppleSoft
> BASIC that generated a dungeon. Not Moria on the IIGS, but something
> 8-bit and AppleSoft. Maybe my memory is hazy on that one.

You mean like Dungeon Campaign?

-uso.

fadden

unread,
Mar 21, 2015, 8:32:49 PM3/21/15
to
On Thursday, March 19, 2015 at 9:18:02 AM UTC-7, Steve][ wrote:
> I thought I remembered a kind of roguelike game written in AppleSoft
> BASIC that generated a dungeon. Not Moria on the IIGS, but something
> 8-bit and AppleSoft. Maybe my memory is hazy on that one.

For a "tight" maze, Dragon Maze (integer BASIC) is a classic example.

For a more Rogue-like game, Don Worth's original Beneath Apple Manor was originally written in BASIC with lo-res graphics. ftp://ftp.apple.asimov.net/pub/apple_II/images/games/adventure/beneath_apple_manor/ seems to have various versions, including the original.

(And, according to Wikipedia, it pre-dates Rogue by a couple of years.)

fadden

unread,
Mar 22, 2015, 11:49:41 AM3/22/15
to
On Saturday, March 21, 2015 at 5:32:49 PM UTC-7, fadden wrote:
a more Rogue-like game, Don Worth's original Beneath Apple Manor was originally written in BASIC with lo-res graphics. ftp://ftp.apple.asimov.net/pub/apple_II/images/games/adventure/beneath_apple_manor/ seems to have various versions, including the original.
>
> (And, according to Wikipedia, it pre-dates Rogue by a couple of years.)

...and I'm apparently a bit behind on current events...

http://www.6502lane.net/2015/03/16/source-code-and-distribution-images-for-don-worths-beneath-apple-manor/
0 new messages