Ejemplo n.º 1
0
 public GridLocation Add(GridLocation newLocation)
 {
     if (_currentNode == null)
         _currentNode = _list.AddFirst(newLocation);
     else
         _currentNode = _list.AddAfter(_currentNode, newLocation);
     return newLocation;
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Optimization.Entities.Grid grid = ConstructGrid();

            var startPoint = new Optimization.Entities.GridLocation(0, 2);
            var endPoint = new Optimization.Entities.GridLocation(3, 1);

            // Construct the appropriate path engine
            Optimization.Interfaces.IPathProvider engine = new ShortestPath.Optimization.Naive.Engine();
            // Optimization.Interfaces.IPathProvider engine = new ShortestPath.Optimization.DP.Engine();

            Console.WriteLine(grid.ToString()); // Display initial grid
            Path path = engine.FindPath(grid, startPoint, endPoint);
            Console.WriteLine(grid.ToString()); // Display final grid

            // Display results
            Console.WriteLine(path.ToString());
            Console.WriteLine("Path length: {0}", path.Length);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Optimization.Entities.Grid grid = ConstructGrid();

            var startPoint = new Optimization.Entities.GridLocation(0, 2);
            var endPoint   = new Optimization.Entities.GridLocation(3, 1);

            // Construct the appropriate path engine
            Optimization.Interfaces.IPathProvider engine = new ShortestPath.Optimization.Naive.Engine();
            // Optimization.Interfaces.IPathProvider engine = new ShortestPath.Optimization.DP.Engine();

            Console.WriteLine(grid.ToString()); // Display initial grid
            Path path = engine.FindPath(grid, startPoint, endPoint);

            Console.WriteLine(grid.ToString()); // Display final grid

            // Display results
            Console.WriteLine(path.ToString());
            Console.WriteLine("Path length: {0}", path.Length);
        }
Ejemplo n.º 4
0
        public GridLocation TraversableLocationAtOffset(GridLocation startingPoint, int xOffset, int yOffset)
        {
            // Note: Offset of 0,0 is considered not-traversable because
            // you can't move from where you are to there. It is not a valid movement.
            GridLocation result = null;

            if (xOffset != 0 || yOffset != 0)
            {
                var xNew = startingPoint.X + xOffset;
                var yNew = startingPoint.Y + yOffset;
                if (LocationIsValid(xNew, yNew))
                {
                    var newLocation = this[xNew, yNew];
                    if (!newLocation.IsRoadblock)
                    {
                        result = newLocation;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
 protected void Add(GridLocation location)
 {
     _list.Add(location);
 }
Ejemplo n.º 6
0
        public GridLocation TraversableLocationAtOffset(GridLocation startingPoint, int xOffset, int yOffset)
        {
            // Note: Offset of 0,0 is considered not-traversable because
            // you can't move from where you are to there. It is not a valid movement.
            GridLocation result = null;

            if (xOffset != 0 || yOffset != 0)
            {
                var xNew = startingPoint.X + xOffset;
                var yNew = startingPoint.Y + yOffset;
                if (LocationIsValid(xNew, yNew))
                {
                    var newLocation = this[xNew, yNew];
                    if (!newLocation.IsRoadblock)
                        result = newLocation;
                }
            }

            return result;
        }