During my Degree, I had this project of doing both a generator and a solver of Maze. We were free to choose wich method to use.
All the project was on Java, the generation and resolution was in java vanilla and for the UI we had to use Java Swing.
note : if you are french (or crazy) you can read our pdf wich is in the repo.
Big s/o to paul, my teammate on this project :
We hesitate between 2 maze generation algorithms:
Finally, I chose the Depth First Search method which seemed a bit eaisier at the time of choice.
Here are the different steps of the algorithm:
- Randomly select a node (or a cell) N.
- Push cell N into a Q queue.
- Mark cell N as visited.
- Randomly select an adjacent cell A from cell N that has not been visited. If all neighbors of N have been visited:
- Continue removing items from queue Q until a cell is encountered with at least one unvisited neighbor - assign this cell to N and go to step 4.
- If no cell exists: stop.
- Break the wall between N and A.
- Assign the value A to N.
- Go to step 2.
For this part, we instantly went for the method of Depth-first search (again T.T) because we were forced to by the university. It was pretty the same logic as its counter part in Generation and so this part was made very quickly.
Now that everything was done, we only had to do the UI part, in where we were forced to use Java Swing. We did something pretty classic :
It is always a great project to do a maze generator and/or solver. I was happy to do it and I am proud of the result ๐น. Thank you to everyone who read all of this, hope it was interested ๐.
See ya