001 package aima.basic.vaccum; 002 003 import java.util.LinkedHashSet; 004 import java.util.Set; 005 006 import aima.basic.Agent; 007 import aima.basic.simplerule.EQUALCondition; 008 import aima.basic.simplerule.Rule; 009 010 /** 011 * An example of using the aima.basic.SimpleReflexAgentProgram. 012 */ 013 014 /** 015 * @author Ciaran O'Reilly 016 * 017 */ 018 019 public class SimpleReflexVaccumAgent extends Agent { 020 021 public SimpleReflexVaccumAgent() { 022 super(new SimpleReflexAgentProgram(getRuleSet())); 023 } 024 025 // 026 // PRIVATE METHODS 027 // 028 private static Set<Rule> getRuleSet() { 029 // Note: Using a LinkedHashSet so that the iteration order (i.e. implied 030 // precedence) of rules can be guaranteed. 031 Set<Rule> rules = new LinkedHashSet<Rule>(); 032 033 // Rules based on REFLEX-VACUUM-AGENT: 034 // Artificial Intelligence A Modern Approach (2nd Edition): Figure 2.8, 035 // page 46. 036 037 rules.add(new Rule(new EQUALCondition("status", "Dirty"), "Suck")); 038 rules.add(new Rule(new EQUALCondition("location", "A"), "Right")); 039 rules.add(new Rule(new EQUALCondition("location", "B"), "Left")); 040 041 return rules; 042 } 043 }