コード例 #1
0
        public SudokuPuzzleView()
        {
            int size = 9;
            InitializeComponent();

            var puzzle = new PuzzleGenerator((int)Math.Sqrt(size));
            board = puzzle.MakePartialSolution(Difficulty.Hard);
            boardAs2DArray = puzzle.PartialSolutionAs2DArray;

            CreateRowAndColumnDefinitions(size);

            for (var row = 0; row < size; row++) {
                for (var column = 0; column < size; column++) {
                    var panel = new SudokuPanel(row, column, boardAs2DArray[column, row], squareSize, squareSize);

                    panel.MouseDown += PanelClick;
                    panel.PutBackGroundOnPanel();

                    this.SudokuGrid.Children.Add(panel);
                    Grid.SetRow(panel, row);
                    Grid.SetColumn(panel, column);
                }
            }
            presenter = new SudokuGridPresenter { SudokuGrid = boardAs2DArray, SudokuGridSquares = board, View = this };
        }
コード例 #2
0
ファイル: Standard.cs プロジェクト: 111025/Sudoku
        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
        }
コード例 #3
0
ファイル: Standard.cs プロジェクト: saraspasic/Sudoku
        /// <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];
                }
            }
        }
コード例 #4
0
ファイル: Standard.cs プロジェクト: NatashaL/Sudoku
        /// <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];
                }
            }
        }
コード例 #5
0
 public void CheckForWinCondition_True()
 {
     var puzzle = new PuzzleGenerator();
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: 111025/Sudoku
        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();
        }