Jump to content
IGNORED

Plotting a dungeon


Opry99er

Recommended Posts

Okay, so I've been reading Matthew's old page on maze generation and I've also been reading through the thread on Berylrogue.

 

http://digitalstratu...ng/hkmaze_ti_xb

 

The above link takes you to Matthew's explanation of how he developed his HK maze... It's very well explained and I learned quite a bit from it. I am, however, looking to develop a different kind of maze... a "dungeon" so to speak.

 

I am hoping to create something like Codex's "Helm of Wooldridge" dungeon.... not so much a "Hunt and Kill" map. Essentially, I want 4 chambers (+-) and paths going between them. My first step is to plot 4 random points on the screen... So I came up with a little program to do that. This plots a point, displays the coordinates onscreen, creates a "chamber", holds for a moment, then plots the next point, repeat.

 

90 CALL CHAR(64,"FFFFFFFFFFFFFFFF")
100 CALL CLEAR
110 RANDOMIZE
120 FOR LP=1 TO 4
130 X=INT(RND*32)+1
131 IF X>28 THEN X=28
132 IF X<4 THEN X=4
140 Y=INT(RND*24)+1
141 IF Y<4 THEN Y=4
142 IF Y>19 THEN Y=19
150 DISPLAY AT(Y,X):"@";
155 DISPLAY AT(21,2):Y;:: DISPLAY AT(21,;
156 CALL HCHAR((Y-1),(X-1),64,6):: CALL HCHAR(Y,(X-1),64,6):: CALL HCHAR((Y+1),(X-1),64,6):: CALL HCHAR((Y+2),(X-1),64,6)
158 FOR I=1 TO 500 :: NEXT I
160 NEXT LP
170 GOTO 170

 

 

This creates 4 rectangular chambers onscreen... so, I need to figure out how to "plot" the passageways between them... I'm continuing to work on this, but I could use a bit of help. =) Thanks. and please try the code so you can see what I'm doing. I know it's inefficient right now, but I'm trying. Am I even on the right track? I know actually rendering the chambers should be better than this... (LINE 156), but that's my best guess at first try. Thanks guys.

 

 

dunplot.jpg

Edited by Opry99er
Link to comment
Share on other sites

I don't know if this helps, but 1 roguelike I worked on that had random dungeons, I first draw the random maze, make it a sparse maze with few off shoots. Then I randomly pick points on the maze path and draw a room on it. Some times I wanted a small passage to the room, just 1 square so I found a path first that and then moved a square away then make the room.

 

You can make random room sizes this way to, just fill the area you have available.

1 maze
***************
         *
         *
         *
         *
      ********
        *
        ****

2 add rooms
***************
 *       *  
***      *  ****
***      *  ****
***      *   *
   ***********
   ***   *
   ***   *******
             ***
             ***

Edited by jchase1970
Link to comment
Share on other sites

Well, a couple things... I don't MIND the overlap, but I would prefer to stay seperate.

 

John, to your point... That seems like a very clean way to accomplish the goal... But I'm not 100% sure how to create random path directions... Will they all be straight, no turns?

 

I'm new to the concept... Adamantyr, Matthew, Codex, and a few others have given me good advice in the past, but I'm just now trying to tie all that in together. This is my first crack. =)

Link to comment
Share on other sites

Here's a good thing to try:

 

1) Step away from the computer

2) Get a nice pad of graph paper... 4-5 squares an inch is ideal

3) Draw your 32x24 size border area, a 8.5x11 sheet of paper is well big enough for this

4) Start designing an "ideal" dungeon, one that you want your program to make

5) Look at what you drew, and start asking why you drew this chamber here, that passage there, etc.

 

Basically, what you're looking for is the PROCESS of maze development. Then you just write down the code to support it.

 

Adamantyr

Link to comment
Share on other sites

Well, a couple things... I don't MIND the overlap, but I would prefer to stay seperate.

You could check the screen before drawing a chamber. All 4 corners have to be checked. If any of the corners are already taken then try a new random chamber. This will avoid overlapping.

 

