Exemple #1
0
        public bool FindPath(Grid grid)
        {
            Grid = grid;
            Start = Grid.GetNode(Grid.Start.X,Grid.Start.Y);
            End = Grid.GetNode(Grid.End.X, Grid.End.Y);
            Open = new List<Node>();
            Closed = new List<Node>();
            Start.g = 0;
            Start.h = Euclidian(Start);
            Start.f = Start.g + Start.h;

            return Search();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var grid = new Grid(10, 10);
            grid.Start = new Node(0, 4);
            grid.End = new Node(7,6);

            for (int i = 0; i < 8; i++)
            {
                grid.SetWalkable(4, i, false);
            }

            grid.DisPlay();

            var a = new Astar();
            if (a.FindPath(grid))
            {
                a.DiaplayPath();
            }
        }