void RetrieveFacts() { //Debug.Log("# of observables: " + fow.observables.Count); /*Transform head = transform.Find("Head"); * Color original = head.GetComponent<Renderer>().material.GetColor("_Color"); //for debugging/showcase purposes*/ foreach (GameObject obj in fow.observables) { if (obj == null) { continue; } Observable obs = obj.GetComponent <Observable>(); //Debug.Log("Observable " + obs); foreach (ObservableFact fact in obs.observableFacts) { YP.assertFact(info.agentId, fact.getLabel(), fact.getValues()); } foreach (LocationClue clue in obs.locationClues) { //head.GetComponent<Renderer>().material.SetColor("_Color", Color.green); //for debugging/showcase purposes agent.solver.AddLocationClue(clue); } foreach (MurderClue clue in obs.murderClues) { transform.Find("Head").GetComponent <Renderer>().material.SetColor("_Color", Color.green); agent.solver.AddMurderClue(clue); } } //StartCoroutine(stopProcessingFacts(head, original, 0.5f)); //for debugging/showcase purposes fow.observables.Clear(); }
/// <summary> /// Insère un prédicat dans la base de données <see cref="YieldProlog"/>. /// A utiliser uniquement dans un nouveau <see cref="AppDomain"/>. /// </summary> public void YPassert() { YP.assertFact(Atom.a(name), values); }
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(); }