Ejemplo n.º 1
0
        public void AStarSameOriginAndDestination()
        {
            bool error = false;

            try
            {
                var list = CreatePointList();
                Graph.Graph <GameObject> graph = new Graph.Graph <GameObject>();
                graph.AddNodes(list);
                int[] indices = new int[graph.Nodes.Count * 2];
                for (int i = 0; i < graph.Nodes.Count * 2; i += 2)
                {
                    indices[i]     = Random.Range(0, graph.Nodes.Count);
                    indices[i + 1] = Random.Range(0, graph.Nodes.Count);
                }
                graph.CreateEdges(indices, (c, d) => Vector3.Distance(c.transform.position, d.transform.position));
                graph.CalculateHeuristics(graph.Nodes[0].Item, (c, d) => Vector3.Distance(c.transform.position, d.transform.position));
                var path = graph.AStar(0, 0);
            }
            catch
            {
                error = true;
            }

            Assert.IsFalse(error);
        }