A desktop JavaFX application that visualizes classic pathfinding algorithms on a 2D grid.
You can place walls, generate a random maze, optionally display edge weights, and run algorithms step-by-step with adjustable animation speed.
- Interactive grid
- Click to toggle walls
- (Optional) Shift + Click to cycle terrain (if enabled in your build)
- Algorithms
- BFS (Breadth-First Search)
- DFS (Depth-First Search)
- Dijkstra (weighted shortest path)
- A* (A-star) with Manhattan heuristic
- Visualization
- Highlights open set, closed set, and final path
- Displays path cost and number of steps when done
- Tools
- Generate Maze (random walls ~30%)
- Show/Hide Weights
- Reset Grid
- The grid is modeled as a graph:
- Nodes = cells
(row, col) - Directed edges to the 4 neighbors (up/down/left/right)
- Each directed edge gets a random weight in [1, 9]
- Nodes = cells
- Algorithms run in step-by-step mode (one iteration per tick) using a JavaFX
Timeline.
- Java: 17+ recommended
- JavaFX: compatible with your Java version
- IDE: IntelliJ / Eclipse / VS Code (any)
src/
controllers/
MainController.java
models/
Grid.java
Cell.java
Edge.java
Pathfinding.java
BFS.java
DFS.java
Dijkstra.java
Astar.java
views/
PathApp.java
- Open the project in your IDE.
- Make sure JavaFX is configured in your project settings.
- Run the main entry point:
controllers.MainController
(or runviews.PathAppif your setup allows it)
If you use JavaFX SDK locally, run with module path (adjust paths and version):
java --module-path /path/to/javafx/lib --add-modules javafx.controls,javafx.fxml -cp out/production/YourProject controllers.MainControllerIf you're using Maven/Gradle, your run command depends on your build file.
-
Set Start and Goal coordinates using the format:
row,col(example:0,0)
-
Click on cells to add/remove walls.
-
Choose an algorithm:
- Run BFS / DFS / Dijkstra / A*
-
Adjust the animation speed with the slider.
-
Optional:
- Generate a maze
- Show/hide weights
- Reset the grid
- Dijkstra and A* currently use a linear scan over the open set (not a heap-based priority queue), so performance may drop on very large grids.