Search in sources :

Example 1 with NOTCondition

use of aima.core.agent.impl.aprog.simplerule.NOTCondition in project aima-java by aimacode.

the class RuleTest method testNOTRule.

@Test
public void testNOTRule() {
    Rule r = new Rule(new NOTCondition(new EQUALCondition(ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true)), ACTION_INITIATE_BRAKING);
    Assert.assertEquals(ACTION_INITIATE_BRAKING, r.getAction());
    Assert.assertEquals("if ![car-in-front-is-braking==true] then Action[name==initiate-braking].", r.toString());
    Assert.assertEquals(false, r.evaluate(new DynamicPercept(ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true)));
    Assert.assertEquals(true, r.evaluate(new DynamicPercept(ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, false)));
    Assert.assertEquals(true, r.evaluate(new DynamicPercept(ATTRIBUTE_CAR_IN_FRONT_IS_INDICATING, true)));
}
Also used : NOTCondition(aima.core.agent.impl.aprog.simplerule.NOTCondition) DynamicPercept(aima.core.agent.impl.DynamicPercept) EQUALCondition(aima.core.agent.impl.aprog.simplerule.EQUALCondition) Rule(aima.core.agent.impl.aprog.simplerule.Rule) Test(org.junit.Test)

Aggregations

DynamicPercept (aima.core.agent.impl.DynamicPercept)1 EQUALCondition (aima.core.agent.impl.aprog.simplerule.EQUALCondition)1 NOTCondition (aima.core.agent.impl.aprog.simplerule.NOTCondition)1 Rule (aima.core.agent.impl.aprog.simplerule.Rule)1 Test (org.junit.Test)1