Exemple #1
0
        public void BestLocationForStation(out int outputRow, out int outputCol)
        {
            //AsteroidMap map = new AsteroidMap((string[])this.rows.Clone());
            int bestCountOfVisibileAsteroids = int.MinValue;
            int bestRow = int.MinValue;
            int bestCol = int.MaxValue;

            for (int row = 0; row < this.mapHeight; row++)
            {
                for (int col = 0; col < this.mapWidth; col++)
                {
                    if (this.GetCell(row, col) == ASTEROID)
                    {
                        AsteroidMap visibilityMap = this.VisibilityMap(row, col);

                        int visibilityCount = visibilityMap.VisibileAsteroidCount();
                        // map.SetCell(row, col, visibilityCount.ToString());

                        if (visibilityCount > bestCountOfVisibileAsteroids)
                        {
                            bestCountOfVisibileAsteroids = visibilityCount;
                            bestRow = row;
                            bestCol = col;
                        }
                    }
                }
            }

            Console.WriteLine("Best visibility: " + bestCountOfVisibileAsteroids + " asteroids if station is at " + bestCol + "," + bestRow);
            outputRow = bestRow;
            outputCol = bestCol;
            return;
        }
Exemple #2
0
        public void SpitOutVisibilityMapInfo(int row, int col)
        {
            AsteroidMap visibilityMap = this.VisibilityMap(row, col);

            if (visibilityMap == null)
            {
                Console.WriteLine("No asteroid at " + col + "," + row + "!");
                return;
            }

            visibilityMap.PrintOut();
            Console.WriteLine("Total asteroids: " + this.AsteroidCount());
            Console.WriteLine("Total visible asteroids at " + col + "," + row + ": " + visibilityMap.VisibileAsteroidCount());
        }