Package aima.core.agent.impl.aprog.simplerule

Examples of aima.core.agent.impl.aprog.simplerule.Rule


        ATTRIBUTE_CAR_IN_FRONT_IS_INDICATING, true)));
  }

  @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)));
  }
View Full Code Here


        ATTRIBUTE_CAR_IN_FRONT_IS_INDICATING, true)));
  }

  @Test
  public void testANDRule() {
    Rule r = new Rule(new ANDCondition(new EQUALCondition(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true), new EQUALCondition(
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)),
        ACTION_EMERGENCY_BRAKING);

    Assert.assertEquals(ACTION_EMERGENCY_BRAKING, r.getAction());

    Assert.assertEquals(
        "if [car-in-front-is-braking==true && car-in-front-tires-smoking==true] then Action[name==emergency-braking].",
        r.toString());

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true)));

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, false,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, false)));
  }
View Full Code Here

        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, false)));
  }

  @Test
  public void testORRule() {
    Rule r = new Rule(new ORCondition(new EQUALCondition(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true), new EQUALCondition(
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)),
        ACTION_EMERGENCY_BRAKING);

    Assert.assertEquals(ACTION_EMERGENCY_BRAKING, r.getAction());

    Assert.assertEquals(
        "if [car-in-front-is-braking==true || car-in-front-tires-smoking==true] then Action[name==emergency-braking].",
        r.toString());

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true)));

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, false,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, true)));

    Assert.assertEquals(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, false)));

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, false,
        ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING, false)));
  }
View Full Code Here

TOP

Related Classes of aima.core.agent.impl.aprog.simplerule.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.