Search in sources :

Example 6 with Rule

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

the class SimpleReflexAgentProgram method execute.

//
// START-AgentProgram
// function SIMPLE-RELEX-AGENT(percept) returns an action
@Override
public Action execute(Percept percept) {
    // state <- INTERPRET-INPUT(percept);
    ObjectWithDynamicAttributes state = interpretInput(percept);
    // rule <- RULE-MATCH(state, rules);
    Rule rule = ruleMatch(state, rules);
    // return action
    return ruleAction(rule);
}
Also used : ObjectWithDynamicAttributes(aima.core.agent.impl.ObjectWithDynamicAttributes) Rule(aima.core.agent.impl.aprog.simplerule.Rule)

Example 7 with Rule

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

the class SimpleReflexVacuumAgent method getRuleSet.

//
// PRIVATE METHODS
//
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 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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EQUALCondition(aima.core.agent.impl.aprog.simplerule.EQUALCondition) Rule(aima.core.agent.impl.aprog.simplerule.Rule)

Example 8 with Rule

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

the class ModelBasedReflexAgentProgram method execute.

//
// START-AgentProgram
// 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;
}
Also used : Rule(aima.core.agent.impl.aprog.simplerule.Rule)

Aggregations

Rule (aima.core.agent.impl.aprog.simplerule.Rule)8 EQUALCondition (aima.core.agent.impl.aprog.simplerule.EQUALCondition)6 DynamicPercept (aima.core.agent.impl.DynamicPercept)4 Test (org.junit.Test)4 ANDCondition (aima.core.agent.impl.aprog.simplerule.ANDCondition)2 LinkedHashSet (java.util.LinkedHashSet)2 ObjectWithDynamicAttributes (aima.core.agent.impl.ObjectWithDynamicAttributes)1 NOTCondition (aima.core.agent.impl.aprog.simplerule.NOTCondition)1 ORCondition (aima.core.agent.impl.aprog.simplerule.ORCondition)1