Hello Vatara,
I believe I understand the algorithm and the code partially, but I still can’t figure out how to input the data.
Let me explain.
As far as I saw this part is the initPart of the code :
public void TestNoObstacles () {
ShortestPathGraphSearch<Vector2i,Vector2i> search = new ShortestPathGraphSearch<Vector2i,Vector2i>(this);
List<Vector2i> list = search.GetShortestPath(new Vector2i(1,0), new Vector2i(3,0));
Assert.Equals(2,list.Count);
Debug.Log("Test No Obstacles");
foreach (Vector2i pos in list){
Debug.Log("Position "+pos);
}
}
Does it mean that in the “search.GetShortestPath(new Vector2i(1,0), new Vector2i(3,0));” Vector2i(1,0) is the StartPoint and Vector2i(3,0) is the EndPoint ?
If that is the case, than where is the input for the GridData?
I would presume that the code needs the StartPoint, the EndPoint and the GridData to process everything correctly. So, following this idea and with my grid example of 20x50 I would need :
- Coord(1,1) : StartPoint
- Coord(20,50) : EndPoint
- GridData (as you mentioned in the last line of your post). But this is one of the things that I do not understand. How do I create the GridData (is it suppose to be in a List or Dictionary) and then , how do I send this Data to the Script?
Do I do something like :
void Start () {
Dictionary<string,Dictionary> NodeDictionary = new Dictionary<string,Dictionary>();
NodeDictionary.Add("StartPoint coordonated", childNodeDictionary);
//In the Dictionary we have only the StartingNode
for( x=node in adjacentNodes){
Dictionary<string,Dictionary,bool> childNodeDictionary = new Dictionary<string,Dictionary,bool>();
myDictionary[NodeCoordonates] = childNodeDictionary;
}
}
and after I populate the Dictionary with all childs and so on, how do I send it to the Pathfinding Script ?