private void CreateTiles() { foreach (Point pos in SudokuFactory.Box(_tiles.GetLength(0), _tiles.GetLength(1))) { _tiles[pos.X, pos.Y] = new SudokuTile(pos.X, pos.Y, _maxValue); } }
internal void AddBoxesCount(int boxesX, int boxesY) { int sizeX = Width / boxesX; int sizeY = Height / boxesY; IEnumerable <SudokuTile> TileBox(int startX, int startY) => SudokuFactory.Box(sizeX, sizeY).Select(pos => _tiles[startX + pos.X, startY + pos.Y]); IEnumerable <Point> boxes = SudokuFactory.Box(sizeX, sizeY); foreach (Point pos in boxes) { CreateRule($"Box at ({pos.X}, {pos.Y})", TileBox(pos.X * sizeX, pos.Y * sizeY)); } }
internal SudokuBoard(SudokuBoard copy) { _maxValue = copy._maxValue; _tiles = new SudokuTile[copy.Width, copy.Height]; CreateTiles(); // Copy the tile values foreach (Point pos in SudokuFactory.Box(Width, Height)) { _tiles[pos.X, pos.Y] = new SudokuTile(pos.X, pos.Y, _maxValue) { Value = copy[pos.X, pos.Y].Value }; } // Copy the rules _rules = copy._rules .Select(rule => new SudokuRule(rule.Select(tile => _tiles[tile.X, tile.Y]), rule.Description)) .ToList(); }