示例#1
0
        private void GenerateEasy()
        {
            CellsGrid tempGrid   = new CellsGrid();
            int       iterations = 0;
            int       tests      = 0;

            for (; ;)
            {
                grid     = new CellsGrid();
                tempGrid = new CellsGrid();
                while (tempGrid.Count < 20)
                {
                    DebugGridPrint();
                    iterations++;
                    tempGrid = grid.Clone();
                    tempGrid[random.Next(0, 9), random.Next(0, 9)] = random.Next(1, 9);
                    if (new Validator(tempGrid).IsValid())
                    {
                        grid = tempGrid.Clone();
                    }
                }
                if (new Solver(grid).SolveHard())
                {
                    break;
                }
                tests++;
                Debug.Print(tests.ToString());
            }
            Generated = grid.Clone();
        }
示例#2
0
        public Solver(CellsGrid inputGrid) : base(inputGrid)
        {
            Grid     = inputGrid.Clone();
            possible = new List <List <List <int> > >();
            for (int i = 0; i < 9; i++)
            {
                possible.Add(new List <List <int> >());
                for (int j = 0; j < 9; j++)
                {
                    possible[i].Add(new List <int>());
                }
            }
            Steps = new List <CellsGrid>();
            Steps.Add(Grid.Clone());

            //if(Grid.Count > 5) SolveHard();
        }