Exemple #1
0
 public static void Display(Ocean ocean, int iterNum)
 {
     Console.SetWindowSize(100, 40);
     Console.CursorVisible = false;
     DisplayStats(iterNum, ocean);
     DisplayBorder(ocean);
     DisplayCells(ocean);
 }
Exemple #2
0
 private static void DisplayBorder(Ocean ocean)
 {
     for (int i = 0; i < ocean.NumCols; i++)
     {
         Console.SetCursorPosition(initX + i, initY - 1);
         Console.Write("*");
         Console.SetCursorPosition(initX + i, initY + ocean.NumRows);
         Console.Write("*");
     }
 }
        public object Clone()
        {
            Ocean clone = (Ocean)MemberwiseClone();

            Cell [,] cellClone = new Cell[NumCols, NumRows];
            for (int y = 0; y < NumRows; y++)
            {
                for (int x = 0; x < NumCols; x++)
                {
                    if (_cells[x, y] != null)
                    {
                        cellClone[x, y] = (Cell)_cells[x, y].Clone();
                    }
                }
            }
            return(clone);
        }
Exemple #4
0
 private static void DisplayCells(Ocean ocean)
 {
     for (byte y = 0; y < ocean.NumRows; y++)
     {
         for (byte x = 0; x < ocean.NumCols; x++)
         {
             if (ocean[new Coordinate(x, y)] != null)
             {
                 Console.SetCursorPosition(initX + x, initY + y);
                 Console.Write(ocean[new Coordinate(x, y)].Image);
             }
             else
             {
                 Console.SetCursorPosition(initX + x, initY + y);
                 Console.Write("-");
             }
         }
     }
 }
 public static void Initialize()
 {
     Ocean1 = new Ocean();
     Ocean1.InitCells();
 }
Exemple #6
0
 private static void DisplayStats(int iterNum, Ocean ocean)
 {
     Console.SetCursorPosition(0, 0);
     Console.WriteLine("Iteration: {0}  Obstacles: {1}  Megalodons: {2}  Shark: {3}  Stingray: {4} Tuna: {5} ", iterNum, ocean.NumObstacles, ocean.NumMegalodon, ocean.NumShark, ocean.NumStingray, ocean.NumTuna);
     Console.WriteLine("   Number born prey: {0}  Number born predators: {1}  Number of eaten prey: {2} ", ocean.NumBornPrey, ocean.NumBornPredators, ocean.NumEaten);
 }
Exemple #7
0
 private static void DisplayStats(int iterNum, Ocean ocean)
 {
     Console.SetCursorPosition(0, 0);
     Console.WriteLine("   Iteration number: {0}  Obstacles: {1}  Predators: {2}  Preys: {3} ", iterNum, ocean.NumObstacles, ocean.NumPredators, ocean.NumPreys);
     Console.WriteLine("   Number born prey: {0}  Number born predators: {1}  Number of eaten prey: {2} ", ocean.NumBornPrey, ocean.NumBornPredators, ocean.NumEaten);
 }