Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need help improving my random 2d dungeon creator

Author
Message
Ranietz
AGK Gold Backer
21
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 4th Feb 2011 18:04
Hi.

I'm making a random 2d dungeon creator and I need some help improving it. It just creates corridors, rooms and doors for now and it works as it should except the door placement isn't good enough. I've attached a screen shot so you can see what I mean. (to many doors at the end of the corridors)
I found a way to improve the door placement but it's to slow for my liking (it's included in the code).

So if anyone have some suggestions for how I can improve my code I'll be very happy. I'll also appreciate comments of other areas to improve my code.

Here's the code. I've tried to clean it up an comment it as much as I could.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 4th Feb 2011 18:35 Edited at: 4th Feb 2011 18:36
Maybe you aren't removing the wall when placing a door. Seems that doors are counting as walls, and you need some Dim that puts a hole there. But errr the code is too long for me to completely get to grips with.

Ranietz
AGK Gold Backer
21
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 4th Feb 2011 18:53
No, Pincho Paxton. That's not the problem. When I insert a door the wall gets replaced by that door.

I know I should try to explain the problem a bit better but English is not my native language and it's not easy for me to express my self in written language...
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Feb 2011 19:26 Edited at: 4th Feb 2011 19:27
Why not just use the remed off code in the "find dead end corridors" area? It may be slower (I didn't really notice it being slow) but it reduces the number of doors like crazy.

This area:


Ranietz
AGK Gold Backer
21
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 4th Feb 2011 19:48 Edited at: 4th Feb 2011 19:55
The reason I'm not using it is because I want to be able to make really big dungeons.
It takes about 2 seconds to create a 255x187 dungeon using the fast way of inserting doors but it takes 12 seconds using the slower but better way. (at least on my old Pentium 4 computer)

Edit: The reason it takes so much longer using the "better" way is because the dungeon gets to many unconnected areas and the flood fill routine takes so much longer connecting it all back together.

Login to post a reply

Server time is: 2026-07-18 02:09:13
Your offset time is: 2026-07-18 02:09:13