still trying to fix astar
This commit is contained in:
@@ -99,6 +99,7 @@ using UnityEngine;
|
|||||||
onSample = CanSample();
|
onSample = CanSample();
|
||||||
if (onSample.x == 1)
|
if (onSample.x == 1)
|
||||||
{
|
{
|
||||||
|
Debug.Log("SAMPLING");
|
||||||
Node child = new Node(this, this.agent, this.samples, 'S', this.distanceTraveled + 1, this.heuristic);
|
Node child = new Node(this, this.agent, this.samples, 'S', this.distanceTraveled + 1, this.heuristic);
|
||||||
|
|
||||||
child.samples.RemoveAt(onSample.y);
|
child.samples.RemoveAt(onSample.y);
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class Pathfinder
|
|||||||
for(int i = 0; i < result.Count; i++)
|
for(int i = 0; i < result.Count; i++)
|
||||||
{
|
{
|
||||||
Node n = result[i];
|
Node n = result[i];
|
||||||
|
Debug.Log("Agent at: " + n.agent.x + ", " + n.agent.y);
|
||||||
Debug.Log(n.lastMove);
|
Debug.Log(n.lastMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,9 +80,6 @@ public class Pathfinder
|
|||||||
List<Node> open = new List<Node>();
|
List<Node> open = new List<Node>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//PriorityQueue<Node> open = new PriorityQueue<Node>();
|
|
||||||
|
|
||||||
open.Add(initialState);
|
open.Add(initialState);
|
||||||
int cap = 1000;
|
int cap = 1000;
|
||||||
while (true && cap > 0)
|
while (true && cap > 0)
|
||||||
@@ -100,7 +98,6 @@ public class Pathfinder
|
|||||||
{
|
{
|
||||||
while (currentNode.parent != null)
|
while (currentNode.parent != null)
|
||||||
{
|
{
|
||||||
Debug.Log("Agent at: " + currentNode.agent.x + ", " + currentNode.agent.y);
|
|
||||||
solution.Add(currentNode);
|
solution.Add(currentNode);
|
||||||
currentNode = currentNode.parent;
|
currentNode = currentNode.parent;
|
||||||
}
|
}
|
||||||
@@ -139,7 +136,7 @@ public class Pathfinder
|
|||||||
sorted.Add(children[i]);
|
sorted.Add(children[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted = sorted.OrderBy(Node => Node.fn).ToList();
|
//sorted = sorted.OrderBy(Node => Node.fn).ToList();
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class nMain : MonoBehaviour
|
|||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
Pathfinder astar = new Pathfinder(world, agent, obstacles, samples, algorithm, 0);
|
Pathfinder astar = new Pathfinder(world, agent, obstacles, samples, algorithm, 0);
|
||||||
astar.go();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user