summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts
diff options
context:
space:
mode:
authordereelatwit <54997325+dereelatwit@users.noreply.github.com>2023-08-09 13:21:27 -0400
committerdereelatwit <54997325+dereelatwit@users.noreply.github.com>2023-08-09 13:21:27 -0400
commit5297b3f06053210b646f820c243fd7fd51c83116 (patch)
tree15118ed5e7df102fe6a0da2dc5fa69ed4a9f3d94 /Pathfinding Visualizer/Assets/Scripts
parent716995cd9206aa53a22fcce59d87e1e5e5ad4c69 (diff)
Fixed closed list to compare string values
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
index c82451a..c2b9e6d 100644
--- a/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/Pathfinder.cs
@@ -8,7 +8,7 @@ public class Pathfinder
{
// used to store all unique states that agent has visited (holds agent and sample coords)
- public static HashSet<State> closed = new HashSet<State>();
+ public static HashSet<string> closed = new HashSet<string>();
LogicGrid world;
public Vector2Int agent;
@@ -26,7 +26,7 @@ public class Pathfinder
public Pathfinder(LogicGrid world, Vector2Int a, HashSet<Vector2Int> o, HashSet<Vector2Int> s, int algo, int heu)
{
- closed = new HashSet<State>();
+ closed = new HashSet<string>();
this.world = world;
height = world.GetHeight();
@@ -299,7 +299,7 @@ public class Node
Vector2Int onSample = new Vector2Int();
// since this state is being currently visited (expanded), put in closed list
- Pathfinder.closed.Add(this.getState());
+ Pathfinder.closed.Add(this.getStateString());
////////////////////////////////////
// BEGIN CHECKING FOR VALID MOVES //
@@ -319,7 +319,7 @@ public class Node
//SampleWorld.nodesGenerated++;
// make sure that we have not already made that move
- if (!Pathfinder.closed.Contains(child.getState()))
+ if (!Pathfinder.closed.Contains(child.getStateString()))
children.Add(child);
}
@@ -329,7 +329,7 @@ public class Node
Node child = new Node(this, down, this.obstacles, this.samples, 'D', this.distanceTraveled + 1, this.heuristic);
//SampleWorld.nodesGenerated++;
- if (!Pathfinder.closed.Contains(child.getState()))
+ if (!Pathfinder.closed.Contains(child.getStateString()))
children.Add(child);
}
@@ -338,7 +338,7 @@ public class Node
Node child = new Node(this, left, this.obstacles, this.samples, 'L', this.distanceTraveled + 1, this.heuristic);
//SampleWorld.nodesGenerated++;
- if (!Pathfinder.closed.Contains(child.getState()))
+ if (!Pathfinder.closed.Contains(child.getStateString()))
children.Add(child);
}
@@ -347,7 +347,7 @@ public class Node
Node child = new Node(this, right, this.obstacles, this.samples, 'R', this.distanceTraveled + 1, this.heuristic);
//SampleWorld.nodesGenerated++;
- if (!Pathfinder.closed.Contains(child.getState()))
+ if (!Pathfinder.closed.Contains(child.getStateString()))
children.Add(child);
}