Ejemplo n.º 1
0
        public void RandomShooting_3()
        {
            //Arrange
            Map map = new Map(10, 10);

            map.CellsStatuses[5, 5] = CellStatus.DamagedPartOfShip;
            map.CellsStatuses[5, 6] = CellStatus.DamagedPartOfShip;
            map.CellsStatuses[5, 7] = CellStatus.PartOfShip;
            Random random = new Random();

            List <Coordinates> shotCoordinates = new List <Coordinates>();


            //Act
            for (int i = 0; i < 1000; i++)
            {
                Coordinates shotCoord = NotAi.MakeShot(ref map, random);
                shotCoordinates.Add(shotCoord);
            }


            //Assert
            Coordinates coord1 = new Coordinates(5, 4);
            Coordinates coord2 = new Coordinates(5, 7);

            foreach (var coordinate in shotCoordinates)
            {
                Assert.IsTrue(coordinate == coord1 || coordinate == coord2);
            }
        }
Ejemplo n.º 2
0
        public void RandomShooting_2()
        {
            //Arrange
            Map    map    = new Map(10, 10);
            Random random = new Random(314159265);

            //Act
            Coordinates shotCoordinates = NotAi.MakeShot(ref map, random);

            Console.WriteLine(shotCoordinates);

            //Assert
            Assert.AreEqual(new Coordinates(4, 4), shotCoordinates);
        }
Ejemplo n.º 3
0
        public void ShotAlong_1()
        {
            //Arrange
            Map map = new Map(10, 10);

            map.CellsStatuses[0, 0] = CellStatus.DamagedPartOfShip;
            map.CellsStatuses[0, 1] = CellStatus.DamagedPartOfShip;
            Random random = new Random();
            //Act
            Coordinates shotCoordinates = NotAi.MakeShot(ref map, random);

            //Assert
            Assert.AreEqual(shotCoordinates, new Coordinates(0, 2));
        }
        public void CrossfireShooting_LowerLeftCorner_1()
        {
            //Arrange
            Map map = new Map(10, 10);

            map.CellsStatuses[0, 0] = CellStatus.DamagedPartOfShip;
            Random random = new Random(3163999);

            //Act
            Coordinates shotCoordinates = NotAi.MakeShot(ref map, random);

            Console.WriteLine(shotCoordinates);

            //Assert
            Assert.AreEqual(new Coordinates(0, 1), shotCoordinates);
        }
        public void CrossfireShooting_Right()
        {
            //Arrange
            Map map = new Map(10, 10);

            map.CellsStatuses[2, 4] = CellStatus.DamagedPartOfShip;
            Random random = new Random(314159);

            //Act
            Coordinates shotCoordinates = NotAi.MakeShot(ref map, random);

            Console.WriteLine(shotCoordinates);

            //Assert
            Assert.AreEqual(new Coordinates(3, 4), shotCoordinates);
        }
Ejemplo n.º 6
0
        public void RandomShooting_2()
        {
            //Arrange
            Map map = new Map(10, 10);

            map.CellsStatuses[5, 5] = CellStatus.DamagedPartOfShip;
            map.CellsStatuses[5, 6] = CellStatus.DamagedPartOfShip;
            map.CellsStatuses[5, 7] = CellStatus.PartOfShip;
            Random random = new Random(41459);

            //Act
            Coordinates shotCoordinates = NotAi.MakeShot(ref map, random);

            Console.WriteLine(shotCoordinates);

            //Assert
            Assert.AreEqual(new Coordinates(5, 4), shotCoordinates);
        }
Ejemplo n.º 7
0
        public ShotResult PlayerAutoShot(Player player)
        {
            Coordinates coordinates;

            switch (player)
            {
            case Player.First:
                coordinates = NotAi.MakeShot(ref _player2Map);
                break;

            case Player.Second:
                coordinates = NotAi.MakeShot(ref _player1Map);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(player), player, null);
            }
            var shotResult = PlayerShot(player, coordinates);

            return(shotResult);
        }