Check all 4 corners, and move one character away from the centre of the chamber in both directions (horizontal and vertical). This will avoid overlapping and touching.

 

Another approach, which is not all that random is achieved by dividing the screen into 4 sections (this could even be random). Each section will hold a chamber at a random position. Divide the screen like this

 

chambers.png

 

The red bands do not exist, but you just avoid having any chambers there.

Edited by sometimes99er
Link to comment
Share on other sites

@adamantyr--- just printed some graph paper. =) I used to do ALL my graphics design on graph paper...

 

@sometimes--- thanks man. I like the first option best, more random.

 

This is all testing... I want to UNDERSTAND the process first, then I want to move that over to assembly. I won't be using a screen-by-screen basis, I don't think... I think I will plot an 80x80 MAP using these same algorithms I learn here and use a viewport. The way I do it on screen in this learning example won't be too different than plotting it on a larger scale map... However, I may be missing the point. =)

Link to comment
Share on other sites

@sometimes--- thanks man. I like the first option best, more random.

You should check out the second approach. It will appear nice and random to the player (he doesn't see the red bands). And the chambers are drawn quickly based on 2 random numbers, no checking. Easy to do - apart from a bit of math.

 

:)

Edited by sometimes99er
Link to comment
Share on other sites

Works Great, sometimes99er, thank you. =) I don't understand precisely what your code is doing... as there is a bunch of math I don't quite understand, but I made a video of it working. =)

 

http://www.youtube.com/watch?v=lcxxnL61eS0

 

I imagine I'll be spending the next couple hours figuring out precisely how this works and then learning to plot passageways. I really like jchase's maze file he posted... That's almost exactly what I'm looking to create for BerylRogue.

Link to comment
Share on other sites

Thanks John. I've seen Codex's method for Helm, adamantyr's method for Dark Maze, Matthew's HK design and blog about the creation of it... I guess I'm still letting it all sink in. I'm trying my own right now but seem to be failing over and over. =) Finally got the points for rooms to plot properly, but it's still not anywhere near an algorithm... I've tried taking the loop counter and turning it into a string variable with an "X" or "Y" to store where the points are... from there I planned to SEG$ them back into numeric variables and use them for designing my passageways, but I have ended up in failure 3 or 4 times so far today. I'm not giving up though. =) Gotta make it happen.... I hope whatever I come up with is at least moderately easy to translate into assembly, because this game will be created in that language. =) Although, it wouldn't hurt to make a whole program in XB just to get it moving. I'll keep you guys updated. In the meantime, John, I look forward to seeing what you designed. =)

Link to comment
Share on other sites

Hey adamantyr,

I started thinking about what I did when I drew that maze, and here's what the process was.

 

I started with a chamber in the top left corner... I then drew a passageway going south from the chamber. That passageway then split once, then one fork went into another chamber, the other split from there and the process continued. I noticed that I always had one main passageway from which all the rooms and other passageways eminated. The end of the maze ended up at the top right corner.

 

One other point of note... I tried to always keep the passageways close to the other rooms and passageways--- maximization of space...

 

So on that note... I suppose I need to "code-ify" that process. =)

Link to comment
Share on other sites

I started with one chamber and drew two passageways, one to the right, one to the bottom... This isn't very random... only the location of the initial chamber is random. It's just another step, that's all... I'll be updating THIS particular post with code as I get further along.

 

 

 

90 CALL CHAR(64,"FFFFFFFFFFFFFFFF")
100 CALL CLEAR
110 RANDOMIZE
130 X=INT(RND*32)+1
131 IF X>28 THEN X=28
132 IF X<4 THEN X=4
140 Y=INT(RND*24)+1
141 IF Y<4 THEN Y=4
142 IF Y>19 THEN Y=19
150 DISPLAY AT(Y,X):"@";
156 CALL HCHAR((Y-1),(X-1),64,6):: CALL HCHAR(Y,(X-1),64,6):: CALL HCHAR((Y+1),(X-1),64,6):: CALL HCHAR((Y+2),(X-1),64,6)
158 FOR I=1 TO 500 :: NEXT I
160 CALL HCHAR(Y,X,64,(31-X))

170 CALL VCHAR(Y,X,64,(23-Y))

180 GOTO 180

 

 

 

mazealg.jpg

Edited by Opry99er
Link to comment
Share on other sites

ok 2hrs later and


5 RANDOMIZE
10 CALL CHAR(33,"8888FF222222FF88")
20 CALL CHAR(34,"108004200108A002")
30 CALL HCHAR(1,1,33,768)
40 START=INT(RND*10)+1
50 ON START GOTO 60,61,62,63,64,65,66,67,68,69
60 CALL VCHAR(1,6,34,6):: GOTO 70
61 CALL VCHAR(1,16,34,6):: GOTO 70
62 CALL VCHAR(1,27,34,6):: GOTO 70
63 CALL HCHAR(7,27,34,6):: GOTO 70
64 CALL HCHAR(18,27,34,6):: GOTO 70
65 CALL VCHAR(18,27,34,6):: GOTO 70
66 CALL VCHAR(18,16,34,6):: GOTO 70
67 CALL VCHAR(18,6,34,6):: GOTO 70
68 CALL HCHAR(18,1,34,6):: GOTO 70
69 CALL HCHAR(7,1,34,6):: GOTO 70
70 DIM ROOM(6)
71 ROOM(1)=1
72 E=INT(RND*3)+1
73 IF E=1 OR E=3 THEN CALL HCHAR(7,6,34,11):: ROOM(2)=1
74 IF E=2 OR E=3 THEN CALL VCHAR(7,6,34,12):: ROOM(4)=1
75 E=INT(RND*6)+1
76 IF E=1 OR E=4 OR E=5 THEN CALL HCHAR(7,6,34,11):: ROOM(2)=1
77 IF E=2 OR E=4 OR E=6 THEN CALL HCHAR(7,16,34,12):: IF ROOM(2)=1 THEN ROOM(3)=1
78 IF E=3 OR E=5 OR E=6 THEN CALL VCHAR(7,16,34,12):: IF ROOM(2)=1 THEN ROOM(5)=1
79 E=INT(RND*3)+1
80 IF E=1 OR E=3 THEN CALL HCHAR(7,16,34,11):: IF ROOM(2)=1 THEN ROOM(3)=1
81 IF E=2 OR E=3 THEN CALL VCHAR(7,27,34,12):: IF ROOM(2)=1 THEN ROOM(6)=1
82 E=INT(RND*3)+1
83 IF E=1 OR E=3 THEN CALL VCHAR(7,6,34,11):: ROOM(4)=1
84 IF E=2 OR E=3 THEN CALL HCHAR(18,6,34,12):: IF ROOM(4)=1 THEN ROOM(5)=1
85 E=INT(RND*6)+1
86 IF E=1 OR E=4 OR E=5 THEN CALL HCHAR(18,6,34,11):: IF ROOM(4)=1 THEN ROOM(5)=1
87 IF E=3 OR E=4 OR E=6 THEN CALL HCHAR(18,16,34,12):: IF ROOM(5)=1 THEN ROOM(6)=1
88 IF E=2 OR E=5 OR E=6 THEN CALL VCHAR(7,16,34,12):: IF ROOM(2)=1 THEN ROOM(5)=1
89 E=INT(RND*3)+1
90 IF E=1 OR E=3 THEN CALL VCHAR(7,27,34,11):: IF ROOM(3)=1 THEN ROOM(6)=1
91 IF E=2 OR E=3 THEN CALL HCHAR(18,16,34,12):: IF ROOM(5)=1 THEN ROOM(6)=1
100 IF ROOM(2)=0 THEN CALL HCHAR(7,6,34,11):: ROOM(2)=1
110 IF ROOM(4)=0 THEN CALL VCHAR(7,6,34,12):: ROOM(4)=1
120 EXIT=INT(RND*10)+1
130 IF EXIT=START THEN 120
150 ON EXIT GOTO 160,161,162,163,164,165,166,167,168,169
160 CALL VCHAR(1,6,34,6):: GOTO 200
161 CALL VCHAR(1,16,34,6):: GOTO 200
162 CALL VCHAR(1,27,34,6):: GOTO 200
163 CALL HCHAR(7,27,34,6):: GOTO 200
164 CALL HCHAR(18,27,34,6):: GOTO 200
165 CALL VCHAR(18,27,34,6):: GOTO 200
166 CALL VCHAR(18,16,34,6):: GOTO 200
167 CALL VCHAR(18,6,34,6):: GOTO 200
168 CALL HCHAR(18,1,34,6):: GOTO 200
169 CALL HCHAR(7,1,34,6):: GOTO 200
200 IF INT(RND*100)+1>50 THEN 202
201 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(5+Y+L,4+X,34,5):: NEXT L
202 IF INT(RND*100)+1>50 THEN 204
203 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(5+Y+L,14+X,34,5):: NEXT L
204 IF INT(RND*100)+1>50 THEN 206
205 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(5+Y+L,25+X,34,5):: NEXT L
206 IF INT(RND*100)+1>50 THEN 208
207 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(16+Y+L,4+X,34,5):: NEXT L
208 IF INT(RND*100)+1>50 THEN 210
209 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(16+Y+L,14+X,34,5):: NEXT L
210 IF INT(RND*100)+1>50 THEN 250
211 X=2-INT(RND*5):: Y=2-INT(RND*5):: FOR L=0 TO 4 :: CALL HCHAR(16+Y+L,25+X,34,5):: NEXT L
250 GOTO 30

 

