Ejemplo n.º 1
0
        /// <summary>.</summary>
        /// <param name="pathHalves"></param>
        /// <param name="isForward"></param>
        public AltPathfinder(IPathHalves <THex> pathHalves, bool isForward)
        {
            int exitCost(IHex hex, Hexside hexside) => hex.ExitCost(hexside);
            int entryCost(IHex hex, Hexside hexside) => hex.EntryCost(hexside);

            PathHalves = pathHalves;
            Board      = pathHalves.Board;
            ClosedSet  = pathHalves.ClosedSet;
            Start      = isForward ? pathHalves.Source : pathHalves.Target;
            Goal       = isForward ? pathHalves.Target : pathHalves.Source;
            StepCost   = isForward ? (StepCost)exitCost : entryCost;
            Potential  = isForward ? (Potential)((l, c) => l.DistanceFrom(c))
                                                : ((l, c) => l.DistanceTo(c));
            SetBestSoFar = isForward ? (SetBest)((s, p) => PathHalves.SetBestSoFar(p, s))
                                              : ((s, p) => PathHalves.SetBestSoFar(s, p));
            HexsideDirection = isForward ? (Func <Hexside, Hexside>)(hexside => hexside)
                                         : (hexside => hexside.Reversed);

            OpenSet = new Dictionary <HexCoords, IDirectedPath>();
            Queue   = HotPriorityQueue.New <IDirectedPath>(0, 256);

            $"ALT {(isForward?"Fwd":"Rev")}".TraceFindPathDetailDirection(Goal.Coords - Start.Coords);

            StartPath(Start);
        }
        /// <param name="pathHalves"></param>
        /// <param name="isForward"></param>
        public AltPathfinder(IPathHalves pathHalves, bool isForward)
        {
            IsForward   = isForward;
            ClosedSet   = pathHalves.ClosedSet;
            StartCoords = pathHalves.Start;
            GoalCoords  = pathHalves.Goal;
            Landmarks   = pathHalves.Board.Landmarks;
            OpenSet     = new Dictionary <HexCoords, IDirectedPath>();
            Queue       = HotPriorityQueue.New <IDirectedPath>(0, 256);
            TryStepCost = IsForward ? (StepCost)pathHalves.Board.TryEntryCost : pathHalves.Board.TryExitCost;
            PathHalves  = pathHalves;

            PathfinderExtensions.TraceFindPathDetailDirection(Direction, GoalCoords - StartCoords);

            StartPath(IsForward ? StartCoords : GoalCoords);
        }
Ejemplo n.º 3
0
        /// <summary>TODO</summary>
        internal static IPriorityQueue <int, TValue> NewHotPriorityQueue <TValue>(int initialSize)
//    where TValue : class
        {
            return(HotPriorityQueue.New <TValue>(0, initialSize));
        }
 /// <summary>Returns a new <see cref="HotPriorityQueue"/> with size <paramref name="initialSize"/>.</summary>
 internal static IPriorityQueue <int, TValue> NewHotPriorityQueue <TValue>(int initialSize)
 => HotPriorityQueue.New <TValue>(0, initialSize);