public void AlwaysExecutableQuery() { world = CreateITWorld(); var sc1 = new Scenario(); sc1.AddScenarioStep(new ScenarioStep(eat, alice)); sc1.AddScenarioStep(new ScenarioStep(drink, alice)); sc1.AddScenarioStep(new ScenarioStep(drink, rabbit)); sc1.AddScenarioStep(new ScenarioStep(eat, alice)); var q1 = new ScenarioAlwaysExecutableQuery(sc1); var sc2 = new Scenario(); sc2.AddScenarioStep(new ScenarioStep(drink, alice)); sc2.AddScenarioStep(new ScenarioStep(drink, rabbit)); sc2.AddScenarioStep(new ScenarioStep(drink, hatter)); sc2.AddScenarioStep(new ScenarioStep(drink, cat)); var q2 = new ScenarioAlwaysExecutableQuery(sc2); var r1 = q1.Evaluate(world); var r2 = q2.Evaluate(world); Assert.AreEqual(r1, false); // elixir może się skończyć na alicji, wtedy (drink,rabbit) nie przywróci ciastka Assert.AreEqual(r2, true); }
public void LightLampTest2() { var domain = new Domain(); var tom = new Actor("Tom"); var lighted = new Fluent("lighted"); var broken = new Fluent("broken"); var turnOn = new Action("TurnOn"); var turnOff = new Action("TurnOff"); var throwDown = new Action("ThrowDown"); var world = World.Instance; world.SetActions(new List <Action> { turnOn, turnOff, throwDown }); world.SetFluents(new List <Fluent> { lighted, broken }); world.SetActors(new List <Actor> { tom }); domain.AddInitiallyClause(new Initially(new Conjunction(new Negation(broken), lighted))); domain.AddTypicallyCausesClause(new TypicallyCauses(throwDown, false, new List <Actor> { tom }, broken)); domain.AddCausesClause(new Causes(turnOn, false, new List <Actor> { tom }, lighted)); domain.AddCausesClause(new Causes(turnOff, false, new List <Actor> { tom }, new Negation(lighted))); domain.AddAlwaysClause(new Always(new Implication(lighted, new Negation(broken)))); domain.AddPreservesClause(new Preserves(turnOn, false, new List <Actor> { tom }, broken, null)); world.SetDomain(domain); world.Build(); var scenario = new Scenario(); scenario.AddScenarioStep(new ScenarioStep(throwDown, tom)); scenario.AddScenarioStep(new ScenarioStep(turnOn, tom)); var q = new ScenarioAlwaysExecutableQuery(scenario); var r = q.Evaluate(world); Assert.AreEqual(r, false); }
public void NeroAlwaysExecutableQuery() { var query = new ScenarioAlwaysExecutableQuery(_drinkRestTorchScenario); Assert.IsTrue(query.Evaluate(_world)); }