001 package aima.search.map; 002 003 import aima.search.framework.BidirectionalProblem; 004 import aima.search.framework.HeuristicFunction; 005 import aima.search.framework.Problem; 006 007 /** 008 * @author Ciaran O'Reilly 009 * 010 */ 011 public class BidirectionalMapProblem extends Problem implements 012 BidirectionalProblem { 013 014 Map map; 015 016 Problem reverseProblem; 017 018 public BidirectionalMapProblem(Map aMap, String initialState, 019 String goalState) { 020 super(initialState, new MapSuccessorFunction(aMap), new MapGoalTest( 021 goalState), new MapStepCostFunction(aMap)); 022 023 map = aMap; 024 025 reverseProblem = new Problem(goalState, new MapSuccessorFunction(aMap), 026 new MapGoalTest(initialState), new MapStepCostFunction(aMap)); 027 } 028 029 public BidirectionalMapProblem(Map aMap, String initialState, 030 String goalState, HeuristicFunction hf) { 031 super(initialState, new MapSuccessorFunction(aMap), new MapGoalTest( 032 goalState), new MapStepCostFunction(aMap), hf); 033 034 map = aMap; 035 036 reverseProblem = new Problem(goalState, new MapSuccessorFunction(aMap), 037 new MapGoalTest(initialState), new MapStepCostFunction(aMap), 038 hf); 039 } 040 041 // 042 // START Interface BidrectionalProblem 043 public Problem getOriginalProblem() { 044 return this; 045 } 046 047 public Problem getReverseProblem() { 048 return reverseProblem; 049 } 050 // END Interface BirectionalProblem 051 // 052 }