broken AStar has been implemented

need to fix sorting problem because the returned order of movements does not make any sense
This commit is contained in:
Simon O'Shea
2023-08-08 18:35:53 -04:00
parent 96a90a647d
commit c49365523b
2 changed files with 40 additions and 17 deletions
+17 -2
View File
@@ -14,7 +14,7 @@ public class Main : MonoBehaviour
// Coordinates for pathfinding
public Vector2Int agent = new Vector2Int();
public Vector2Int agent = new Vector2Int(-1, -1);
public List<Vector2Int> obstacles = new List<Vector2Int>();
public List<Vector2Int> samples = new List<Vector2Int>();
@@ -102,6 +102,9 @@ public class Main : MonoBehaviour
public void ResetGrid()
{
world.reset();
agent = new Vector2Int(-1, -1);
obstacles = new List<Vector2Int>();
samples = new List<Vector2Int>();
}
public void StartAlgorithm()
@@ -115,7 +118,7 @@ public class Main : MonoBehaviour
int index = x * world.GetHeight() + y;
int value = world.GetValue(x, y);
Debug.Log("x: " + x + " y: " + y + " | value: " + value);
//Debug.Log("x: " + x + " y: " + y + " | value: " + value);
// Add coordinate to obstacle array
if (value == 1)
@@ -143,6 +146,18 @@ public class Main : MonoBehaviour
}
}
if (agent.x == -1 && agent.y == -1)
{
Debug.Log("NO AGENT!");
return;
}
if (samples.Count == 0)
{
Debug.Log("NO SAMPLES!");
return;
}
if ( true )
{