Skip to content

JavaFX Application using DFS for maze traversal and random maze generation

Notifications You must be signed in to change notification settings

PrateekAdhikaree/MazeTraversalAndGeneration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maze Traversal and Generation

Summary

A simple program to illustrate maze traversal and random maze generation using Depth First Search algorithm

Specifications

  • JavaFX Application
  • Netbeans IDE

Installation

  • Download the project and run on Netbeans or similar IDE.
  • src/FixedMaze contains logic for maze traversal
    • run main() in src/FixedMaze/MazeTraverse.java
  • src/RandomMaze has a file to randomly generate maze on every execution
    • run main() in src/RandomMaze/MazeGeneratorFrame.java

Description

Maze Traversal

There is a simple algorithm for walking through a maze that guarantees finding the exit (assuming there is an exit). If there is no exit, you will arrive at the starting location again. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall, eventually you will arrive at the exit of the maze. There may be a shorter path than the one you have taken, but you are guaranteed to get out of the maze if you follow the algorithm.

Wrote a recursive method mazeTraverse (iterative method) to walk from the starting location of the maze. As mazeTraverse() attempts to locate the exit from the maze, it places Mario in each square in the path. The method displays the maze after each move so the user can watch as the maze is solved.

screen1

In the end, when Mario finds the exit (Princess), a message is shown and the path traversed by him is shown in green.

screen2

screen3

Maze generator

Redid the previous part but with randomly generated mazes. Wrote a method mazeGenerator() that takes as an argument a double-subscripted array and randomly produces a maze. The method also provides the starting and ending locations of the maze.

random1

random2

random3

Thanks!!

About

JavaFX Application using DFS for maze traversal and random maze generation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages