Ejemplo n.º 1
0
        private Coordinates SearchingShot()
        {
            var rand         = new Random(Guid.NewGuid().GetHashCode());
            var hitNeighbors = FiringBoard.GetHitNeighbors();
            var neighborID   = rand.Next(hitNeighbors.Count);

            return(hitNeighbors[neighborID]);
        }
Ejemplo n.º 2
0
        public Coordinates FireShot()
        {
            //If there are hits on the board with neighbors which don't have shots, we should fire at those first.
            var         hitNeighbors = FiringBoard.GetHitNeighbors();
            Coordinates coords;

            if (hitNeighbors.Any())
            {
                coords = SearchingShot();
            }
            else
            {
                coords = RandomShot();
            }
            Console.WriteLine(Name + " says: \"Firing shot at " + coords.Row.ToString() + ", " + coords.Column.ToString() + "\"");
            return(coords);
        }