Exemplo n.º 1
0
        public void TestViablePath()
        {
            var roads = new TestRoads();


            Assert.AreEqual(1, roads.seg_0_0_10_0.AIRoutes.Length);
            Assert.AreEqual(1, roads.seg_40_0_50_0.AIRoutes.Length);
            Assert.AreEqual(3, roads.seg_0_0_10_0.AIRoutes[0].Paths.Length);
            Assert.AreEqual(3, roads.seg_40_0_50_0.AIRoutes[0].Paths.Length);

            var routeSolver = new RouteSolver(roads.seg_0_0_10_0.AIRoutes, roads.seg_40_0_50_0.AIRoutes);

            while (!routeSolver.IsComplete)
            {
                routeSolver.Iterate();
            }
            Assert.IsTrue(routeSolver.IsSuccess);

            var route = routeSolver.Solution;

            var pathSolver = new PathSolver(roads.seg_0_0_10_0.AIRoutes[0].Paths, roads.seg_40_0_50_0.AIRoutes[0].Paths, route);

            while (!pathSolver.IsComplete)
            {
                pathSolver.Iterate();
            }
            Assert.IsTrue(pathSolver.IsSuccess);
        }
Exemplo n.º 2
0
        private void TestPaths(IAIPath[] from, TestPath[] to, TestRoute[] route)
        {
            var solver = new PathSolver(from, to, route);

            while (solver.Iterate())
            {
            }

            Assert.IsTrue(solver.IsComplete);
            Assert.IsTrue(solver.IsSuccess);
            r.HighlightRoute(route);
            r.HighlightRoute(solver.Solution.OfType <TestPath>());
        }