A JavaFX desktop application that visualizes various pathfinding algorithms in real-time. This project demonstrates the behavior of different search algorithms on customizable grids with interactive maze generation.
-
Multiple Pathfinding Algorithms:
- A* (A-Star) - Heuristic-based pathfinding
- Dijkstra's Algorithm - Shortest path guarantee
- Breadth-First Search (BFS) - Level-order traversal
- Depth-First Search (DFS) - Stack-based exploration
-
Interactive Grid:
- Click and drag to draw walls
- Adjustable grid size
- Set custom start and goal nodes
- Erase walls with eraser tool
-
Maze Generation:
- DFS-based maze generator
- Random maze generator
- Save and load custom mazes
-
Real-Time Visualization:
- Color-coded nodes showing algorithm progress
- Adjustable animation speed
- Visual path reconstruction
- Green: Start node
- Red: Goal/target node
- Black: Wall nodes
- Orange: Nodes being explored (neighbors)
- Medium Purple: Nodes in exploration queue (BFS/DFS)
- Light Sky Blue: Final path from start to goal
Watch the pathfinding visualizer in action:
- Demo Video 1 - Pathfinding algorithms demonstration
- Demo Video 2 - Interactive features and maze generation
- Java 18 or higher
- Maven 3.8+
- JavaFX 18.0.2
-
Clone the repository:
git clone https://github.com/prydatkoo/pathfinder-java.git cd pathfinder-java -
Build the project:
mvn clean install
-
Run the application:
mvn javafx:run
-
Create a Grid:
- Enter desired pixel size in the text field
- Click "Create Grid" to initialize
-
Set Start and Goal:
- Click "Set Start Node" and click on the grid to place the start point
- Click "Set Goal Node" and click on the grid to place the target point
-
Draw Walls:
- Click "Set Walls" and drag on the grid to create obstacles
- Use "Erase Walls" to remove obstacles
-
Generate Mazes (Optional):
- Select "MazeDFS" or "Random Mazes" from the dropdown
- Click to generate automated maze patterns
-
Choose Algorithm:
- Select an algorithm from the dropdown menu (A*, Dijkstra, BFS, or DFS)
-
Visualize:
- Click "Visualize" to watch the algorithm find the path
- Adjust the animation speed slider for faster/slower visualization
-
Save/Load Mazes:
- Enter a filename in the text field
- Click "Save Maze" to save your current grid configuration
- Click "Upload Maze" to load a previously saved maze
Uses both distance from start (g-cost) and estimated distance to goal (h-cost) to find the optimal path efficiently. Combines the benefits of Dijkstra's and greedy best-first search.
Formula: f(n) = g(n) + h(n)
Guarantees the shortest path by exploring nodes in order of their distance from the start. Does not use heuristics, making it slower but reliable.
Explores nodes level by level using a queue. Guarantees the shortest path in unweighted graphs.
Explores as far as possible along each branch using a stack. Does not guarantee the shortest path but can be useful for maze solving.
PathfindingVis/
├── src/
│ └── main/
│ ├── java/
│ │ └── source/cspathfinder/
│ │ ├── Main.java # Application entry point
│ │ ├── Controller.java # GUI controller and logic
│ │ ├── Node.java # Node data structure
│ │ ├── Grid.java # Grid management
│ │ ├── aStar.java # A* implementation
│ │ ├── Dijkstras.java # Dijkstra's implementation
│ │ ├── BFS.java # BFS implementation
│ │ ├── DFS.java # DFS implementation
│ │ ├── MazeDFS.java # DFS maze generator
│ │ ├── RandomMazes.java # Random maze generator
│ │ ├── SaveMaze.java # Save maze functionality
│ │ └── InputFile.java # Load maze functionality
│ └── resources/
│ └── source/cspathfinder/
│ └── Scene.fxml # JavaFX UI layout
├── pom.xml # Maven configuration
└── README.md # This file
- Java 18 - Core programming language
- JavaFX 18.0.2 - GUI framework for desktop application
- Maven - Dependency management and build tool
- FXML - XML-based UI layout
This project demonstrates:
- Data Structures: Graphs, Priority Queues, Stacks, Queues, Hash Sets
- Algorithms: Pathfinding, maze generation, heuristics
- Design Patterns: MVC architecture
- GUI Development: Event handling, real-time visualization
- Software Engineering: Modular code structure, separation of concerns
Each grid cell is represented as a Node object containing:
- Coordinates (x, y)
- Cost values (f-cost, g-cost, h-cost)
- Neighbor references
- State flags (visited, wall, explored)
Uses ScheduledExecutorService to run algorithms step-by-step with configurable delays, providing smooth real-time visualization of the search process.
- DFS Maze: Creates perfect mazes (one path between any two points) using recursive backtracking
- Random Maze: Generates random wall patterns with 40% wall density
- Add more algorithms (Greedy Best-First, Jump Point Search)
- Implement weighted nodes for terrain costs
- Add diagonal movement support
- Export visualizations as GIF/video
- Performance metrics (nodes explored, path length, time taken)
Maryan Prydatko
- Email: [email protected]
- GitHub: @prydatkoo
This project was created as a high school computer science project.
This project was developed during high school to explore and visualize fundamental pathfinding algorithms used in computer science, robotics, and game development.
Note: This application requires a display and cannot run in headless mode due to JavaFX requirements.