Пример #1
0
        public Solver(List <PuzzleConstraint> constraints)
        {
            SolverMethods.Add(new HiddenSingle());
            SolverMethods.Add(new IntersectionRemoval());


            foreach (var constraint in constraints)
            {
                switch (constraint)
                {
                case PuzzleConstraint.NormalSudoku:
                    BoardValidators.Add(new ColumnUnique());
                    BoardValidators.Add(new RowUnique());
                    BoardValidators.Add(new BoxUnique());
                    break;

                case PuzzleConstraint.KnightsMove:
                    BoardValidators.Add(new KnightUnique());
                    break;

                case PuzzleConstraint.KingsMove:
                    BoardValidators.Add(new KingUnique());
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Пример #2
0
        public PseudoSolver(List <PuzzleConstraint> constraints, PseudoBoard board)
        {
            CurrentStep = new SolverStep
            {
                SolverStepId = 1,
                StepComment  = "Starting Board State",
                BoardState   = new SolverState
                {
                    BoardCells  = board.BoardCells,
                    SolvedState = false
                }
            };
            CurrentBoard = board;

            SolverMethods.Add(new HiddenSingle());
            SolverMethods.Add(new ConjugatePair());


            foreach (var constraint in constraints)
            {
                switch (constraint)
                {
                case PuzzleConstraint.BoxUnique:
                    BoardValidators.Add(new BoxUnique());
                    break;

                case PuzzleConstraint.ColumnUnique:
                    BoardValidators.Add(new ColumnUnique());
                    break;

                case PuzzleConstraint.RowUnique:
                    BoardValidators.Add(new RowUnique());
                    break;

                case PuzzleConstraint.KnightUnique:
                    BoardValidators.Add(new KnightUnique());
                    break;

                case PuzzleConstraint.KingUnique:
                    BoardValidators.Add(new KingUnique());
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }