Пример #1
0
        public void RouteTestNoSystemsInRange()
        {
            // You can't get from Olgrea to Sheela Na Gig with 5LY jumps, it is 6.597303LY
            DataSetup();
            var j = new RouteFinder();

            j.JumpRange = 5;
            var route = j.Route(EDSystemManager.Instance.Find("Olgrea"), EDSystemManager.Instance.Find("Sheela Na Gig"));

            Assert.AreEqual(0, route.Count());
        }
        public void MultiRouteTest()
        {
            DataSetup();
            var mr = new MultiRouteFinder();

            mr.JumpRange = 30.0F;

            var start  = EDSystemManager.Instance.Find("Olgrea");
            var routes = new List <Queue <EDSystem> >();

            var routeA = new Queue <EDSystem>();

            routeA.Enqueue(EDSystemManager.Instance.Find("Te Kaha"));
            routeA.Enqueue(EDSystemManager.Instance.Find("Cao Junga"));
            routes.Add(routeA);

            var routeB = new Queue <EDSystem>();

            routeB.Enqueue(EDSystemManager.Instance.Find("Carnsan"));
            routeB.Enqueue(EDSystemManager.Instance.Find("HIP 13179"));
            routes.Add(routeB);

            var finalRoute = mr.Route(start, routes);

            Assert.AreEqual(6, finalRoute.Count());

            int         i    = 0;
            EDSystem    prev = null;
            RouteFinder r    = new RouteFinder();

            r.JumpRange = 30;

            while (finalRoute.Count() > 0)
            {
                var dest = finalRoute.Dequeue();
                Console.Write($"{i} {dest.name}");
                if (prev != null)
                {
                    var distance = Astrogation.Distance(prev, dest);
                    var jumps    = r.Route(prev, dest).Count();
                    Console.Write($" ({distance:n1} LY, {jumps:n0} jumps)");
                }
                Console.WriteLine();

                prev = dest;
                i++;
            }
        }