예제 #1
0
        public Pot(int id, IEnumerable <SpreadingRule> rules, Pot left2, Pot left1, Pot right1, Pot right2)
        {
            this.Id = id;

            this.Filled = CalculateFilled(false, rules, left2, left1, right1, right2);
        }
예제 #2
0
        private static bool CalculateFilled(bool currentValue, IEnumerable <SpreadingRule> rules, Pot left2, Pot left1, Pot right1, Pot right2)
        {
            var state = new bool[]
            {
                left2?.Filled == true,
                left1?.Filled == true,
                currentValue,
                right1?.Filled == true,
                right2?.Filled == true
            };

            foreach (var rule in rules)
            {
                if (rule.Matches(state))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public Pot(Pot currentPot, IEnumerable <SpreadingRule> rules, Pot left2, Pot left1, Pot right1, Pot right2)
        {
            this.Id = currentPot.Id;

            this.Filled = CalculateFilled(currentPot.Filled, rules, left2, left1, right1, right2);
        }