Esempio n. 1
0
        private void createNRules(RuleMSX rmsx, RuleContainer rc, RuleAction reached, Accumulator acm, int min, int max)
        {
            if (min == max)
            {
                // leaf node, so add rule with action
                Rule newRule = new Rule("intBetween" + min.ToString() + "and" + max.ToString(), new IsIntBetween(min, max, acm), rmsx.createAction("ShowValue", new ShowValue(min)));
                newRule.AddAction(reached);
                rc.AddRule(newRule);
            }
            else
            {
                Rule newRule = new Rule("intBetween" + min.ToString() + "and" + max.ToString(), new IsIntBetween(min, max, acm));
                rc.AddRule(newRule);

                if (max - min < 2)
                {
                    createNRules(rmsx, newRule, reached, acm, min, min);
                    createNRules(rmsx, newRule, reached, acm, max, max);
                }
                else
                {
                    int mid = ((max - min) / 2) + min;
                    createNRules(rmsx, newRule, reached, acm, min, mid);
                    createNRules(rmsx, newRule, reached, acm, mid + 1, max);
                }
            }
        }