001 package aima.basic.vaccum; 002 003 import aima.basic.Agent; 004 import aima.basic.AgentProgram; 005 import aima.basic.Percept; 006 007 /** 008 * @author Ravi Mohan 009 * 010 */ 011 public class ModelBasedTVEVaccumAgentProgram extends AgentProgram { 012 VaccumEnvironmentModel myModel; 013 014 ModelBasedTVEVaccumAgentProgram(VaccumEnvironmentModel model) { 015 myModel = model; 016 } 017 018 @Override 019 public String execute(Percept percept) { 020 String location = (String) percept.getAttribute("location"); 021 String locationStatus = (String) percept.getAttribute("status"); 022 myModel.setLocationStatus(location, locationStatus); 023 024 if (myModel.bothLocationsClean()) { 025 return Agent.NO_OP; 026 } else if (locationStatus.equals("Dirty")) { 027 return "Suck"; 028 } else if (location.equals("A")) { 029 return "Right"; 030 } else if (location.equals("B")) { 031 return "Left"; 032 } else 033 return "None"; 034 035 } 036 037 }