コード例 #1
0
        private void guessAll()
        {
            long guessStart = DateTime.Now.Ticks;

            for (int i = 0; i < size; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    if (tracker.board.board[i][j] != '-')
                    {
                        continue;
                    }
                    CharSet possib = tracker.progress[i][j];
                    if (possib.size() == 2)                     // minimal
                    {
                        for (int l = 0; l < 2; ++l)
                        {
                            Tracker newTracker = new Tracker(tracker);
                            newTracker.board.setCell(i, j, possib.getList()[l]);
                            Solver  newSolver  = new Solver(newTracker);
                            Tracker retTracker = newSolver.run();
                            if (retTracker.valid)
                            {
                                singleSquareElapsed += newSolver.singleSquareElapsed;
                                singleRegionElapsed += newSolver.singleRegionElapsed;
                                guessCnt            += newSolver.guessCnt + 1;
                                ++tracker.solutionCnt;
                                if (tracker.solutionCnt == 2 || retTracker.solutionCnt == 2)
                                {
                                    tracker             = retTracker;
                                    tracker.solutionCnt = 2;
                                    i = size; j = size; l = 2;                                     // break from loop
                                }
                            }
                        }
                    }
                }
            }
            long guessEnd   = DateTime.Now.Ticks;
            long timeMicros = (guessEnd - guessStart) / 10;

            guessTimeElapsed += timeMicros;
        }