예제 #1
0
        public void Simple2()
        {
            var map = ConstantMapGenerator.GenerateFilled(5, 3);

            var path = map.GetPath(map[0, 0], map[4, 2]);

            path.Length.Should().Be(4);
        }
예제 #2
0
        public void Empty()
        {
            var map = ConstantMapGenerator.GenerateFilled(10, 10);

            var path = map.GetPath(map[1, 1], map[1, 1]);

            path.Should().BeEmpty();
        }
예제 #3
0
        public void Wall1()
        {
            var map = ConstantMapGenerator.GenerateFilled(5, 3);

            map[2, 1] = new Brick(new Vector2Int(2, 1));

            var path = map.GetPath(map[0, 0], map[4, 2]);

            path.Length.Should().Be(5);
        }
예제 #4
0
        public void Simple_OneStep()
        {
            var map = ConstantMapGenerator.GenerateFilled(5, 3);

            var path     = map.GetPath(map[0, 0], map[1, 0]);
            var expected = new[]
            {
                new Vector2Int(1, 0)
            };

            path.Select(x => x.Cords).Should().BeEquivalentTo(expected);
        }
예제 #5
0
        public void BenchmarkTest()
        {
            var map    = ConstantMapGenerator.GenerateFilled(100, 100);
            var random = new Random();

            /*for (var i = 500_00000; i > 0; i--)
             * {
             *  var x = random.Next(9999);
             *  var y = random.Next(9999);
             *  map[x, y] = new Brick(x, y);
             * }*/
            var start = new Sand(0, 0);
            var end   = new Sand(99, 99);

            Console.WriteLine(Test(() => map.GetPath(start, end)));
        }
예제 #6
0
        public void Wall2()
        {
            var map = ConstantMapGenerator.GenerateFilled(5, 3);

            map[2, 1] = new Brick(new Vector2Int(2, 1));
            map[2, 2] = new Brick(new Vector2Int(2, 2));
            map[3, 1] = new Brick(new Vector2Int(3, 1));
            map[3, 2] = new Brick(new Vector2Int(3, 2));

            var path     = map.GetPath(map[0, 0], map[4, 2]);
            var expected = new[]
            {
                new Vector2Int(1, 0),
                new Vector2Int(2, 0),
                new Vector2Int(3, 0),
                new Vector2Int(4, 0),
                new Vector2Int(4, 1),
                new Vector2Int(4, 2)
            };

            path.Select(x => x.Cords).Should().BeEquivalentTo(expected);
        }