Ejemplo n.º 1
0
        /// <summary>Returns a least-cost path from the hex <c>start</c> to the hex <c>goal.</c></summary>
        public static IDirectedPath GetDirectedPath(this IBoard <IHex> @this, IHex start, IHex goal)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this");
            }
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }
            if (goal == null)
            {
                throw new ArgumentNullException("goal");
            }

            if (@this.IsPassable(start.Coords) && @this.IsPassable(goal.Coords))
            {
                return(goal.Coords.Range(start.Coords) > @this.RangeCutoff
              ? BidirectionalPathfinder.FindDirectedPathFwd(start, goal, @this)
              : UnidirectionalPathfinder.FindDirectedPathFwd(start, goal, @this));
            }
            else
            {
                return(default(IDirectedPath));
            }
        }
 public PathShortcut(IHex start, IHex goal, IDirectedNavigableBoard board)
 {
     DirectedPath = BidirectionalPathfinder.FindDirectedPathFwd(start, goal, board);
     Goal         = goal;
 }