Skip to content

Java-based GUI application that solves mazes using backtracking algorithm. It visualizes the maze-solving process in real-time, highlighting the current path, backtracking steps, and teleportation through portals. The application effectively demonstrates pathfinding algorithms by marking visited cells, backtracking paths, and portal usage.

Notifications You must be signed in to change notification settings

Israel-Charles/GUI-Dynamic-Maze-Solver

Repository files navigation

GUI Dynamic Maze Solver

Dynamic Maze Solver is a Java-based graphical application that demonstrates maze-solving techniques using a backtracking algorithm. This project visualizes the process of solving a maze in real-time, showcasing pathfinding, backtracking, and teleportation mechanics through portals.

Features

  • Real-time Visualization: Watch the algorithm solve the maze step by step.
  • Backtracking: See the algorithm backtrack from dead ends and visualize the path taken.
  • Portals: Experience teleportation through numbered portals.
  • Start and End Points: Clearly labeled start (S) and exit (E) points.
  • Interactive Graphics: Uses Java Swing to provide a graphical representation of the maze.

How It Works

  1. Maze Representation: The maze is represented as a 2D grid, read from a text file where each character denotes a wall, path, portal, start, or exit.
  2. Pathfinding Algorithm: A backtracking algorithm explores the maze, visiting valid paths, utilizing portals, and marking visited and backtracked paths.
  3. Visualization: The graphical interface updates in real-time to show the current position, visited cells, and backtracked paths.

Prerequisites

  • Java Development Kit (JDK) 8 or later.
  • An IDE or text editor to view and run the Java program.

Setup

  1. Clone the Repository:
git clone https://github.com/Israel-Charles/Dynamic-Maze-Solver.git
  1. Navigate to the Project Directory:
cd DynamicMazeSolver
  1. Compile the Java Program:
javac MagicMaze.java
  1. Run the Program:

Maze File Format

  1. Create a text file in the project directory to pass it as argument when running the program.

  2. Use characters to design your maze:

  • '@' for walls
  • '*' for paths
  • '0-9' for portal pairs
  • 'X' for the exit point

Note: Maze will always start at the bottom left corner

Some example maze files are in the repo

Run the Program

java DynamicMazeSolver <mazefile.txt> <# of rows> <# of cols>

Example with a maze file that has 15 rows and 20 columns:

java DynamicMazeSolver maze4.txt 15 20

About

Java-based GUI application that solves mazes using backtracking algorithm. It visualizes the maze-solving process in real-time, highlighting the current path, backtracking steps, and teleportation through portals. The application effectively demonstrates pathfinding algorithms by marking visited cells, backtracking paths, and portal usage.

Topics

Resources

Stars

Watchers

Forks

Languages