• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

C# : Maze Program

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.07/day)
Location
Cheeseland (Wisconsin, USA)
Okay kids, I thought it would be fun to write a program to generate random mazes.

I usually go through the code and explain things, but this time I am just going to drop off the source code and let you have fun with it. If you have any questions post them here and I will be happy to explain whatever you want.

Feel free to expand upon it and post your changes and results !!!

It's a Visual Studio project written in C#.
 

Attachments

So ... no one have a comments on my little project?
Did anyone compile it and try it?
 
main rig is down :( no sweet apps on my laptop.
 
I compiled it and tried it out, it's very nice. Unfortunately I'm so busy with classwork for the end of the semester that I don't have time to pick any C# and play with it at all :(
 
ill try it later :)
 
Good stuff. If I had a little more practice in C#, would write a mouse (path finder) class :)
 
Who needs SuperPI? We have MazzBench! :D

MazzBench.png
 
this looks cool, I'll give it a try next time I boot in to Windows :toast:
 
Lol, I was just reading a threading tutorial.
 
I've got some ideas to make this a little more interesting, but I haven't had any time to code in the last few days :(

So I'll give you a little coding humor instead ...
pointers.png
 
I overclocked:

MazzBench-OC.png


Then I multi-thread:

MazzBench-Multi.png


Hmm... need to optimize ;)

-edit-

After a little re-working, got them to ~100 each.
 
Last edited:
You should be able to average around 140 per core. It should be done in right around 4 seconds on a dual-core or 2 seconds on a quad core for 1000 mazes.
 
Nice benchmark concept, but, would be better if you had a mouse and it had to solve the maze too! Or at least a fill routine, that coloured in each maze branch simultaneously. What is the best maze-solve algorithm?

What is your "random" generator for creating the maze? Random-random, or fractal-random? That might be interesting.

Oh, why isnt this in 3D?
evilgrin0022.gif


Capture068.jpg

http://en.wikipedia.org/wiki/3D_Monster_Maze
 
The best maze solving algorithm would probably be based on a binary tree--a new leaf created every time a junction is encountered.
 
Ooo this reminds me of when i had to write a maze generator for uni a few years ago in java - does your algorithm have the possibility of creating "islands" where a pathfinding algorithm which would use a take every right or take every left would be able to get trapped?

Also sorry if this may go off-topic but would anyone be interested in a 3D version (java+openGl) which has pre-made maps and a random maze generator? If you make a massive random maze it can drag even high-end rigs down in performance :p I can upload mine if anyone's interested (graphics are very basic, but it has more than just a maze solving component as it was a fire fighting game).
 
Last edited:
Nice benchmark concept, but, would be better if you had a mouse and it had to solve the maze too! Or at least a fill routine, that coloured in each maze branch simultaneously. What is the best maze-solve algorithm?

What is your "random" generator for creating the maze? Random-random, or fractal-random? That might be interesting.

Oh, why isnt this in 3D?

This was just a quick little project to get the maze working. What I wanted to do eventually was get the maze working as needed and then import it into MS Robotic studio as a 3D maze and then allow people to write robot control routines to traverse the maze and see who could come up with good control routines for solving the maze.

That thought got sidelined when I realized it would be more fun to write this as a client server program where 4 people would make robots (1 in each corner) and see who could complete the maze (travel to the opposing diagonal corner) first. Of course the robots would be armed and could shoot each other when they met (killing a robot would send it back to its starting location forcing it to start over). :D
 
Sounds great! What would be cool would be such an "environment" with a logo-type scripting language so that people (teams) could program their own bots to wander and solve the maze and compete! BIG PROJECT though! Perhaps for a masters or PhD... collective community AI project.
 
Last edited:
You could just import .NET Framework DLLs for robot AI. That's much easier and faster than coding a scripting language.
 
I think we need a TPU coding project.
Not sure what we would do , but it would be fun to get a group of us coding hobbyists together and create some kind of coding masterpiece. :rockout:
 
I think we need a TPU coding project.
Not sure what we would do , but it would be fun to get a group of us coding hobbyists together and create some kind of coding masterpiece. :rockout:

that would be wicked fun. the problem is im not sure what we could do that would incorporate everyones area. as not everyone knows the others language.
 
Back
Top