I made it draw random paths and upto 6 random rooms with random offset placements.

The start path and exit path are random but could be programed easy for a set route.

Link to comment
Share on other sites

paste these lines in to not see the maze make but to just have it pop up.

20 call char(34,"8888FF222222FF88")
240 call char(34,"108004200108A002")
245 for l=1 to 400::next l
250 goto 20

 

here also is my development pad with the comments to help understand it

 

 

5 randomize

rem chars

rem wall

10 call char(33,"8888FF222222FF88")

rem floor

20 call char(34,"108004200108A002")

rem draw all walls

30 call hchar(1,1,33,768)

 

rem pick start point 10 possible

40 start=int(rnd*10)+1

50 on start goto 60,61,62,63,64,65,66,67,68,69

rem draw 1st path

60 call vchar(1,6,34,6)::goto 70

61 call vchar(1,16,34,6)::goto 70

62 call vchar(1,27,34,6)::goto 70

63 call hchar(7,27,34,6)::goto 70

64 call hchar(18,27,34,6)::goto 70

65 call vchar(18,27,34,6)::goto 70

66 call vchar(18,16,34,6)::goto 70

67 call vchar(18,6,34,6)::goto 70

68 call hchar(18,1,34,6)::goto 70

69 call hchar(7,1,34,6)::goto 70

 

 

rem make stack of 6 possible rooms to connect

70 dim room(6)

rem 1st room is connected to self

71 room(1)=1

rem room 1 has 2 possible exits

72 e=int(rnd*3)+1

73 if e=1 or e=3 then call hchar(7,6,34,11)::room(2)=1

74 if e=2 or e=3 then call vchar(7,6,34,12)::room(4)=1

rem room 2 has 3 possible exits

75 e=int(rnd*6)+1

76 if e=1 or e=4 or e=5 then call hchar(7,6,34,11)::room(2)=1

77 if e=2 or e=4 or e=6 then call hchar(7,16,34,12)::if room(2)=1 then room(3)=1

78 if e=3 or e=5 or e=6 then call vchar(7,16,34,12)::if room(2)=1 then room(5)=1

rem room 3 has 2 possible exits

79 e=int(rnd*3)+1

80 if e=1 or e=3 then call hchar(7,16,34,11)::if room(2)=1 then room(3)=1

81 if e=2 or e=3 then call vchar(7,27,34,12)::if room(2)=1 then room(6)=1

rem room 4 has 2 possible exits

82 e=int(rnd*3)+1

83 if e=1 or e=3 then call vchar(7,6,34,11)::room(4)=1

84 if e=2 or e=3 then call hchar(18,6,34,12)::if room(4)=1 then room(5)=1

