Example #1
0
        public void TestCreateNoiseSourceWhisWall()
        {
            var width  = 3;
            var height = 3;

            GameSetter.SetMapAndFillWithDecors(width, height, new List <Tuple <Point, IDecor> >
            {
                Tuple.Create(new Point(1, 1), (IDecor) new Wall()),
                Tuple.Create(new Point(1, 0), (IDecor) new Wall())
            });
            var map    = GetMap(width, height);
            var sourse = new NoiseSource(NoiseType.GuardVoice, 1, 4, new Point(2, 1), "");

            Dijkstra.DijkstraTraversal(map, sourse, (noises, noise) => { noises.Add(noise); });
            var mapAnswer = GetMap(width, height);

            ChangeMap(mapAnswer,
                      Tuple.Create(new Point(0, 0), new Noise(sourse, 1)),
                      Tuple.Create(new Point(0, 1), new Noise(sourse, 2)),
                      Tuple.Create(new Point(0, 2), new Noise(sourse, 2)),
                      Tuple.Create(new Point(1, 2), new Noise(sourse, 3)),
                      Tuple.Create(new Point(2, 0), new Noise(sourse, 3)),
                      Tuple.Create(new Point(2, 1), new Noise(sourse, 4)),
                      Tuple.Create(new Point(2, 2), new Noise(sourse, 3)));
            CheckMap(map, mapAnswer);
        }
Example #2
0
        public void TestCreateTwoNoiseSource()
        {
            var width  = 2;
            var height = 2;

            GameSetter.SetMapAndFillWithDecors(width, height, new List <Tuple <Point, IDecor> >());
            var map     = GetMap(width, height);
            var sourse1 = new NoiseSource(NoiseType.GuardVoice, 1, 2, new Point(1, 1), "");
            var sourse2 = new NoiseSource(NoiseType.GuardVoice, 1, 2, new Point(0, 0), "");

            Dijkstra.DijkstraTraversal(map, sourse1, (noises, noise) => { noises.Add(noise); });
            Dijkstra.DijkstraTraversal(map, sourse2, (noises, noise) => { noises.Add(noise); });
            var mapAnswer = GetMap(width, height);

            ChangeMap(mapAnswer,
                      Tuple.Create(new Point(0, 0), new Noise(sourse1, 1)),
                      Tuple.Create(new Point(0, 1), new Noise(sourse1, 1)),
                      Tuple.Create(new Point(1, 0), new Noise(sourse1, 1)),
                      Tuple.Create(new Point(1, 1), new Noise(sourse1, 2)));
            ChangeMap(mapAnswer,
                      Tuple.Create(new Point(0, 0), new Noise(sourse2, 2)),
                      Tuple.Create(new Point(0, 1), new Noise(sourse2, 1)),
                      Tuple.Create(new Point(1, 0), new Noise(sourse2, 1)),
                      Tuple.Create(new Point(1, 1), new Noise(sourse2, 1)));

            CheckMap(map, mapAnswer);
        }
        public void ShortestPathSearchWithSolidObject()
        {
            GameSetter.SetMapAndFillWithDecors(4, 3, new List <Tuple <Point, IDecor> >
            {
                Tuple.Create(new Point(1, 2), (IDecor) new Wall()),
                Tuple.Create(new Point(3, 1), (IDecor) new Wall())
            });

            var from      = new Point(0, 1);
            var to        = new Point(3, 2);
            var direction = Direction.Down;

            var answer = new List <Query>
            {
                Query.RotateLeft,
                Query.Move,
                Query.Move,
                Query.RotateRight,
                Query.Move,
                Query.RotateLeft,
                Query.Move
            };
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }
        public void ZeroPath()
        {
            GameSetter.SetMapAndFillWithDecors(2, 2, new List <Tuple <Point, IDecor> >());

            var from      = new Point(0, 0);
            var to        = new Point(0, 0);
            var direction = Direction.Down;

            var answer = new List <Query>();
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }
Example #5
0
        public void TestRemoveNoiseSourceWithLowIntensity()
        {
            var width  = 5;
            var height = 5;

            GameSetter.SetMapAndFillWithDecors(width, height, new List <Tuple <Point, IDecor> >());
            var map    = GetMap(width, height);
            var sourse = new NoiseSource(NoiseType.GuardVoice, 1, 2, new Point(2, 2), "");

            Dijkstra.DijkstraTraversal(map, sourse, (noises, noise) => { noises.Add(noise); });
            Dijkstra.DijkstraTraversal(map, sourse, (noises, noise) => { noises.Remove(noise); });
            var mapAnswer = GetMap(width, height);

            CheckMap(map, mapAnswer);
        }
        public void ShortestPathSearch()
        {
            GameSetter.SetMapAndFillWithDecors(3, 2, new List <Tuple <Point, IDecor> >());

            var from      = new Point(0, 0);
            var to        = new Point(2, 1);
            var direction = Direction.Down;

            var answer = new List <Query> {
                Query.Move, Query.RotateRight, Query.Move, Query.Move
            };
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }
        public void NoPath()
        {
            GameSetter.SetMapAndFillWithDecors(3, 3, new List <Tuple <Point, IDecor> >
            {
                Tuple.Create(new Point(1, 0), (IDecor) new Wall()),
                Tuple.Create(new Point(1, 1), (IDecor) new Wall()),
                Tuple.Create(new Point(1, 2), (IDecor) new Wall())
            });

            var from      = new Point(0, 0);
            var to        = new Point(2, 0);
            var direction = Direction.Down;

            var answer = new List <Query>();
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }
        public void ShortestPathSearchWithMobileObject()
        {
            GameSetter.SetMapAndFillWithDecors(3, 3, new List <Tuple <Point, IDecor> >());
            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature>
            {
                MobileObjectsManager.GetCreatureByNameAndInitParams(
                    CreatureTypes.Guard, new MobileObjectInitialization(new Point(1, 1), Direction.Down))
            });

            var from      = new Point(1, 0);
            var to        = new Point(1, 2);
            var direction = Direction.Down;

            var answer = new List <Query>
            {
                Query.Move,
                Query.Move
            };
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }