コード例 #1
0
ファイル: ELAlgo.cs プロジェクト: tMaxx/SpaceGuess
 public static void resetAll()
 {
     resetEngine();
     item  = null;
     DomTh = "cup(X) :- liftable(X), holds_liquid(X)."
             + Environment.NewLine + "holds_liquid(Z) :- part(Z, W), concave(W), points_up(W)."
             + Environment.NewLine + "liftable(Y) :- light(Y), part(Y, handle)."
             + Environment.NewLine + "light(A):- small(A)."
             + Environment.NewLine + "light(A):- made_of(A, feathers)." + Environment.NewLine
             + Environment.NewLine + "small(obj1)."
             + Environment.NewLine + "owns(bob, obj1)."
             + Environment.NewLine + "part(obj1, handle)."
             + Environment.NewLine + "part(obj1, bottom)."
             + Environment.NewLine + "part(obj1, bowl)."
             + Environment.NewLine + "points_up(bowl)."
             + Environment.NewLine + "concave(bowl)."
             + Environment.NewLine + "color(obj1, red)." + Environment.NewLine
             + Environment.NewLine + "operational(small(_))."
             + Environment.NewLine + "operational(part(_, _))."
             + Environment.NewLine + "operational(owns(_, _))."
             + Environment.NewLine + "operational(points_up(_))."
             + Environment.NewLine + "operational(concave(_)).";
     SpaceForm.self.tbELRuleInput.Text = "cup(obj1)";
     Status = "gotowy";
     logApp("---Reset---");
 }
コード例 #2
0
ファイル: ELAlgo.cs プロジェクト: tMaxx/SpaceGuess
        internal static void execQuery(string cmd)
        {
            Status = "przygotowywanie polecenia...";
            cmd    = VSHistory.wspaceRx.Replace(cmd.Trim(), "");
            if (cmd.EndsWith("."))
            {
                cmd = cmd.TrimEnd('.');
            }

            string pred, body;

            extractParts(cmd, out pred, out body);
            cmd = buildQuery(pred, body);

            Status = "resetowanie silnika Prolog...";

            resetEngine();

            Status = "przygotowywanie teorii...";
            logProlog("commiting theory...");

            if (!bumpTmpFile())
            {
                Status = "błąd przy zapisie stanu teorii";
                return;
            }

            Status = "wykonywanie polecenia...";

            try
            {
                using (PlQuery q = new PlQuery(cmd))
                {
                    item = new ELItem();
                    foreach (PlQueryVariables v in q.SolutionVariables)
                    {
                        item.proof    = v["Proof"].ToString();
                        item.genProof = v["GenProof"].ToString();
                        item.rule     = pred + '(' + v["X"].ToString() + ") :- " + v["RuleBody"] + '.';
                        break;
                    }
                    logProlog("exec: " + cmd + Environment.NewLine + q.ToString());
                }
            }
            catch (Exception e)
            {
                Status = "wystąpił błąd; sprawdź konsolę";
                logProlog("ERROR: could not solve: " + e.ToString());
                return;
            }

            Status = "drukowanie...";

            SpaceForm.self.tbELOutput.Text = "Zapytanie:" + Environment.NewLine + cmd + Environment.NewLine + Environment.NewLine
                                             + "Dowód:" + Environment.NewLine + item.proof + Environment.NewLine + Environment.NewLine
                                             + "Dowód ogólny:" + Environment.NewLine + item.genProof
                                             + Environment.NewLine + Environment.NewLine + Environment.NewLine
                                             + "***Nowa reguła obiektu***:" + Environment.NewLine + item.rule;

            Status = "zakończono";
        }