Skip to content

Commit 1bb30e2

Browse files
committed
finishing up
1 parent 0278b8e commit 1bb30e2

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
# Pathfiding Algorithms Visualized
22

3-
<img width="400" src="https://i.postimg.cc/RFG3VL3W/Capture33.png">
3+
<img width="600" src="https://i.postimg.cc/T3Mrkg6N/Capture.png">
44

55
## About
66

77
Here you can see in realtime how pathfiding algorithms works. You can also draw walls and move the start and end point.
88

9-
This include :
9+
Features :
1010

11-
* `A*`
12-
* `Dijkstra` (modified version because here is not a cost graph)
11+
* draw (left click) & remove (right click) walls
12+
* live searching
13+
* draw/remove walls after the search ends
14+
* move end point and see instantly the path
15+
16+
Pathfiding algorithms used :
1317

14-
Soon :
15-
* `Prim`
18+
* `A*`
19+
* `Dijkstra`
1620

1721
## How To Run
1822

19-
In order to run this, you'll need to install [Processing](https://processing.org/) first. Open Sketch.pde under Sketch folder and you are done.
23+
In order to run this, you'll need to install [Processing](https://processing.org/) first. Open Sketch.pde under Sketch folder and you are done.
24+
Also you must have the GUI library installed : [ControlP5](http://www.sojamo.de/libraries/controlP5/)
2025

2126
## Credits
2227

Sketch/AStar.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ class AStar extends Pathfiding{
77
super(arr);
88
super.priorityQueue = new PriorityQueue<Node>(1, new DistanceFComparator());
99
}
10-
10+
int k = 0;
1111
// HERE IS THE A* ALGORITHM
1212
@Override
1313
public void run(){
14-
14+
super.priorityQueue.clear();
1515
startNode.gScore = 0;
1616
super.priorityQueue.add(startNode);
1717

Sketch/Node.pde

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Node{
4747
// IF THE SELECTED CELL IS NOT START OR END NODE THEN
4848
// MAKE IT BLOCKED
4949
else if (this != startNode && this != endNode){
50+
this.resetNode();
5051
nodeColor = color(25);
5152
isBlocked = true;
5253
}

Sketch/Pathfiding.pde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ class Pathfiding implements Runnable{
8585
private void getPath(){
8686
this.t = null;
8787
Node temp = endNode;
88-
while(temp != null){
89-
temp.nodeColor(pathColor);
90-
temp = temp.parent;
88+
while(temp != null && temp != startNode){
89+
temp.nodeColor(pathColor);
90+
temp = temp.parent;
9191
}
9292
return;
9393
}

Sketch/Prim.pde

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)