Ejemplo n.º 1
0
        public void Bfs_ShouldReturnCorrectPath_OnMapWithStairs()
        {
            var str       = "     \r\nTTTLT\r\n   L \r\nTTTTT";
            var path      = new Point[] { new Point(2, 2), new Point(3, 2), new Point(3, 1), new Point(3, 0), new Point(2, 0) };
            var resultBfs = Bfs.FindPaths(str, new Point(2, 2), new Point(2, 0));

            AssertPath(resultBfs, path);
        }
Ejemplo n.º 2
0
        public void Bfs_ShouldReturnCorrectPath_WhenPathLeadStairs()
        {
            var str       = "   \r\nTTL\r\n   ";
            var path      = new Point[] { new Point(0, 0), new Point(1, 0), new Point(2, 0), new Point(2, 1) };
            var resultBfs = Bfs.FindPaths(str, new Point(0, 0), new Point(2, 1));

            AssertPath(resultBfs, path);
        }
Ejemplo n.º 3
0
        public void Bfs_ShouldReturnCorrectPath_OnSimpleMap()
        {
            var str       = "     \r\nTTTTT";
            var path      = new Point[] { new Point(3, 0), new Point(2, 0), new Point(1, 0), new Point(0, 0) };
            var resultBfs = Bfs.FindPaths(str, new Point(3, 0), new Point(0, 0));

            AssertPath(resultBfs, path);
        }
Ejemplo n.º 4
0
        public void Bfs_ShouldReturnCorrectPath_WhenSeveralPaths()
        {
            var str  = "      \r\nLTTTLT\r\nL   L \r\nTTTTTT";
            var path = new Point[] { new Point(2, 2), new Point(1, 2),
                                     new Point(0, 2), new Point(0, 1), new Point(0, 0), new Point(1, 0) };
            var resultBfs = Bfs.FindPaths(str, new Point(2, 2), new Point(1, 0));

            AssertPath(resultBfs, path);
        }
Ejemplo n.º 5
0
 public Move Act(Level level, int x, int y)
 {
     if (y + 1 <= level.Height - 1 &&
         !(level.CheckCreature(x, y + 1, typeof(Terrain)) ||
         level.CheckCreature(x, y + 1, typeof(Stairs))))
         return new Move { DeltaY = 1 };
     if (Status == Status.Inactive)
         return new Move();
     var player = FindPlayer(level);
     if (player is null)
         return new Move();
     var path = Bfs.FindPaths(level.TextInitiallyMap, new Point(x, y), new Point(player.Value.X, player.Value.Y));
     if (path is null)
         return new Move();
     return new Move() { DeltaX = path.Previous.Value.X - x, DeltaY = path.Previous.Value.Y - y };
 }
Ejemplo n.º 6
0
        public void Bfs_ShouldReturnNull_WhenPointInBottomMap()
        {
            var str = "   \r\nTTT\r\n";

            Assert.IsNull(Bfs.FindPaths(str, new Point(0, 0), new Point(2, 1)));
        }
Ejemplo n.º 7
0
        public void Bfs_ShouldReturnNull_WhenPathNotExist()
        {
            var str = "   \r\nTTT\r\n   ";

            Assert.IsNull(Bfs.FindPaths(str, new Point(0, 2), new Point(0, 0)));
        }
Ejemplo n.º 8
0
        public void Bfs_ShouldReturnNull_WhenStairsFar()
        {
            var str = "   \r\nTTL\r\n  L\r\n   \r\nTTT";

            Assert.IsNull(Bfs.FindPaths(str, new Point(0, 3), new Point(0, 0)));
        }
Ejemplo n.º 9
0
 public void Bfs_ShouldReturnNull_WhenEmptyMap()
 {
     Assert.IsNull(Bfs.FindPaths(" ", new Point(), new Point()));
 }