public Standard(Difficulty diff) : base(diff) { puzzleGrid = new PuzzleGrid(); puzzleSolver = new PuzzleSolver(); puzzleGenerator = new PuzzleGenerator(diff); puzzleGenerator.InitGrid(); base.solution = puzzleGenerator.SolutionGrid.Grid; base.mask = puzzleGenerator.PermaGrid.Grid;//check for negative values }
/// <summary> /// Return object of type Standard:Sudoku /// </summary> /// <param name="diff">Difficulty of Sudoku</param> public Standard(Difficulty diff) : base(diff) { base.scheme = scheme; puzzleGrid = new PuzzleGrid(); puzzleSolver = new PuzzleSolver(); puzzleGenerator = new PuzzleGenerator(diff); puzzleGenerator.InitGrid(); base.solution = puzzleGenerator.SolutionGrid.Grid; base.mask = puzzleGenerator.PermaGrid.Grid;//check for negative values userGrid.Initialize(); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { mask[i, j] = -mask[i, j]; userGrid[i, j] = mask[i, j]; } } }
public void setGrid(gameType type, Difficulty level) { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { dataGridView1.Rows[i].Cells[j].Value = ""; } } if (type == gameType.Standard) { squigglyGrid = null; PuzzleGenerator gen = new PuzzleGenerator(level); PuzzleGrid grid = gen.InitGrid(); standardSolver = new PuzzleSolver(); standardSolver.SolutionGrid = gen.SolutionGrid; standardGrid = new PuzzleGrid(); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (grid.Grid[i, j] != 0) { dataGridView1.Rows[i].Cells[j].Value = -grid.Grid[i, j]; } standardGrid.Grid[i, j] = -grid.Grid[i, j]; ColorMap[i, j] = Color.White; } } } else { standardGrid = null; schemeBuilder(); Random r = new Random(); int[,] scheme = Schemes[r.Next(6)]; bool Completed = false; CustomSquiggly squigglyGrid = null; squigglySolver = new SquigglySolver(scheme); while (squigglyGrid == null && !Completed) { squigglyGrid = Limex(() => new CustomSquiggly(scheme, level), 4000, out Completed); } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (squigglyGrid.Grid[i, j] != 0) { dataGridView1.Rows[i].Cells[j].Value = -squigglyGrid.Grid[i, j]; } dataGridView1.Rows[i].Cells[j].Style.BackColor = colors[scheme[i, j]]; ColorMap[i, j] = colors[scheme[i, j]]; } } string rez = "$$$$$$ try\n"; for (int ii = 0; ii < 9; ii++) { for (int jj = 0; jj < 9; jj++) { rez += CustomSquiggly.solution[ii, jj] + " "; } rez += "\n"; } MessageBox.Show(rez); } LockCellMap(); }