예제 #1
0
        /// <param name="shallCountSolutions">
        /// True means the number of solutions is counted.
        /// False means it stops after the first solution that is found.
        /// </param>
        public Solver(IEnumerable <IFieldValueChangedRule> fieldChangedRules,
                      IEnumerable <ISolverRule> solverRules,
                      ITrialAndErrorRule trialRule,
                      IBackup <IBimaruGrid> gridBackup,
                      bool shallCountSolutions = false)
        {
            ChangedRules        = fieldChangedRules;
            SolverRules         = solverRules;
            TrialRule           = trialRule;
            GridBackup          = gridBackup;
            ShallCountSolutions = shallCountSolutions;

            bool isSolverCapableOfCounting = TrialRule != null &&
                                             TrialRule.AreTrialsDisjoint &&
                                             TrialRule.AreTrialsComplete;

            if (ShallCountSolutions && !isSolverCapableOfCounting)
            {
                throw new ArgumentException("This solver is not able to count the number of solutions.");
            }
        }
 public OneMissingShipOrWater(ITrialAndErrorRule fallBackRule)
 {
     FallBackRule = fallBackRule;
 }