コード例 #1
0
 public static IEnumerable <bool> action(object Obj, object Status, object Cmd)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("action_"), new object[] { Obj, Status, Cmd }))
         {
             yield return(false);
         }
     }
 }
コード例 #2
0
 public static IEnumerable <bool> recognition(object Obj, object Value)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("recognition_"), new object[] { Obj, Value }))
         {
             yield return(false);
         }
     }
 }
コード例 #3
0
 public static IEnumerable <bool> confidence(object Obj, object Min, object Max)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("confidence_"), new object[] { Obj, Min, Max }))
         {
             yield return(false);
         }
     }
 }
コード例 #4
0
 public static IEnumerable <bool> result(object SysCmd, object Out)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("result_"), new object[] { SysCmd, Out }))
         {
             yield return(false);
         }
     }
 }
コード例 #5
0
 public static IEnumerable <bool> request(object Id, object UserCmd)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("request_"), new object[] { Id, UserCmd }))
         {
             yield return(false);
         }
     }
 }
コード例 #6
0
 public static IEnumerable <bool> objcmd(object Obj, object SysCmd)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("objcmd_"), new object[] { Obj, SysCmd }))
         {
             yield return(false);
         }
     }
 }
コード例 #7
0
 public static IEnumerable <bool> cmddesc(object SysCmd, object Desc)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("cmddesc_"), new object[] { SysCmd, Desc }))
         {
             yield return(false);
         }
     }
 }
コード例 #8
0
 public static IEnumerable <bool> usrcmd(object UserCmd, object SysCmd)
 {
     {
         foreach (bool l2 in YP.matchDynamic(Atom.a("usrcmd_"), new object[] { UserCmd, SysCmd }))
         {
             yield return(false);
         }
     }
 }
コード例 #9
0
    IEnumerator ChooseBehavior()
    {
        while (true)
        {
            yield return(new WaitForSeconds(behaviorDelay));

            //Debug.Log("Choosing behavior");
            Variable deadAgent = new Variable();
            Variable whenVar   = new Variable();
            Variable whereVar  = new Variable();
            //Debug.Log("AgentBehavior" + info.agentName);
            int  deadCount   = 0;
            bool killerFound = false;
            try {
                foreach (bool l1 in YP.matchDynamic(info.agentId, Atom.a("dead"),
                                                    new object[] { deadAgent, whenVar, whereVar }))
                {
                    Debug.Log(string.Format("{0} KNOWS {1} HAS DIED IN {2} at {3}",
                                            info.agentName,
                                            deadAgent.getValue(),
                                            whereVar.getValue(),
                                            whenVar.getValue()));
                    deadCount++;
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
            }

            Variable killerAgent = new Variable();
            try
            {
                foreach (bool l1 in YP.matchDynamic(info.agentId, Atom.a("killed"),
                                                    new object[] { killerAgent, deadAgent }))
                {
                    Debug.Log(string.Format("{0} KNOWS {1} HAS KILLED {2}",
                                            info.agentName,
                                            killerAgent.getValue(),
                                            deadAgent.getValue()));
                    killerFound = true;
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e);
            }
            if (deadCount == 3 || killerFound)
            {
                StartNewBehavior("RunAwayBehavior");
                //StopCoroutine(thinkingBehavior);
            }
        }
    }
コード例 #10
0
ファイル: Tutorial4.cs プロジェクト: wannaphong/YieldProlog
 public static IEnumerable <bool> uncle
     (object Person, object Uncle)
 {
     {
         Variable Goal   = new Variable();
         Variable Parent = new Variable();
         foreach (bool l2 in YP.unify
                      (Goal, new Functor2
                          (Atom.a("parent", Atom.a("")),
                          Person, Parent)))
         {
             foreach (bool l3 in YP.getIterator
                          (Goal, getDeclaringClass()))
             {
                 foreach (bool l4 in YP.matchDynamic
                              (Atom.a("brother"), new object[] { Parent, Uncle }))
                 {
                     yield return(false);
                 }
             }
         }
     }
 }
コード例 #11
0
ファイル: Tutorial4.cs プロジェクト: wannaphong/YieldProlog
    static void Main(string[] args)
    {
        YP.assertFact(Atom.a("brother"),
                      new object[] { Atom.a("Hillary"), Atom.a("Hugh") });
        YP.assertFact(Atom.a("brother"),
                      new object[] { Atom.a("Hillary"), Atom.a("Tony") });
        YP.assertFact(Atom.a("brother"),
                      new object[] { Atom.a("Bill"), Atom.a("Roger") });

        Variable Brother = new Variable();

        Console.WriteLine("Using dynamic assert:");
        foreach (bool l1 in YP.matchDynamic
                     (Atom.a("brother"), new object[]
                     { Atom.a("Hillary"), Brother }))
        {
            Console.WriteLine("Hillary has brother " +
                              Brother.getValue() + ".");
        }

        string prologCode =
            "uncle(Person, Uncle) :- \n" +
            "  parent(Person, Parent), \n" +
            "  brother(Parent, Uncle). \n";

        Console.WriteLine("\n// Compiled code:");
        compileAndWrite(prologCode);

        prologCode =
            ":- import('', [parent/2]). \n" +
            "uncle(Person, Uncle) :- \n" +
            "  parent(Person, Parent), \n" +
            "  brother(Parent, Uncle). \n";
        Console.WriteLine("// Calling an imported function:");
        compileAndWrite(prologCode);

        prologCode =
            "parent('Chelsea', 'Hillary'). \n" +
            "parent('Chelsea', 'Bill'). \n" +

            "uncle(Person, Uncle) :- \n" +
            "  parent(Person, Parent), \n" +
            "  brother(Parent, Uncle). \n";
        Console.WriteLine("// Calling a locally-defined function:");
        compileAndWrite(prologCode);

        prologCode =
            ":- import('', [parent/2]). \n" +
            "uncle(Person, Uncle) :- \n" +
            "  Goal = parent(Person, Parent), \n" +
            "  Goal, \n" +
            "  brother(Parent, Uncle). \n";
        Console.WriteLine("// Calling a dynamic goal:");
        compileAndWrite(prologCode);

        Console.WriteLine("Calling compiled code having a dynamic goal:");
        Variable Person = new Variable();
        Variable Uncle  = new Variable();

        foreach (bool l1 in uncle(Person, Uncle))
        {
            Console.WriteLine(Person.getValue() +
                              " has uncle " + Uncle.getValue() + ".");
        }

        Console.WriteLine("\nPress Enter to finish.");
        Console.ReadLine();
    }