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

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


  // function MODEL-BASED-REFLEX-AGENT(percept) returns an action
  public Action execute(Percept percept) {
    // state <- UPDATE-STATE(state, action, percept, model)
    state = updateState(state, action, percept, model);
    // rule <- RULE-MATCH(state, rules)
    Rule rule = ruleMatch(state, rules);
    // action <- rule.ACTION
    action = ruleAction(rule);
    // return action
    return action;
  }
View Full Code Here


  public Action execute(Percept percept) {

    // state <- INTERPRET-INPUT(percept);
    ObjectWithDynamicAttributes state = interpretInput(percept);
    // rule <- RULE-MATCH(state, rules);
    Rule rule = ruleMatch(state, rules);
    // action <- rule.ACTION;
    // return action
    return ruleAction(rule);
  }
View Full Code Here

  private static Set<Rule> getRuleSet() {
    // Note: Using a LinkedHashSet so that the iteration order (i.e. implied
    // precedence) of rules can be guaranteed.
    Set<Rule> rules = new LinkedHashSet<Rule>();

    rules.add(new Rule(new ANDCondition(new EQUALCondition(
        ATTRIBUTE_STATE_LOCATION_A,
        VacuumEnvironment.LocationState.Clean), new EQUALCondition(
        ATTRIBUTE_STATE_LOCATION_B,
        VacuumEnvironment.LocationState.Clean)), NoOpAction.NO_OP));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_STATE,
        VacuumEnvironment.LocationState.Dirty),
        VacuumEnvironment.ACTION_SUCK));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_LOCATION,
        VacuumEnvironment.LOCATION_A),
        VacuumEnvironment.ACTION_MOVE_RIGHT));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_LOCATION,
        VacuumEnvironment.LOCATION_B),
        VacuumEnvironment.ACTION_MOVE_LEFT));

    return rules;
  }
View Full Code Here

    // Rules based on REFLEX-VACUUM-AGENT:
    // Artificial Intelligence A Modern Approach (3rd Edition): Figure 2.8,
    // page 48.

    rules.add(new Rule(new EQUALCondition(LocalVacuumEnvironmentPercept.ATTRIBUTE_STATE,
        VacuumEnvironment.LocationState.Dirty),
        VacuumEnvironment.ACTION_SUCK));
    rules.add(new Rule(new EQUALCondition(
        LocalVacuumEnvironmentPercept.ATTRIBUTE_AGENT_LOCATION,
        VacuumEnvironment.LOCATION_A),
        VacuumEnvironment.ACTION_MOVE_RIGHT));
    rules.add(new Rule(new EQUALCondition(
        LocalVacuumEnvironmentPercept.ATTRIBUTE_AGENT_LOCATION,
        VacuumEnvironment.LOCATION_B),
        VacuumEnvironment.ACTION_MOVE_LEFT));

    return rules;
View Full Code Here

    return state;
  }

  private Set<Rule> makeRules() {
    Set<Rule> rules = new HashSet<Rule>();
    rules.add(new Rule(new EQUALCondition(ATTR_CUR_STATE, State.INIT_TOP),
        EnhancedVacuumEnvironment.ACTION_UP));
    rules.add(new Rule(new EQUALCondition(ATTR_CUR_STATE, State.INIT_LEFT),
        EnhancedVacuumEnvironment.ACTION_LEFT));
    rules.add(new Rule(new EQUALCondition(ATTR_CUR_STATE, State.SCAN_LEFT),
        EnhancedVacuumEnvironment.ACTION_LEFT));
    rules.add(new Rule(
        new EQUALCondition(ATTR_CUR_STATE, State.SCAN_RIGHT),
        EnhancedVacuumEnvironment.ACTION_RIGHT));
    rules.add(new Rule(
        new EQUALCondition(ATTR_CUR_STATE, State.SCAN_DOWN_1),
        EnhancedVacuumEnvironment.ACTION_DOWN));
    rules.add(new Rule(
        new EQUALCondition(ATTR_CUR_STATE, State.SCAN_DOWN_2),
        EnhancedVacuumEnvironment.ACTION_DOWN));
    rules.add(new Rule(new EQUALCondition(ATTR_CUR_STATE, State.CLEAN),
        EnhancedVacuumEnvironment.ACTION_CLEAN));
    return rules;
  }
