private void map_LandmarkTapped_1(object sender, Bing.Maps.LandmarkTappedEventArgs e) { landmarkDetailsPanel.Children.Clear(); LandmarkCollection landmarks = e.Landmarks; foreach (Landmark landmark in landmarks) { TextBlock landmarkName = new TextBlock(); landmarkName.Text = "Name: " + landmark.Name; landmarkDetailsPanel.Children.Add(landmarkName); TextBlock landmarkType = new TextBlock(); landmarkType.Text = "Type: " + landmark.Type; landmarkDetailsPanel.Children.Add(landmarkType); TextBlock landmarkLocationLatitude = new TextBlock(); landmarkLocationLatitude.Text = "Latitude: " + landmark.Location.Latitude; landmarkDetailsPanel.Children.Add(landmarkLocationLatitude); TextBlock landmarkLocationLongitude = new TextBlock(); landmarkLocationLongitude.Text = "Longitude: " + landmark.Location.Longitude; landmarkLocationLongitude.Margin = new Thickness(0, 0, 0, 10); landmarkDetailsPanel.Children.Add(landmarkLocationLongitude); } }
/// <summary>TODO</summary> /// <param name="landmarkCoords"><see cref="IFastList{HexCoords}"/> of the hexes to be used as Path-Finding landmarks.</param> /// <returns></returns> protected Exception ResetLandmarks(IFastList <HexCoords> landmarkCoords) { try { #if true Landmarks = (this as IBoard <IHex>).CreateLandmarksHotQueue(landmarkCoords); #else Landmarks = LandmarkCollection.New(this, landmarkCoords); #endif OnLandmarksReady(new EventArgs <ILandmarks>(Landmarks)); return(null); } catch (Exception ex) { return(ex); } }
protected HexBoard(Size sizeHexes, Size gridSize, Func <HexBoard <THex>, BoardStorage <THex> > initializeBoard, ReadOnlyCollection <HexCoords> landmarkCoords ) { if (initializeBoard == null) { throw new ArgumentNullException("initializeBoard"); } SetGridSize(sizeHexes, gridSize); BoardHexes = initializeBoard(this); Landmarks = LandmarkCollection.CreateLandmarks(this, landmarkCoords); }
private void SetLandmarks(IFastList <HexCoords> landmarkCoords) { ILandmarks tempLandmarks = null; ILandmarks landmarks = null; try { tempLandmarks = LandmarkCollection.CreateLandmarks(this, landmarkCoords); landmarks = tempLandmarks; tempLandmarks = null; } finally { if (tempLandmarks != null) { tempLandmarks.Dispose(); } } Landmarks = landmarks; }
BidirectionalPathfinder(IHex start, IHex goal, LandmarkCollection landmarks, HashSet<HexCoords> closed, Func<double> getBestSoFar ) { _start = start; _goal = goal; _getBestSoFar = getBestSoFar; _vectorGoal = goal.Coords.Canon - start.Coords.Canon; _open = new Dictionary<HexCoords, DirectedPath>(); _closed = closed; _queue = new HotPriorityQueue<DirectedPath>(16); _landmark = landmarks .OrderByDescending(l => l.HexDistance(goal.Coords) - l.HexDistance(start.Coords)) .FirstOrDefault(); _heuristic = c => _landmark.HexDistance(c) - _landmark.HexDistance(start.Coords); var path = new DirectedPath(goal); _open.Add(goal.Coords, path); _queue.Enqueue(0, path); }
/// <summary>TODO</summary> /// <param name="landmarkCoords"><see cref="IFastList{HexCoords}"/> of the hexes to be used as Path-Finding landmarks.</param> /// <returns></returns> protected bool ResetLandmarks(IFastList <HexCoords> landmarkCoords) { Landmarks = LandmarkCollection.New(this, landmarkCoords); OnLandmarksReady(new EventArgs <ILandmarks>(Landmarks)); return(true); }
/// <summary>Create a new instance of <see cref="PathfinderRev"/>.</summary> /// <param name="start"></param> /// <param name="goal"></param> /// <param name="stepCost"></param> /// <param name="landmarks"></param> /// <param name="closed"></param> /// <param name="setBestSoFar"></param> /// <param name="getBestSoFar"></param> public PathfinderRev(IHex start, IHex goal, Func<IHex, Hexside, double> stepCost, LandmarkCollection landmarks, HashSet<HexCoords> closed, Action<DirectedPath, DirectedPath> setBestSoFar, Func<double> getBestSoFar ) : base(goal, start, landmarks, closed, getBestSoFar) { _addStep = (path, there, hexside, cost) => path.AddStep(there, hexside.Reversed(), cost); _setBestSoFar = (self, partner) => setBestSoFar(partner, self); _stepCost = (here, hexside, there) => stepCost(here, hexside); //_search = "Rev"; }
/// <summary>Returns an <c>IPath</c> for the optimal path from coordinates <c>start</c> to <c>goal</c>.</summary> /// <param name="start">Coordinates for the <c>last</c> step on the desired path.</param> /// <param name="goal">Coordinates for the <c>first</c> step on the desired path.</param> /// <param name="stepCost">Cost to extend path by hex at <c>coords</c> from hex at direction <c>hexside</c>.</param> /// <param name="landmarks"><c>LandmarkCollection</c> of landmarks available for heuristic calculation.</param> static PathHalves FindDirectedPath( IHex start, IHex goal, Func<IHex, Hexside, double> stepCost, LandmarkCollection landmarks ) { if (start == null) throw new ArgumentNullException("start"); if (goal == null) throw new ArgumentNullException("goal"); if (stepCost == null) throw new ArgumentNullException("stepCost"); if (landmarks == null) throw new ArgumentNullException("landmarks"); var closed = new HashSet<HexCoords>(); var pathHalves = new PathHalves(); var pathfinderFwd = new PathfinderFwd(start, goal, stepCost, landmarks, closed, pathHalves.SetBestSoFar, () => pathHalves.BestSoFar); var pathfinderRev = new PathfinderRev(start, goal, stepCost, landmarks, closed, pathHalves.SetBestSoFar, () => pathHalves.BestSoFar); pathfinderFwd.Partner = pathfinderRev; var pathfinder = pathfinderRev.Partner = pathfinderFwd; while (!pathfinder.IsFinished()) pathfinder = pathfinder.Partner; return pathHalves; }