示例#1
0
        /// <summary>
        /// Returns size of generation
        /// </summary>
        public static WorldSize WorldSize(this CellStatus[,] generation)
        {
            new List <int>().Count();

            return(new WorldSize
            {
                Rows = generation.GetUpperBound(0) + 1,
                Columns = generation.GetUpperBound(1) + 1,
            });
        }
示例#2
0
        /// <summary>
        /// Demonstrate grid according to user inputs: height and width
        /// </summary>
        /// <param name="currentState">uses current state of Cellstatus</param>
        public static void ShowGrid(CellStatus[,] currentState)
        {
            Console.SetCursorPosition(0, 0);
            int x         = 0;
            int rowLength = currentState.GetUpperBound(1) + 1;

            var output = new StringBuilder();

            foreach (var state in currentState)
            {
                output.Append(state == CellStatus.Alive ? "1" : ".");
                x++;
                if (x >= rowLength)
                {
                    x = 0;
                    output.AppendLine();
                }
            }

            Console.Write(output.ToString());
        }