summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
diff options
context:
space:
mode:
authorSimon O'Shea <osheas1@wit.edu>2023-08-09 12:14:10 -0400
committerSimon O'Shea <osheas1@wit.edu>2023-08-09 12:14:10 -0400
commit53d3bee642da9da745ce6ecf88454240c5576b89 (patch)
treec3fcc8b284c158e01c15047f14ecac21c5cf6f55 /Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
parent3f5e0a28f1347a47c45664561cca6cacbb33dbb8 (diff)
updated algorithms / heuristics
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
index 2f10505..b44c638 100644
--- a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
@@ -74,7 +74,12 @@ public class Pathfinder
{
result = StartDFS(initialState, -1);
}
- }
+ // Run IDS
+ if (algorithm == 2)
+ {
+ result = StartIDS(initialState);
+ }
+ }
public static Stack<Node> StartAStar(Node initialState, int heuristic)
{
@@ -117,7 +122,7 @@ public class Pathfinder
List<Node> children = currentNode.expand(-1);
if (heuristic == 0)
- h2(children);
+ h0(children);
else if (heuristic == 1)
h1(children);
else if (heuristic == 2)
@@ -203,7 +208,7 @@ public class Pathfinder
List<Node> open = new List<Node>();
open.Add(initialState);
- int cap = 100000;
+ int cap = 90000;
while (true && cap > 0)
{
// if open is empty, we have exhausted all of our options and there is no solution
@@ -211,6 +216,7 @@ public class Pathfinder
return solution;
Node currentNode = open[0];
+ open.RemoveAt(0);
// check if agent is in goal state
if (currentNode.samples.Count == 0)
@@ -234,7 +240,7 @@ public class Pathfinder
Debug.Log("Too much work :(");
return solution;
}
- public static Stack<Node> ids(Node initialState)
+ public static Stack<Node> StartIDS(Node initialState)
{
Debug.Log("RUNNING IDS");
Stack<Node> result = new Stack<Node>();