Example #1
0
        /// <summary>
        /// 找到最短路径的place
        /// </summary>
        /// <returns></returns>
        static Place MinPlace(List <Place> openList, Place endPlace)
        {
            Place place = null;

            foreach (Place item in openList)
            {
                //int parentG = 0;
                //if (item.ParentPlace != null)
                //{
                //    parentG = item.DistrictList.Sum(obj => obj.CrossingTime);
                //}

                int G = item.DistrictList.Sum(obj => obj.CrossingTime) /*+ parentG*/;
                int H = (int)Draw.ComparePoints(item.Coordinate, endPlace.Coordinate);
                int F = G + H;
                if (place == null || place.DistrictList.Sum(obj => obj.CrossingTime) + (int)Draw.ComparePoints(place.Coordinate, endPlace.Coordinate) > F)
                {
                    place = item;
                }
            }
            return(place);
        }