View Full Code Here

  private static Set<Rule> getRuleSet() {
    // Note: Using a LinkedHashSet so that the iteration order (i.e. implied
    // precedence) of rules can be guaranteed.
    Set<Rule> rules = new LinkedHashSet<Rule>();

    rules.add(new Rule(new ANDCondition(new EQUALCondition(
        ATTRIBUTE_STATE_LOCATION_A,
        VacuumEnvironment.LocationState.Clean), new EQUALCondition(
        ATTRIBUTE_STATE_LOCATION_B,
        VacuumEnvironment.LocationState.Clean)), NoOpAction.NO_OP));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_STATE,
        VacuumEnvironment.LocationState.Dirty),
        VacuumEnvironment.ACTION_SUCK));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_LOCATION,
        VacuumEnvironment.LOCATION_A),
        VacuumEnvironment.ACTION_MOVE_RIGHT));
    rules.add(new Rule(new EQUALCondition(ATTRIBUTE_CURRENT_LOCATION,
        VacuumEnvironment.LOCATION_B),
        VacuumEnvironment.ACTION_MOVE_LEFT));

    return rules;
  }
View Full Code Here

    // Rules based on REFLEX-VACUUM-AGENT:
    // Artificial Intelligence A Modern Approach (3rd Edition): Figure 2.8,
    // page 48.

    rules.add(new Rule(new EQUALCondition(VacuumEnvPercept.ATTRIBUTE_STATE,
        VacuumEnvironment.LocationState.Dirty),
        VacuumEnvironment.ACTION_SUCK));
    rules.add(new Rule(new EQUALCondition(
        VacuumEnvPercept.ATTRIBUTE_AGENT_LOCATION,
        VacuumEnvironment.LOCATION_A),
        VacuumEnvironment.ACTION_MOVE_RIGHT));
    rules.add(new Rule(new EQUALCondition(
        VacuumEnvPercept.ATTRIBUTE_AGENT_LOCATION,
        VacuumEnvironment.LOCATION_B),
        VacuumEnvironment.ACTION_MOVE_LEFT));

    return rules;
View Full Code Here

  // function MODEL-BASED-REFLEX-AGENT(percept) returns an action
  public Action execute(Percept percept) {
    // state <- UPDATE-STATE(state, action, percept, model)
    state = updateState(state, action, percept, model);
    // rule <- RULE-MATCH(state, rules)
    Rule rule = ruleMatch(state, rules);
    // action <- rule.ACTION
    action = ruleAction(rule);
    // return action
    return action;
  }
View Full Code Here

  public Action execute(Percept percept) {

    // state <- INTERPRET-INPUT(percept);
    ObjectWithDynamicAttributes state = interpretInput(percept);
    // rule <- RULE-MATCH(state, rules);
    Rule rule = ruleMatch(state, rules);
    // action <- rule.ACTION;
    // return action
    return ruleAction(rule);
  }
View Full Code Here

  private static final String ATTRIBUTE_CAR_IN_FRONT_IS_INDICATING = "car-in-front-is-indicating";
  private static final String ATTRIBUTE_CAR_IN_FRONT_TIRES_SMOKING = "car-in-front-tires-smoking";

  @Test
  public void testEQUALRule() {
    Rule r = new Rule(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(true, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_BRAKING, true)));

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

    Assert.assertEquals(false, r.evaluate(new DynamicPercept(
        ATTRIBUTE_CAR_IN_FRONT_IS_INDICATING, true)));
  }
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.