This article is inspired by Jamis Buck’s presentation(Algorithm is not a 4-letter word). I’ve talked before about Maze Generation and its importance in acmASCIS blog, it’s great and interesting topic. In this post we’ll talk about a technique of generating a perfect maze, it’s Recursive Backtracking . Recursive backtracking is an algorithm for solving and generating perfect mazes. This algorithm is fast, easy to understand and straightforward to implement, but the maze is still biased(check Jamis Buck’s Presentation about Biased Maze Concept). Recursive backtracker performs a drunkard’s walk from the starting point by randomizing the visited child node at each level, but with some modifications on the drunkard’s walk ,as it pushes each visited node onto a stack and when it reached a dead-end it pops the nodes off the stack until it finds one that it can continue walking from instead of doing O(n) Search. Algorithm Steps from Jamis Buck’s Blog:
- Choose a starting point in the field.
- Randomly choose a wall at that point and carve a passage through to the adjacent cell, but only if the adjacent cell has not been visited yet. This becomes the new current cell.
- If all adjacent cells have been visited, back up to the last cell that has uncarved walls and repeat.
- The algorithm ends when the process has backed all the way up to the starting point.
you can check the animation introduced by Jamis Buck (here).
Here’s my Implementation in C#.
- publicoverridevoid GenerateMaze()
- while (NumOfVisitedCells < TotalCells)
- ArrayList adjcentCells = this.GetNeighborsWithWalls(currentCell);
- if (adjcentCells.Count > 0)
- int randomCell = Cell.theRandom.Next(0, adjcentCells.Count);
- Cell aCell = ((Cell)adjcentCells[randomCell]);
- currentCell = aCell;
- currentCell = (Cell)cellStack.Pop();
you can try simple .exe file Maze Generation.exe.
C++ Emulator :
- Islam Ibrahim
- Anas Awad
- Ahmed Sakr
- Project idea based on emulating C++ language and implement features of text editors(Syntax highlighting ,word wrapping ..etc)
Project Features :
- Text Editor Features
- C++ syntax Highlighter
- Basic features ( create project , Open , Remove ,…..etc)
- Emulator Features
- this C++ Emulator can run C++ Code till recursive functions (loops , nested loops , if & switch statements ,nested if , arrays , functions ,
- some libraries such as and are involved ,that support built in functions.
- Programming language : Java, You can find the source code (here)
- about syntax highlighter : after implementing lexical analyzer for using programming language , I’ve implemented a syntax highlighter that highlights each token based on its type if keyword or string literal……. etc.
- about concepts of emulating you can find them Here
- if your written code contains “cin” and you opened the console and didn’t enter the required data , the console will crash if you try to open it again.
- If your code contains error and you run it for another time the console will not be editable.
all if these problems just in first version.
- We Hope in next version we finish implement of some features of text editor such as indentation.
Project Experience Acquired:
- learn more about Compilers “How to build compiler or interpreter”.
- I’ve implemented lexical analyzer and Parse tree.
- Make me interested in new area which is programming languages Industry and Engineering compilers.
- How to apply OOP , OOA and OOD concepts.
Certifications : this project is certified from Dr.Gahada Nasr and got 2nd place with another project implemented by (Bassem Modar , Karim Magdy , Noran abo Doma , Hagar el Fiky) rest of our team members.
Thank You :
- Dr.Ghada Nasr .. OOP course instructor ..
- Dr.Mohammed Samy .. Teacher Assistant in my college .. His videos about interpreters were really helpful.
- Mohammed Hesham .. (acmASCIS) president .. he directed me to the starting point.
- Noran , Bassem , Hagar, karim … The rest of team members they were working on (connect4 with 3D) graphics.
Thanks all of you, You were really helpful.