Example #1
0
        public void FindAllPathsToAllGoals_SmallMapWithTwoGoals_Finds2PathsWith6Points()
        {
            string mapRepresentation = @"########
                                      #....#.#
                                      #.#..#.#
                                      #.#..#.#
                                      #......#
                                      ########";
            IMapCreationStrategy <Map> mapCreationStrategy = new StringDeserializeMapCreationStrategy <Map>(mapRepresentation);
            IMap map = Map.Create(mapCreationStrategy);

            GoalMap goalMap = new GoalMap(map);

            goalMap.AddGoal(1, 1, 0);
            goalMap.AddGoal(6, 1, 0);
            List <List <Point> > paths = goalMap.FindAllPathsToAllGoals(3, 4);

            string expectedGoalMapRepresentation = @"#    #    #    #    #    #    #    #
                                                  #    0    1    2    3    #    0    #
                                                  #    1    #    3    4    #    1    #
                                                  #    2    #    4    5    #    2    #
                                                  #    3    4    5    5    4    3    #
                                                  #    #    #    #    #    #    #    #";

            Assert.AreEqual(expectedGoalMapRepresentation.Replace(" ", string.Empty), goalMap.ToString().Replace(" ", string.Empty));
            Assert.AreEqual(2, paths.Count);
            Assert.AreEqual(6, paths[0].Count);
            Assert.AreEqual(6, paths[1].Count);
        }
Example #2
0
        public void FindAllPathsToAllGoals_SmallMapWithTwoGoals_Finds2PathsWith6Points()
        {
            string mapRepresentation = @"########
                                      #....#.#
                                      #.#..#.#
                                      #.#..#.#
                                      #......#
                                      ########";
             IMapCreationStrategy<Map> mapCreationStrategy = new StringDeserializeMapCreationStrategy<Map>( mapRepresentation );
             IMap map = Map.Create( mapCreationStrategy );

             GoalMap goalMap = new GoalMap( map );
             goalMap.AddGoal( 1, 1, 0 );
             goalMap.AddGoal( 6, 1, 0 );
             List<List<Point>> paths = goalMap.FindAllPathsToAllGoals( 3, 4 );

             string expectedGoalMapRepresentation = @"#    #    #    #    #    #    #    #
                                                  #    0    1    2    3    #    0    #
                                                  #    1    #    3    4    #    1    #
                                                  #    2    #    4    5    #    2    #
                                                  #    3    4    5    5    4    3    #
                                                  #    #    #    #    #    #    #    #";
             Assert.AreEqual( expectedGoalMapRepresentation.Replace( " ", string.Empty ), goalMap.ToString().Replace( " ", string.Empty ) );
             Assert.AreEqual( 2, paths.Count );
             Assert.AreEqual( 6, paths[0].Count );
             Assert.AreEqual( 6, paths[1].Count );
        }