コード例 #1
0
ファイル: Path.cs プロジェクト: AnnMarieTorres/DPDemo
 public GridLocation Add(GridLocation newLocation)
 {
     if (_currentNode == null)
         _currentNode = _list.AddFirst(newLocation);
     else
         _currentNode = _list.AddAfter(_currentNode, newLocation);
     return newLocation;
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: AnnMarieTorres/DPDemo
        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);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: AnnMarieTorres/DPDemo
        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);
        }
コード例 #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);
        }
コード例 #5
0
 protected void Add(GridLocation location)
 {
     _list.Add(location);
 }
コード例 #6
0
ファイル: Grid.cs プロジェクト: AnnMarieTorres/DPDemo
        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;
        }