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.

Code Snippets / [DBP] - maze generator

Author
Message
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 14th Mar 2011 05:46
Depth first search maze generator

change the variables w for width and h for height!
pix:
completed maze


during generation


Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 14th Mar 2011 05:47
ARGH! wth? gorrdddm ms paint compression

SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 14th Mar 2011 07:35 Edited at: 14th Mar 2011 07:39
You sir are one of my biggest heros. Bill gates, john remero, lee bamber, you

Nice program by the way

__________________________________________

My software never has bugs. It just develops random features.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 15th Mar 2011 04:41
w00t, made another version that's better for caves. PLUS I've been playing with probabilities - so that if you press the space bar while the maze is generating, the path is more likely to move towards your mouse! I also made it so that you can't see the walls in between cells. Basically, I was going for something to generate cave looking things. As it is, the program is a useful 2d dungeon generator. Each part of the map that's white should be open space - and you can take a screenshot of the thing and save it to a bitmap or something! (not the absolute most efficient way to store stuff, but whatever!)





Quote: "You sir are one of my biggest heros. Bill gates, john remero, lee bamber, you"


This made my day. You inspired me to try to do something I had on my mind for a while... I was going to make a program to create "squigs" as defined in mandelbrot's book the fractal geometry of nature BUT... I'm running into what I'm pretty sure is DBPro-side bugs (Well, not to say my program isn't bugless, but I couldn't debug it because the dang thing didn't work at all! I posted 'bout it in the dbpro board). So... I'm porting teh stuff to C++ and adding some extra features/better code structure. I'll definitely post the results on this thread when I'm done!

SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 15th Mar 2011 05:19
I'm glad that found my comment inspiring and I'm glad you decided too make another awesome program . The new project sounds really interesting, could you provide an image of a "squig" or a resource describing it in detail, I don't have access to the book you mentioned above but I will be sure to look for it on my next trip to a book store. Google gave me no results related too geometry, fractal or otherwise.

__________________________________________

My software never has bugs. It just develops random features.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 15th Mar 2011 16:34 Edited at: 15th Mar 2011 16:35
Squigs are... self avoiding edge sharing continous non-differentiable curves! O.o

I wrote up an article on mah website!
http://www.neurofuzzydev.com/papers/whatsasquig.php

[edit]
oh, yeah, and the pictures are fine, it's just how the forum displays them that messes 'em up.

SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 15th Mar 2011 20:44
Thank you those do look very interesting indeed. I cant wait to see this finished.

Ps. the pictures display fine for me, really sharp and clear.

Oh and one other thing relating to the squig project: I think it would be cool to define how big the starting triangles are, and it would be cool to have a slo-mo mode to see the squigs being subdevided and such. Like your animated gif.

__________________________________________

My software never has bugs. It just develops random features.
gfgfgfdddddddd
13
Years of Service
User Offline
Joined: 11th Mar 2011
Location: calgary
Posted: 16th Mar 2011 02:23


yo
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Mar 2011 06:59 Edited at: 16th Mar 2011 07:08
Schweet! got it.


Here's the source code for the "Squig" class.
Uhh, the only API specific thing is the draw function. I used SDL for the demo, but DGDK could be used incredibly easily. In the following snippet, I just replaced all the "line" commands with "dbLine"... I think that would work in DGDK.

Squig.h


Squig.cpp


Aaaand the vector class I use is as follows:
vector2.h


vector2.cpp


[edit]
Oh, and of course, the download link to the compiled program. Press "0" to iterate.
http://www.neurofuzzydev.com/downloads/C++/squig.rar

SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 17th Mar 2011 01:16
nicely done!

__________________________________________

My software never has bugs. It just develops random features.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Jun 2011 13:41 Edited at: 11th Jun 2011 15:21
Neuro Fuzzy

I've tried your cave generator posted on 15 March but keep getting memblock errors:



I've tried changing the screen resolution, etc, but keep getting the same result. Did you post an early version by mistake? Or is my copy/paste suspect?

Edit

Tinkered with the code a bit and it now seems to work. Good work Neuro Fuzzy.

Attachments

Login to view attachments
noobnerd
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 10th Jul 2011 22:56
wow awesome maze genrator! Could you possibly add a function that highlights a path from a point to another?
10JACK7
12
Years of Service
User Offline
Joined: 3rd Aug 2011
Location:
Posted: 4th Aug 2011 20:55
Wow. I've always wondered if someone had done this. You should make a way to save an image, such as (in the main loop):

This saves an image of the whole screen to "C:\myimage.bmp" when the user presses the S key.

Login to post a reply

Server time is: 2024-03-29 09:06:08
Your offset time is: 2024-03-29 09:06:08