Пример #1
0
        protected void btnSolveStepByStep_Click(object sender, EventArgs e)
        {
            Logger log = null;
            Grid grid = null;
            int steps = 0;
            bool prevSolved = false, solved = false;

            LoadSession(out grid, out prevSolved, out steps);
            kenGrid.Grid = grid;

            KenKenSolver kenSolver = new KenKenSolver();
            solved = kenSolver.Solve(grid, out log, true);

            if (prevSolved)
            {
                NoMoreSteps(true, steps);
            }
            else if (log.CellId == null)
            {
                NoMoreSteps(false, steps);
            }
            else
            {
                UpdateLog(log, true);
                btnSolve.Text = "OK ! Take Step " + ++steps;
            }

            SaveSession(grid, solved, steps);
        }
Пример #2
0
        void SolveKenKen(bool stepByStep)
        {
            Logger log = null;
            Grid grid = null;
            int steps = 0;
            bool prevSolved = false, solved = false;

            LoadSession(out grid, out prevSolved, out steps);

            KenKenSolver kenSolver = new KenKenSolver();
            solved = kenSolver.Solve(grid, out log, stepByStep);

            kenGrid.Grid = grid;

            if (prevSolved)
            {
                NoMoreSteps(true, steps);
            }
            else if (log.CellId == null)
            {
                NoMoreSteps(false, steps);
            }
            else
            {
                UpdateLog(log, false);
                btnSolve.Text = "OK ! Take Step " + ++steps;
            }

            SaveSession(grid, solved, steps);
        }