Exemple #1
0
        /// <summary>
        /// bt爆搜寻路(可搜折返),单向寻路,以进路为单位搜索
        /// </summary>
        /// <param name="Now"></param>
        /// <param name="res"></param>
        /// <param name="tempRoutes"></param>
        /// <param name="src"></param>
        /// <param name="tar"></param>
        /// <param name="k"></param>
        /// <param name="used"></param>
        void SearchSinglePath(ATSRoute Now, List <OptionalRoutes> res, OptionalRoutes tempRoutes, string tar, int k, HashSet <ATSRoute> routeUsed, RouteDirection routedir, int maxY, int minY)
        {
            if (k > deepth || res.Count > MaxResNum)
            {
                return;
            }
            foreach (var de in Now.InSections)
            {
                if (de.Name == tar)
                {
                    tempRoutes.UpdateDistance();
                    res.Add(new OptionalRoutes(tempRoutes));
                    return;
                }
            }

            foreach (var possibleRoute in Now.OptionalRoutes)
            {
                ATS.Signal signal = possibleRoute.StartSignal as ATS.Signal;
                double     y      = Canvas.GetTop(signal);
                if (possibleRoute.Dir == routedir && y >= minY && y <= maxY && !routeUsed.Contains(possibleRoute))
                //if (possibleRoute.Dir == routedir)
                {
                    tempRoutes.Routes.Add(possibleRoute);
                    routeUsed.Add(possibleRoute);
                    SearchSinglePath(tempRoutes.Routes.Last(), res, tempRoutes, tar, k + 1, routeUsed, routedir, maxY, minY);
                    tempRoutes.Routes.Remove(tempRoutes.Routes.Last());
                    routeUsed.Remove(possibleRoute);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// bt爆搜寻路
 /// </summary>
 /// <param name="Now"></param>
 /// <param name="res"></param>
 /// <param name="tempRoutes"></param>
 /// <param name="src"></param>
 /// <param name="tar"></param>
 /// <param name="k"></param>
 /// <param name="used"></param>
 void SearchPathBy(Device Now, List <OptionalRoutes> res, OptionalRoutes tempRoutes, string src, string tar, int k, HashSet <int> used, RouteDirection routedir)
 {
     if (k > deepth || res.Count > MaxResNum)
     {
         return;
     }
     if (Now.Name == tar)
     {
         tempRoutes.UpdateDistance();
         res.Add(new OptionalRoutes(tempRoutes));
     }
     else
     {
         List <ATSRoute> PossibleRoutes = Routes.FindAll((ATSRoute route) =>
         {
             foreach (Device d in route.IncomingSections)
             {
                 if (d.Name == Now.Name && !used.Contains(route.ID))
                 {
                     return(true);
                 }
             }
             return(false);
         });
         if (PossibleRoutes != null)
         {
             foreach (ATSRoute route in PossibleRoutes)
             {
                 if (route.Dir == routedir)
                 {
                     tempRoutes.Routes.Add(route);
                     used.Add(route.ID);
                     SearchPathBy(route.InSections.Last(), res, tempRoutes, src, tar, k + 1, used, routedir);
                     tempRoutes.Routes.Remove(tempRoutes.Routes.Last());
                     used.Remove(route.ID);
                 }
             }
         }
     }
 }