Пример #1
0
        public static void Astar()
        {
            var mapa = new MapServices();

            Console.WriteLine("Lista miast: ");
            for (int i = 0; i < mapa.AStarNodeMap.Count; i++)
            {
                Console.WriteLine(i + ". " + mapa.AStarNodeMap.ElementAt(i).Name);
            }

            int startNum, endNum;

            Console.Write("\nWybierz miasto początkowe(numer): ");
            int.TryParse(Console.ReadLine(), out startNum);

            Console.Write("Wybierz miasto końcowe(numer): ");
            int.TryParse(Console.ReadLine(), out endNum);

            AStarNode start = mapa.AStarNodeMap.ElementAt(startNum);
            AStarNode end   = mapa.AStarNodeMap.ElementAt(endNum);

            Astar             search = new Astar(end);
            IList <AStarNode> route  = search.Expand(start);

            foreach (var item in route)
            {
                Console.WriteLine(item.Name);
            }
        }