private void CreateTiles() { foreach (var pos in SudokuFactory.box(tiles.GetLength(0), tiles.GetLength(1))) { tiles[pos.Item1, pos.Item2] = new SudokuTile(pos.Item1, pos.Item2, _maxValue); } }
internal void AddBoxesCount(int boxesX, int boxesY) { int sizeX = Width / boxesX; int sizeY = Height / boxesY; var boxes = SudokuFactory.box(sizeX, sizeY); foreach (var pos in boxes) { IEnumerable <SudokuTile> boxTiles = TileBox(pos.Item1 * sizeX, pos.Item2 * sizeY, sizeX, sizeY); CreateRule("Box at (" + pos.Item1.ToString() + ", " + pos.Item2.ToString() + ")", boxTiles); } }
public SudokuBoard(SudokuBoard copy) { _maxValue = copy._maxValue; tiles = new SudokuTile[copy.Width, copy.Height]; CreateTiles(); // Copy the tile values foreach (var pos in SudokuFactory.box(Width, Height)) { tiles[pos.Item1, pos.Item2] = new SudokuTile(pos.Item1, pos.Item2, _maxValue); tiles[pos.Item1, pos.Item2].Value = copy.tiles[pos.Item1, pos.Item2].Value; } // Copy the rules foreach (SudokuRule rule in copy.rules) { var ruleTiles = new HashSet <SudokuTile>(); foreach (SudokuTile tile in rule) { ruleTiles.Add(tiles[tile.X, tile.Y]); } rules.Add(new SudokuRule(ruleTiles, rule.Description)); } }
internal IEnumerable <SudokuTile> TileBox(int startX, int startY, int sizeX, int sizeY) { return(from pos in SudokuFactory.box(sizeX, sizeY) select tiles[startX + pos.Item1, startY + pos.Item2]); }