rem room 5 has 3 possible exits

85 e=int(rnd*6)+1

86 if e=1 or e=4 or e=5 then call hchar(18,6,34,11)::if room(4)=1 then room(5)=1

87 if e=3 or e=4 or e=6 then call hchar(18,16,34,12)::if room(5)=1 then room(6)=1

88 if e=2 or e=5 or e=6 then call vchar(7,16,34,12)::if room(2)=1 then room(5)=1

rem room 6 has 2 possible exits

89 e=int(rnd*3)+1

90 if e=1 or e=3 then call vchar(7,27,34,11)::if room(3)=1 then room(6)=1

91 if e=2 or e=3 then call hchar(18,16,34,12)::if room(5)=1 then room(6)=1

 

rem are some not connected

100 if room(2)=0 then call hchar(7,6,34,11)::room(2)=1

110 if room(4)=0 then call vchar(7,6,34,12)::room(4)=1

 

rem make exit path

120 exit=int(rnd*10)+1

130 if exit=start then 120

150 on exit goto 160,161,162,163,164,165,166,167,168,169

rem draw 1st path

160 call vchar(1,6,34,6)::goto 200

161 call vchar(1,16,34,6)::goto 200

162 call vchar(1,27,34,6)::goto 200

163 call hchar(7,27,34,6)::goto 200

164 call hchar(18,27,34,6)::goto 200

165 call vchar(18,27,34,6)::goto 200

166 call vchar(18,16,34,6)::goto 200

167 call vchar(18,6,34,6)::goto 200

168 call hchar(18,1,34,6)::goto 200

169 call hchar(7,1,34,6)::goto 200

 

rem 50% chance per room

rem room 1

200 if int(rnd*100)+1>50 then 202

201 x=2-int(rnd*5)::y=2-int(rnd*5)::FOR l=0 TO 4::call hchar(5+y+l,4+x,34,5)::NEXT l

rem room 2

202 if int(rnd*100)+1>50 then 204

203 x=2-int(rnd*5)::y=2-int(rnd*5)::for l=0 to 4::call hchar(5+y+l,14+x,34,5)::next l

rem room 3

204 if int(rnd*100)+1>50 then 206

205 x=2-int(rnd*5)::y=2-int(rnd*5)::for l=0 to 4::call hchar(5+y+l,25+x,34,5)::next l

rem room 4

206 if int(rnd*100)+1>50 then 208

207 x=2-int(rnd*5)::y=2-int(rnd*5)::for l=0 to 4::call hchar(16+y+l,4+x,34,5)::next l

rem room 5

208 if int(rnd*100)+1>50 then 210

209 x=2-int(rnd*5)::y=2-int(rnd*5)::for l=0 to 4::call hchar(16+y+l,14+x,34,5)::next l

rem room 6

210 if int(rnd*100)+1>50 then 250

211 x=2-int(rnd*5)::y=2-int(rnd*5)::for l=0 to 4::call hchar(16+y+l,25+x,34,5)::next l

 

250 goto 30

 

 

 

 

20 call char(34,"8888FF222222FF88")

240 call char(34,"108004200108A002")

245 for l=1 to 400::next l

250 goto 20

 

 

 

bug fix

6 dim room(6)

70 for i=1 to 6::room(i)=0::next i

80 if e=1 or e=3 then call hchar(7,16,34,12)::if room(2)=1 then room(3)=1

86 if e=1 or e=4 or e=5 then call hchar(18,6,34,12)::if room(4)=1 then room(5)=1

Edited by jchase1970
Link to comment
Share on other sites

definitely cool man... I've looked over your comments, and I like this method. Very interesting. =) I am going to try to write my own, but I will more than likely end up using some of your mathematical functions. This is certainly efficient. It's interesting that you start with a possible 10 starting points that start a passageway, rather than beginning with a room. =) Certainly a different method than I was shooting for initially.

 

I'm going to play with your code a bit and see what I can incorporate into my own efforts. I'm quite a ways away from having a successful algorithm, but seeing your code is giving me some ideas for how to proceed, thank you. =)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...