001    package aima.search.map;
002    
003    import aima.basic.Percept;
004    import aima.search.framework.GoalTest;
005    
006    /**
007     * Implementation of the GoalTest interface for testing if at a desired location.
008     */
009    
010    /**
011     * @author Ciaran O'Reilly
012     * 
013     */
014    
015    public class MapGoalTest implements GoalTest {
016            private String goalState = null;
017    
018            public MapGoalTest(String goalState) {
019                    this.goalState = goalState;
020            }
021    
022            public boolean isGoalState(Object currentState) {
023    
024                    String location = currentState.toString();
025                    if (currentState instanceof Percept) {
026                            location = (String) ((Percept) currentState)
027                                            .getAttribute(DynAttributeNames.PERCEPT_IN);
028                    }
029    
030                    return goalState.equals(location);
031            }
032    }