• 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.20/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

  • Mazz.zip
    15.5 KB · Views: 2,802

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
So ... no one have a comments on my little project?
Did anyone compile it and try it?
 

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,838 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
main rig is down :( no sweet apps on my laptop.
 

unibrow1990

New Member
Joined
Mar 19, 2009
Messages
194 (0.04/day)
Location
Detroit, Michigan
System Name FUBAR
Processor AMD Phenom II 720BE @ 3.6Ghz
Motherboard Jetway HA06, 780g sb700
Cooling Sunbeamtech Core Contact Freezer, 2x 40mm fan 1x 70mm hdd fan, 2x 80mm case fans, 4x 120mm case fans
Memory 4gb OCZ Reaper ddr2 800@ 4-4-4-12-1t 2.2v
Video Card(s) HIS 4850 ICEQ4 512mb crossfired with XFX 4850 512mb
Storage WDC Black 640gb SATA, 250gb Hitachi Deskstar SATA
Display(s) Acer X193W+ 19" 5ms 1680x1050
Case Modded Raidmax Smilodon Extreme Black
Audio Device(s) Integrated W/ Altec Lansing 2.1 speakers
Power Supply Rosewill RP550V2-D-SL 550W with FSP Booster X3
Software Win 7 Home Premium 64-bit
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 :(
 
Joined
May 19, 2007
Messages
7,662 (1.24/day)
Location
c:\programs\kitteh.exe
Processor C2Q6600 @ 1.6 GHz
Motherboard Anus PQ5
Cooling ACFPro
Memory GEiL2 x 1 GB PC2 6400
Video Card(s) MSi 4830 (RIP)
Storage Seagate Barracuda 7200.10 320 GB Perpendicular Recording
Display(s) Dell 17'
Case El Cheepo
Audio Device(s) 7.1 Onboard
Power Supply Corsair TX750
Software MCE2K5
ill try it later :)
 
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
Good stuff. If I had a little more practice in C#, would write a mouse (path finder) class :)
 
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
Who needs SuperPI? We have MazzBench! :D

 

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.09/day)
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
this looks cool, I'll give it a try next time I boot in to Windows :toast:
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
Lol, I was just reading a threading tutorial.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
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 ...
 
Joined
Aug 10, 2007
Messages
4,267 (0.70/day)
Location
Sanford, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
I overclocked:



Then I multi-thread:



Hmm... need to optimize ;)

-edit-

After a little re-working, got them to ~100 each.
 
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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.
 

Completely Bonkers

New Member
Joined
Feb 6, 2007
Messages
2,576 (0.41/day)
Processor Mysterious Engineering Prototype
Motherboard Intel 865
Cooling Custom block made in workshop
Memory Corsair XMS 2GB
Video Card(s) FireGL X3-256
Display(s) 1600x1200 SyncMaster x 2 = 3200x1200
Software Windows 2003
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?



http://en.wikipedia.org/wiki/3D_Monster_Maze
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
The best maze solving algorithm would probably be based on a binary tree--a new leaf created every time a junction is encountered.
 
Joined
Nov 10, 2008
Messages
1,983 (0.35/day)
Processor Intel Core i9 9900k @ 5.1GHZ all core load (8c 16t)
Motherboard MSI MEG Z390 ACE
Cooling Corsair H100i v2 240mm
Memory 32GB Corsair 3200mhz C16 (2x16GB)
Video Card(s) Powercolor RX 6900 XT Red Devil Ultimate (XTXH) @ 2.6ghz core, 2.1ghz mem
Storage 256GB WD Black NVME drive, 4TB across various SSDs/NVMEs, 4TB HDD
Display(s) Asus 32" PG32QUX (4k 144hz mini-LED backlit IPS with freesync & gsync & 1400 nit HDR)
Case Corsair 760T
Power Supply Corsair HX850i
Mouse Logitech G502 Lightspeed on powerplay mousemat
Keyboard Logitech G910
VR HMD Wireless Vive Pro & Valve knuckles
Software Windows 10 Pro
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:

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
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
 

Completely Bonkers

New Member
Joined
Feb 6, 2007
Messages
2,576 (0.41/day)
Processor Mysterious Engineering Prototype
Motherboard Intel 865
Cooling Custom block made in workshop
Memory Corsair XMS 2GB
Video Card(s) FireGL X3-256
Display(s) 1600x1200 SyncMaster x 2 = 3200x1200
Software Windows 2003
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.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
You could just import .NET Framework DLLs for robot AI. That's much easier and faster than coding a scripting language.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
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:
 

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,838 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
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.
 
Top