Beispiel #1
0
 public static Condition QuadrantMajorityCount(Comparison comparison, bool white, EdgeworkValue ev)
 {
     return(new Condition(
                string.Format("If there are {0} mostly-{1} quadrants {2} {3}", comparison == Comparison.Same ? "exactly as many" : comparison == Comparison.Fewer ? "fewer" : "more", white ? "white" : "black", comparison == Comparison.Same ? "as" : "than", ev.Name),
                Extra.None,
                (grid, bomb) =>
     {
         var quadrants = getQuadrantCounts(grid);
         var numMajQuadrants = quadrants.Count(q => white ? (q > 8) : (q < 8));
         return
         comparison == Comparison.Same ? (numMajQuadrants == ev.GetValue(bomb)) :
         comparison == Comparison.More ? (numMajQuadrants > ev.GetValue(bomb)) : (numMajQuadrants < ev.GetValue(bomb));
     }));
 }
Beispiel #2
0
    private int findAnswer(bool log)
    {
        var startRuleIx = _startRule.GetValue(Bomb);

        if (log)
        {
            Debug.LogFormat("[Bitmaps #{0}] Starting rule: {1} = {2}", _moduleId, _startRule.Name, startRuleIx);
        }

        for (int r = 0; r < _rules.Length; r++)
        {
            var ruleIndex = (r + startRuleIx) % _rules.Length;
            var result    = _rules[ruleIndex].Condition.Evaluate(_bitmap, Bomb);
            if (result != null)
            {
                var answer = _rules[ruleIndex].Solution.Answer(_bitmap, Bomb, result.Value);
                var btn    = (answer + 3) % 4 + 1;
                if (log)
                {
                    Debug.LogFormat("[Bitmaps #{0}] Applicable rule: {1} = {2}", _moduleId, ruleIndex, _rules[ruleIndex].Condition.Name);
                    Debug.LogFormat("[Bitmaps #{0}] Answer: {1} = {2}", _moduleId, _rules[ruleIndex].Solution.Name, answer);
                    Debug.LogFormat("[Bitmaps #{0}] Button to push: {1}", _moduleId, btn);
                }
                return(btn);
            }
        }

        Debug.LogFormat("[Bitmaps #{0}] There is a bug in the module. Please contact the author Timwi#0551 on Discord.", _moduleId);
        return(1);
    }
Beispiel #3
0
 public Solution(EdgeworkValue ev)
 {
     Name = ev.Name; Answer = (grid, bomb, extra) => ev.GetValue(bomb);
 }