コード例 #1
0
ファイル: AdmiralSolver.cs プロジェクト: nlhans/NWERC-2012
        public List<List<Route>> Visit(int targetID, Waypoint waypoint, List<Route> route)
        {
            List<List<Route>> routes = new List<List<Route>>();

            foreach(Passage passage in waypoint.Routes)
            {
                if (route.Any(x => x.Start == passage.Target))
                {
                    continue;
                }

                List<Route> followedRoute = new List<Route>(route);
                followedRoute.Add(new Route(waypoint, passage));
                if(passage.Target.ID == targetID)
                {
                    routes.Add(followedRoute);
                }
                else
                {
                    routes.AddRange(Visit(targetID, passage.Target, followedRoute));
                }
            }

            return routes;
        }
コード例 #2
0
ファイル: AdmiralSolver.cs プロジェクト: nlhans/NWERC-2012
        private static Waypoint GetOrCreate(int id, SortedList<int, Waypoint> waypoints)
        {
            Waypoint waypoint;

            if (!waypoints.ContainsKey(id))
            {
                waypoint = new Waypoint(id);
                waypoints.Add(id, waypoint);
            }
            else
            {
                waypoint = waypoints[id];
            }

            return waypoint;
        }