Ejemplo n.º 1
0
        public void SolveOneVar()
        {
            SMTVar.Reset();
            var x = new SMTVar("x", 0, 10);

            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(SMTVar.Solve(null));
                AssertValid(x);
            }
        }
Ejemplo n.º 2
0
        public void SolveTwoIndependent()
        {
            SMTVar.Reset();
            var x = new SMTVar("x", 0, 10);
            var y = new SMTVar("y", 0, 10);

            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(SMTVar.Solve(null));
                AssertValid(x);
                AssertValid(y);
            }
        }
Ejemplo n.º 3
0
        public void SolveTwoDependent()
        {
            SMTVar.Reset();
            var p = new Problem("SolveTwoDependent");
            var x = new SMTVar("x", 0, 10);
            var y = new SMTVar("y", 0, 10);

            p.Assert(x < y);
            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(SMTVar.Solve(p.Solve()));
                AssertValid(x);
                AssertValid(y);
                Assert.IsTrue(x.Value <= y.Value, $"Trial {i}: {x.Value} > {y.Value}");
            }
        }
Ejemplo n.º 4
0
        public void PSMTNPCStatsTest()
        {
            SMTVar.Reset();
            var p        = new Problem("NPC stats");
            var str      = new SMTVar("str", 0, 10);
            var con      = new SMTVar("con", 0, 10);
            var dex      = new SMTVar("dex", 0, 10);
            var intel    = new SMTVar("int", 0, 10);
            var wis      = new SMTVar("wis", 0, 10);
            var charisma = new SMTVar("char", 0, 10);

            p.Unique("fighter", "magic user", "cleric", "thief");
            p.Assert(
                ((Expression)(Proposition)"fighter") > (str > intel),
                ((Expression)(Proposition)"fighter") > (str > 5),
                ((Expression)(Proposition)"fighter") > (con > 5),
                ((Expression)(Proposition)"fighter") > (intel < 8),
                ((Expression)(Proposition)"magic") > (str < intel),
                ((Expression)(Proposition)"magic") > (intel > 5),
                ((Expression)(Proposition)"magic") > (str < 8),
                ((Expression)(Proposition)"cleric") > (wis > 5),
                ((Expression)(Proposition)"cleric") > (con < wis),
                ((Expression)(Proposition)"theif") > (dex > 5),
                ((Expression)(Proposition)"theif") > (charisma > 5),
                ((Expression)(Proposition)"theif") > (wis < 5),
                ((Expression)(Proposition)"theif") > (dex > str),
                ((Expression)(Proposition)"theif") > (charisma > intel)
                );
            for (int i = 0; i < 100; i++)
            {
                Solution solution;
                do
                {
                    solution = p.Solve();
                } while (!SMTVar.Solve(solution));
            }
        }