Exemplo n.º 1
0
 public Gunner(int rows, int cols, IEnumerable <int> shipLengths)
 {
     evidenceGrid           = new Grid(rows, cols);
     shipsToShoot           = new List <int>(shipLengths.OrderByDescending(l => l));
     ShootingTactics        = ShootingTactics.Random;
     squareTerminator       = new SquareTerminator(rows, cols);
     shootingTacticsFactory = new ShootingTacticsFactory(evidenceGrid, squaresHit, shipsToShoot);
     targetSelect           = shootingTacticsFactory.GetTactics(ShootingTactics.Random);
 }
Exemplo n.º 2
0
        private void ChangeTactics(HitResult hitResult)
        {
            if (hitResult == HitResult.Sunken)
            {
                ShootingTactics = ShootingTactics.Random;
            }
            if (hitResult == HitResult.Hit)
            {
                switch (ShootingTactics)
                {
                case ShootingTactics.Random:
                    ShootingTactics = ShootingTactics.Surrounding;
                    break;

                case ShootingTactics.Surrounding:
                    ShootingTactics = ShootingTactics.Inline;
                    break;

                case ShootingTactics.Inline:
                    return;
                }
            }
            targetSelect = ShootingTacticsFactory.GetTactics(ShootingTactics);
        }