Example #1
0
        public List <Cell> GetNeighbours(Coordinates coordinates)
        {
            int row    = coordinates.row;
            int column = coordinates.column;

            List <Cell> neighbouringCells = new List <Cell>();

            if (row > 1)
            {
                neighbouringCells.Add(Cells.At(row - 1, column));
            }
            if (column > 1)
            {
                neighbouringCells.Add(Cells.At(row, column - 1));
            }
            if (row < 10)
            {
                neighbouringCells.Add(Cells.At(row + 1, column));
            }
            if (column < 10)
            {
                neighbouringCells.Add(Cells.At(row, column + 1));
            }

            return(neighbouringCells);
        }
Example #2
0
        public List <Cell> GetNeighbors(Coordinates coordinates)
        {
            byte        one    = 1;
            byte        ten    = 10;
            byte        row    = coordinates.Row;
            byte        column = coordinates.Column;
            List <Cell> cells  = new List <Cell>();

            if (column > one)
            {
                cells.Add(Cells.At(row, column--));
            }
            if (row > one)
            {
                cells.Add(Cells.At(row--, column));
            }
            if (row < ten)
            {
                cells.Add(Cells.At(row++, column));
            }
            if (column < ten)
            {
                cells.Add(Cells.At(row, column++));
            }
            return(cells);
        }
Example #3
0
        /// <summary>
        /// Display the board
        /// TODO - remove this as delegate !!
        /// </summary>
        public override void Display()
        {
            for (int row = 1; row <= BoardSize; row++)
            {
                if (row == 1)
                {
                    Console.Write("    ");
                    for (int col = 1; col <= BoardSize; col++)
                    {
                        char column = (char)(col + 64);
                        Console.Write($"{column} ");
                    }
                    Console.WriteLine(Environment.NewLine);
                }
                Console.Write($"{row,3} ");

                for (int col = 1; col <= BoardSize; col++)
                {
                    var cell = Cells.At(row, col) as GameCell;
                    Console.Write($"{cell.OccupiedState.Description()} ");
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.WriteLine(Environment.NewLine);
        }