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); } }
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); }
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); }
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); }
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); }