Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collection of Mazes
#1
Hi,

Find attached a collection of maze programs.

Erik.


Attached Files
.zip   MAZES.ZIP (Size: 13.22 KB / Downloads: 34)
Reply
#2
basically 3 programs, one is old one liner psuedo maze generator, another is pretty good maze generator but takes too many loc and third is old ansii maze style that is variation of amazing in basic games collection of david alh but works ;-))
b = b + ...
Reply
#3
(06-16-2024, 01:47 PM)bplus Wrote: basically 3 programs, one is old one liner psuedo maze generator, another is pretty good maze generator but takes too many loc and third is old ansii maze style that is variation of  amazing in basic games collection of david alh but works ;-))
Thank you for noticing! If you want more 16-bit DOS programs I have older stuff that goes way back into the 1980s.. Smile
Reply
#4
(06-16-2024, 01:47 PM)bplus Wrote: basically 3 programs, one is old one liner psuedo maze generator, another is pretty good maze generator but takes too many loc and third is old ansii maze style that is variation of  amazing in basic games collection of david alh but works ;-))
Are they 3 different algorithms? 
When I get to the PC, I'll compare them with a couple I was using. 
Has anyone seen any "procedural dungeon generator" ones? 
(ie not really mazes, more like a bunch of rooms connected by passages, some of which may be maze-like)
Reply
#5
this is almost the one-liner other basic's could do
Code: (Select All)
_Font 8
10 Print Mid$("/\", Rnd * 2 + 1, 1);: GoTo 10

that was expanded to this in oldmaze.bas
Code: (Select All)
Dim Shared MainWindow As Long
Dim Shared Commodore64Screen As Long
MainWindow = _NewImage(768, 496, 32)
Commodore64Screen = _NewImage(320, 200, 32)
Screen MainWindow
_Title "Never Ending Maze"
_Font 8
Cls , _RGB32(112, 91, 207)
_Dest Commodore64Screen
Cls , _RGB32(52, 30, 149)
Color _RGB32(112, 91, 207), _RGB32(52, 30, 149)
_Font 8
Do
    _Limit 30
    For i = 1 To 13
        Print Mid$("/\", Rnd * 2 + 1, 1);
    Next
    _PutImage (64, 48)-(704, 448), Commodore64Screen, MainWindow
    _Display
    k& = _KeyHit
Loop Until k& = 27
System

here is whole folder but as i said only 3 basic kinds of mazes
   

here is standard graphics version
   

and one of many ascii versions
   
b = b + ...
Reply
#6
Quote:Has anyone seen any "procedural dungeon generator" ones?
(ie not really mazes, more like a bunch of rooms connected by passages, some of which may be maze-like)

i remember steve the amazing starting something like that years ago probably buried away like my little ascii thingy i started on jb years ago just helping someone else get started.
b = b + ...
Reply
#7
(06-18-2024, 12:37 AM)bplus Wrote:
Quote:Has anyone seen any "procedural dungeon generator" ones?
(ie not really mazes, more like a bunch of rooms connected by passages, some of which may be maze-like)

i remember steve the amazing starting something like that years ago probably buried away like my little ascii thingy i started on jb years ago just helping someone else get started.

For my Rogue-Like generator.  Wink   

The basic concept was very simple:

1) Choose 2 points inside your rooms.   (The x/y coordinates for the center, if you like.)
2) Now, all you have to do is draw a straight line from point A to point B -- that would be the easiest road to how to get there.

Problem with step 2 is that's not very "dungon like".   So instead, install a variance to that path as you generate it.

Start at the first point, in the first room
DO
  meander = RND * 100
  Select Case meander
     CASE 0 to 10:  Wander the path north
     CASE 11 to 20:  Wander the path south
     CASE 21 to 30:  Wander the path east
     CASE 31 to 40:  Wander the path west
     CASE 41 to 60:  Keep wandering in the last direction 2 more steps
     CASE ELSE:    Course correct and head directly towards the 2nd point. 
  END SELECT
LOOP

By traveling towards your goal with the CASE ELSE, you'll eventually get to where you want to go.   Adjust the values for how much meandering you want to do with the path, before you get there.



And the way you make criss-crossing paths is by making sure rooms connect sequentially, but you make and place the rooms at random.

Example:  

Room 1 is in the upper right corner.
Room 2 is in the lower left corner.
Room 3 is in the middle left.
Room 4 is in the middle right.

You would now wander roughly SE from room 1 to room 2.   Then roughly north to room 3.   Then roughly east to room 4 -- and this path should automatically transverse the path from room 1 to room 2, now giving you an intersection.



