A Java playground for experimenting with classic path‑finding algorithms on grid‑based “maze” levels. The project comes with a tiny interactive game/visualiser where you control (or let the algorithm control) a yellow agent that tries to reach a black‑and‑white goal flag while obstacles constantly conspire to block the way.
| Feature | Description |
|---|---|
| Two grid modes | Flat Grid – every cell has the same traversal cost. Altitude Grid – pyramidal “hills” give each cell a movement cost proportional to height. |
| Multiple search algorithms | Flat Grid: Depth‑First Search (DFS) and Breadth‑First Search (BFS). Altitude Grid: A* (with Manhattan or Euclidean heuristic – configurable). |
| Live visualisation | Watch the open / closed node sets grow cell by cell and see the final path traced back. |
| Level files | Levels are plain text, so you can design your own mazes with any editor. |
| Pluggable heuristics & costs | Just implement the Heuristic and CostModel interfaces and drop them in. |
| Unit‑test friendly | Core logic is algorithm‑only – no UI dependencies. JUnit tests included. |
| Lightweight | Pure Java 17, no external dependencies; runs on Windows, macOS, Linux. |
| Flat grid (BFS) | Altitude grid (A*) |
|---|---|
![]() |
![]() |
| Algorithm | Grid type | Notes |
|---|---|---|
| BFS | Flat | Uses a FIFO queue; explores layers outward. |
| DFS | Flat | Simple stack‑based exploration; mainly for comparison. |
| A* | Altitude | Priority queue ordered by f(n) = g(n)+h(n). |
| Name | Formula | When to use | ||||
|---|---|---|---|---|---|---|
| Manhattan | ` | dx | + | dy | ` | 4‑way movement, cheap & admissible. |
🚀 Getting started
Gradle (recommended)
git clone https://github.com/your‑username/pathblocker.git
cd pathblocker
./gradlew run # downloads JDK 17 toolchain automaticallyMaven
git clone https://github.com/your‑username/pathblocker.git
cd pathblocker
mvn javafx:run- The start menu lets you pick Flat or Altitude grid.
- Choose an algorithm: Flat grid ➜ BFS or DFS Altitude grid ➜ A* (pick heuristic)
- Click Start – the solver will animate its search. • Space pauses/resumes • N advances one step (great for teaching) • R reloads the same level • L opens the level picker
-
Add a new algorithm:
- Create a package under
search/youralgo. - Implement the
SearchAlgorithminterface. - Register it in
SearchRegistry.
- Create a package under
-
Custom cost models or heuristics: Implement
CostModelorHeuristic, drop the class on the classpath, and select it from the UI. -
Make bigger levels: Level files are simple ASCII art:
########## #S ### S = start # ## # G = goal # ^^^ # # = wall # G # ^ = altitude (height increases with count) ##########









