summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
diff options
context:
space:
mode:
authorSimon O'Shea <osheas1@wit.edu>2023-08-08 20:07:50 -0400
committerSimon O'Shea <osheas1@wit.edu>2023-08-08 20:07:50 -0400
commit615dbd003ea715cdf3ef3424362c26fcd154ca61 (patch)
treeb72eadc34736da8866aad46df4edd5e0e193042e /Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
parent45cb21030f2281be3db0c63a24c6f7772b26586b (diff)
astar broken, just like my spirits
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs18
1 files changed, 17 insertions, 1 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
index 212d6d2..b7f820e 100644
--- a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
@@ -60,6 +60,7 @@ public class Pathfinder
Node initialState = new Node(null, agent, samples, '0', 0, 0);
List<Node> result = new List<Node>();
+ // Run AStar
if (algorithm == 0)
{
result = StartAStar(initialState);
@@ -96,6 +97,7 @@ public class Pathfinder
// check whether we are in goal state
if (currentNode.samples.Count() == 0)
{
+ Debug.Log("Gottem");
while (currentNode.parent != null)
{
solution.Add(currentNode);
@@ -108,7 +110,7 @@ public class Pathfinder
// if not, expand children and continue
List<Node> children = currentNode.expand(-1);
- if (heuristic.Equals("h0"))
+ if (heuristic == 0)
h0(children);
/* else if (heuristic.Equals("h1"))
h1(children);
@@ -124,6 +126,20 @@ public class Pathfinder
return solution;
}
+
+/* private Node GetLowestNode(List<Node> NodeList)
+ {
+ Node lowest = NodeList[0];
+ for (int i = 1; i < NodeList.Count; i++)
+ {
+ if (NodeList[i].fn < lowest.fn)
+ {
+ lowest = NodeList[i];
+ }
+ }
+ return lowest;
+ }*/
+
// HEURISTICS FOR ASTAR
public static List<Node> h0(List<Node> children)
{