Really, very simple logic at the end of the day.  The end user won't know how you made those paths, and when playing, they'll look like "dungeon tunnels" for the most part.  Wink
Reply
#8
(06-18-2024, 12:53 AM)SMcNeill Wrote:
(06-18-2024, 12:37 AM)bplus Wrote:
Quote:Has anyone seen any "procedural dungeon generator" ones?
(ie not really mazes, more like a bunch of rooms connected by passages, some of which may be maze-like)

i remember steve the amazing starting something like that years ago probably buried away like my little ascii thingy i started on jb years ago just helping someone else get started.

For my Rogue-Like generator.  Wink   

The basic concept was very simple:

1) Choose 2 points inside your rooms.   (The x/y coordinates for the center, if you like.)
2) Now, all you have to do is draw a straight line from point A to point B -- that would be the easiest road to how to get there.

Problem with step 2 is that's not very "dungon like".   So instead, install a variance to that path as you generate it.

Start at the first point, in the first room
DO
  meander = RND * 100
  Select Case meander
     CASE 0 to 10:  Wander the path north
     CASE 11 to 20:  Wander the path south
     CASE 21 to 30:  Wander the path east
     CASE 31 to 40:  Wander the path west
     CASE 41 to 60:  Keep wandering in the last direction 2 more steps
     CASE ELSE:    Course correct and head directly towards the 2nd point. 
  END SELECT
LOOP

By traveling towards your goal with the CASE ELSE, you'll eventually get to where you want to go.   Adjust the values for how much meandering you want to do with the path, before you get there.



And the way you make criss-crossing paths is by making sure rooms connect sequentially, but you make and place the rooms at random.

Example:  

Room 1 is in the upper right corner.
Room 2 is in the lower left corner.
Room 3 is in the middle left.
Room 4 is in the middle right.

You would now wander roughly SE from room 1 to room 2.   Then roughly north to room 3.   Then roughly east to room 4 -- and this path should automatically transverse the path from room 1 to room 2, now giving you an intersection.



Really, very simple logic at the end of the day.  The end user won't know how you made those paths, and when playing, they'll look like "dungeon tunnels" for the most part.  Wink

Pretty neat, that'll be fun to play with. Thanks!

