예제 #1
0
        public Hint SingleHint(HintSelections hs)
        {
            Hint        toDiscard = null;
            Requirement c         = EasiestRequirement;

            if (c != null)
            {
                if (c.s == 0)
                {
                    return(new ImpossibleHint(c));
                }
                if (c.s == 1 && hs.ForcedMoves)
                {
                    return(new ForcedMoveHint(c, c.d.Candidate));
                }
            }

            Candidate[] uc = UnselectedCandidates;
            if (hs.ImmediateDiscardables)
            {
                foreach (Candidate k in uc)
                {
                    int o;
                    CheckSelectCandidate(k, out c, out o);
                    if (o == 0)
                    {
                        toDiscard = new DiscardableHint(k, c, false);
                    }
                }
            }
            foreach (Candidate k in uc)
            {
                int o, steps;
                CheckSelectCandidateFollowingSingleOptions(k, out c, out o, out steps);
                if (hs.EventualDiscardables && o == 0)
                {
                    toDiscard = new DiscardableHint(k, c, steps > 1);
                }
                if (hs.EventualSolutions && o == 1)
                {
                    return(new EventualSolutionHint(k));
                }
                if (hs.Selectables)
                {
                    CheckDiscardCandidateFollowingSingleOptions(k, out c, out o);
                    if (o == 0)
                    {
                        return(new SelectableHint(k, c));
                    }
                }
            }
            // It's preferable to use a hint that selects a candidate, because this satisfies requirements and moves towards a solution
            return(toDiscard);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is HintSelections))
            {
                return(false);
            }
            HintSelections hs = obj as HintSelections;

            return(ForcedMoves == hs.ForcedMoves &&
                   ImmediateDiscardables == hs.ImmediateDiscardables &&
                   EventualDiscardables == hs.EventualDiscardables &&
                   Selectables == hs.Selectables &&
                   EventualSolutions == hs.EventualSolutions);
        }
예제 #3
0
        public IEnumerable <Hint> HintsToPaint(HintFlags ho, HintSelections hs, Func <Hint, bool> filter)
        {
            if (filter == null)
            {
                filter = (Hint h) => true;
            }
            bool first = true;

            foreach (var hint in AllHints(hs).Where(filter))
            {
                if (hint.IsIn(hs))
                {
                    yield return(hint);

                    if (first && (hint is ImpossibleHint || hint is ForcedMoveHint))
                    {
                        yield break; // Just paint one for that house
                    }
                }
                first = false;
            }
        }
예제 #4
0
        public IEnumerable <Hint> AllHints(HintSelections hs)
        {
            foreach (var hint in ImpossibleHints)
            {
                yield return(hint);
            }
            if (hs == null || hs.ForcedMoves)
            {
                foreach (var hint in ForcedHints)
                {
                    yield return(hint);
                }
            }

            foreach (Candidate k in UnselectedCandidates)
            {
                Requirement c;
                int         o, steps;
                CheckSelectCandidateFollowingSingleOptions(k, out c, out o, out steps);
                bool eventual = steps > 1;
                if (o == 0 && (hs == null || (eventual ? hs.EventualDiscardables : hs.ImmediateDiscardables)))
                {
                    yield return(new DiscardableHint(k, c, eventual));
                }
                if (o == 1 && (hs == null || hs.EventualSolutions))
                {
                    yield return(new EventualSolutionHint(k));
                }
                if (hs == null || hs.Selectables)
                {
                    CheckDiscardCandidateFollowingSingleOptions(k, out c, out o);
                    if (o == 0)
                    {
                        yield return(new SelectableHint(k, c));
                    }
                }
            }
        }
예제 #5
0
 public abstract bool IsIn(HintSelections hs);
예제 #6
0
 public override bool IsIn(HintSelections hs)
 {
     return(hs.EventualSolutions);
 }
예제 #7
0
 public override bool IsIn(HintSelections hs)
 {
     return(hs.Selectables);
 }
예제 #8
0
 public override bool IsIn(HintSelections hs)
 {
     return(eventual ? hs.EventualDiscardables : hs.ImmediateDiscardables);
 }
예제 #9
0
 public override bool IsIn(HintSelections hs)
 {
     return(hs.ForcedMoves);
 }
예제 #10
0
 public override bool IsIn(HintSelections hs)
 {
     return(true);
 }
예제 #11
0
        public bool IsLevel(Level level)
        {
            HintSelections hs = new HintSelections(level);

            return(hs.Equals(this));
        }
예제 #12
0
 public HintOptions()
 {
     Flags     = new HintFlags();
     Show      = new HintSelections(HintSelections.Level.Hard);
     AutoSolve = new HintSelections(HintSelections.Level.Easy);
 }