コード例 #1
0
        private bool SetFirstBlankSpace(
            TicTacToeBoard board)
        {
            var allLocations = TicTacToeBoard.GetAllLocations();

            foreach (var location in allLocations)
            {
                if (board.IsCellBlank(location))
                {
                    board.SetCellValue(location, _playerCellValue);
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        private bool MakeBlockOnCells(
            CellValueWithLocation[] cells,
            TicTacToeBoard board)
        {
            for (int n = 0; n < 3; n++)
            {
                if (cells[AllCombos[n, 0]].IsBlank &&
                    cells[AllCombos[n, 1]].CellValue == _opposingCellValue &&
                    cells[AllCombos[n, 2]].CellValue == _opposingCellValue)
                {
                    board.SetCellValue(
                        cells[AllCombos[n, 0]],
                        _playerCellValue);

                    return(true);
                }
            }

            return(false);
        }