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); }
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); }
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; } }
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)); } } } }
public abstract bool IsIn(HintSelections hs);
public override bool IsIn(HintSelections hs) { return(hs.EventualSolutions); }
public override bool IsIn(HintSelections hs) { return(hs.Selectables); }
public override bool IsIn(HintSelections hs) { return(eventual ? hs.EventualDiscardables : hs.ImmediateDiscardables); }
public override bool IsIn(HintSelections hs) { return(hs.ForcedMoves); }
public override bool IsIn(HintSelections hs) { return(true); }
public bool IsLevel(Level level) { HintSelections hs = new HintSelections(level); return(hs.Equals(this)); }
public HintOptions() { Flags = new HintFlags(); Show = new HintSelections(HintSelections.Level.Hard); AutoSolve = new HintSelections(HintSelections.Level.Easy); }