(06-18-2024, 12:24 AM)bplus Wrote: this is almost the one-liner other basic's could do
Code: (Select All)
_Font 8
10 Print Mid$("/\", Rnd * 2 + 1, 1);: GoTo 10

that was expanded to this in oldmaze.bas
Code: (Select All)
Dim Shared MainWindow As Long
Dim Shared Commodore64Screen As Long
MainWindow = _NewImage(768, 496, 32)
Commodore64Screen = _NewImage(320, 200, 32)
Screen MainWindow
_Title "Never Ending Maze"
_Font 8
Cls , _RGB32(112, 91, 207)
_Dest Commodore64Screen
Cls , _RGB32(52, 30, 149)
Color _RGB32(112, 91, 207), _RGB32(52, 30, 149)
_Font 8
Do
    _Limit 30
    For i = 1 To 13
        Print Mid$("/\", Rnd * 2 + 1, 1);
    Next
    _PutImage (64, 48)-(704, 448), Commodore64Screen, MainWindow
    _Display
    k& = _KeyHit
Loop Until k& = 27
System

here is whole folder but as i  said only 3 basic kinds of mazes

here is standard graphics version

and one of many ascii versions
The one I had was like the ascii version, but allows specifying how many spaces wide the passages are. It might be better to include an option to vary how wide the passages are at random points, or have it generate rooms here and there, within the maze. I didn't make it to the computer tonight - maybe tomorrow I'll play with these!
Reply
#9
(06-18-2024, 02:09 AM)madscijr Wrote: Pretty neat, that'll be fun to play with. Thanks!

A quick and dirty demo of what I'm talking about for you:

Code: (Select All)
CONST ToggleMeander = -1

RANDOMIZE TIMER
$COLOR:32
DIM Map(50, 50) AS LONG 'let's create a 50x50 grid for our "dungeon"
DIM SHARED gridsize AS LONG
SCREEN _NEWIMAGE(801, 801, 32)
gridsize = 800 / UBOUND(Map)

roomcount = 6
roomsize_min = 1
roomsize_max = 3

DO
CLS
FOR x = 0 TO 800 STEP gridsize 'draw the grid
LINE (x, 0)-(x, 800), LightGray
LINE (0, x)-(800, x), LightGray
NEXT

FOR i = 1 TO roomcount
x1 = INT(RND * 40) + 5: y1 = INT(RND * 40) + 5
roomsize = (INT(RND * roomsize_max + roomsize_min)) * gridsize
'Draw the rooms
LINE (x1 * gridsize - roomsize, y1 * gridsize - roomsize)-_
((x1+1) * gridsize + roomsize , (y1+1) * gridsize + roomsize), Cyan, BF
'draw the center of these rooms
LINE (x1 * gridsize, y1 * gridsize)-STEP(16, 16), Red, BF

IF lastx <> 0 THEN
IF ToggleMeander = 0 THEN
'draw the directpath between these rooms in green
directpath x1, y1, lastx, lasty
ELSE
'draw a meandering path between these two points
MeanderingPath x1, y1, lastx, lasty
END IF
END IF
lastx = x1: lasty = y1
SLEEP
NEXT
lastx = 0: lasty = 0
SLEEP
LOOP

SUB directpath (tx1, ty1, tx2, ty2)
x1 = tx1: y1 = ty1: x2 = tx2: y2 = ty2 'preserve our orignal values without changing them.
DO
rise = x2 - x1
runn = y2 - y1
chance = ABS(rise) + ABS(runn)
roll = INT(RND * chance) + 1
IF roll < ABS(rise) THEN
x1 = x1 + SGN(rise)
ELSE
y1 = y1 + SGN(runn)
END IF
LINE (x1 * gridsize, y1 * gridsize)-STEP(16, 16), Green, BF
LOOP UNTIL chance = 1
END SUB

SUB MeanderingPath (tx1, ty1, tx2, ty2)

x1 = tx1: y1 = ty1: x2 = tx2: y2 = ty2 'preserve our orignal values without changing them.
DO
chance = INT(RND * 100) + 1
SELECT CASE chance
CASE IS <= 20: x1 = x1 + 1
CASE IS <= 40: y1 = y1 + 1
CASE IS <= 60: x1 = x1 - 1
CASE IS <= 80: y1 = y1 - 1
CASE ELSE
rise = x2 - x1
runn = y2 - y1
chance = ABS(rise) + ABS(runn)
roll = INT(RND * chance) + 1
IF roll < ABS(rise) THEN
x1 = x1 + SGN(rise)
ELSE
y1 = y1 + SGN(runn)
END IF
END SELECT
'stay in bounds of the map
IF x1 < 0 THEN x1 = 0
IF x1 > 50 THEN x1 = 50
IF y1 < 0 THEN y1 = 0
IF y1 > 50 THEN y1 = 50
LINE (x1 * gridsize, y1 * gridsize)-STEP(16, 16), Purple, BF
LOOP UNTIL ABS(x1 - x2) <= 1 AND ABS(y1 - y2) <= 1
END SUB

Toggle that first CONST and you can see the difference between a direct path from the center of one room to another, and a meandering path.

Change those values in the SELECT CASE for the SUB MeanderingPath, and you can alter how much it deviates from that basic direct path.

I tried to use color for this to showcase the room (blue), center of room (red), direct path (green), and wandering path (purple), but that wandering path tends to wander and cover up everything else if you're not careful. LOL! Try it imagine it all being one set color for your "dungeon" or "rogue-like play area", and you should be able to see how this creates a map very much like Rogue used to back in the days.

One thing I'd suggest to make this a ton better -- check to make certain the rooms don't overlap each other. The further apart the rooms are, the more room the paths have to stretch out and crisscross and such. Touching rooms kind of defeats the purpose of building roads between them. Smile
Reply
#10
(06-18-2024, 06:34 AM)SMcNeill Wrote:
(06-18-2024, 02:09 AM)madscijr Wrote: Pretty neat, that'll be fun to play with. Thanks!
A quick and dirty demo of what I'm talking about for you:

...

Toggle that first CONST and you can see the difference between a direct path from the center of one room to another, and a meandering path.

Change those values in the SELECT CASE for the SUB MeanderingPath, and you can alter how much it deviates from that basic direct path.

I tried to use color for this to showcase the room (blue), center of room (red), direct path (green), and wandering path (purple), but that wandering path tends to wander and cover up everything else if you're not careful.  LOL!  Try it imagine it all being one set color for your "dungeon" or "rogue-like play area", and you should be able to see how this creates a map very much like Rogue used to back in the days.

One thing I'd suggest to make this a ton better -- check to make certain the rooms don't overlap each other.  The further apart the rooms are, the more room the paths have to stretch out and crisscross and such.  Touching rooms kind of defeats the purpose of building roads between them.  Smile
I like the presentation with the grid lines, and that it waits for you to press a key before going on to the next step. 
I'll play with it some more later. Thank you!
Reply




Users browsing this thread: 1 Guest(s)