Пример #1
0
        private void AddRuleToAntecedentHash(Rule rule)
        {
            var hashCode = GetAntecedentsHashCode(rule.Antecedents);

            if (!_rulesHashedByAntecedent.ContainsKey(hashCode))
                _rulesHashedByAntecedent.Add(hashCode, new List<Rule>());

            _rulesHashedByAntecedent[hashCode].Add(rule);
        }
Пример #2
0
 private static void AssertRulesEqual(Rule expected, Rule actual)
 {
     Assert.Equal(expected.IsMatched, actual.IsMatched);
     Assert.Equal(expected.Weight, actual.Weight);
     Assert.Equal(expected.Antecedents, actual.Antecedents);
     Assert.Equal(expected.Consequent, actual.Consequent);
 }
Пример #3
0
        private void BuildTable(int antecedentCount)
        {
            var query = Enumerable
                .Range(0, antecedentCount + 1)
                .Select(x => GetMoves());

            foreach (var ruleDef in query.CartesianProduct())
            {
                var moves = ruleDef.ToList();
                var antecedents = new List<Move>(antecedentCount);
                moves.Take(antecedentCount).ToList().ForEach(antecedents.Add);

                var rule = new Rule(antecedents, moves.Last());
                Rules.Add(rule);
                AddRuleToAntecedentHash(rule);
            }
        }