Exemplo n.º 1
0
        protected void AddRule(IVRiscuitObject[] before, IVRiscuitObject[] after)
        {
            var beforeSet = new VRiscuitObjectSet(before);

            Debug.Log(beforeSet != null);
            var rule = new VRiscuitRule(new BeforePattern(new VRiscuitObjectSet(before)),
                                        new AfterPattern(new VRiscuitObjectSet(after)));

            Debug.Log(rule);
            _rules.Add(rule);
        }
Exemplo n.º 2
0
        public void CandsSortTest()
        {
            var r = new VRiscuitRule(new BeforePattern(new VRiscuitObjectSet()),
                                     new AfterPattern(new VRiscuitObjectSet()));
            var a     = new Candidate(r, new VRiscuitObjectSet(), 100);
            var b     = new Candidate(r, new VRiscuitObjectSet(), 80);
            var c     = new Candidate(r, new VRiscuitObjectSet(), 60);
            var d     = new Candidate(r, new VRiscuitObjectSet(), 40);
            var cands = new Candidate[] { b, d, a, c };

            cands = cands.OrderBy(cand => - cand.Score).ToArray();
            Debug.Log(cands.Skip(1).Aggregate(cands[0].Score.ToString(), (str, next) => str + ", " + next.Score.ToString()));
            Assert.That(cands[0].Score, Is.EqualTo(100));
            Assert.That(cands[1].Score, Is.EqualTo(80));
            Assert.That(cands[2].Score, Is.EqualTo(60));
            Assert.That(cands[3].Score, Is.EqualTo(40));
        }