ai.search
Class AbstractSearchStateForIntCostFn

java.lang.Object
  extended by ai.search.AbstractSearchStateForIntCostFn
All Implemented Interfaces:
SearchStateForIntCostFn

public abstract class AbstractSearchStateForIntCostFn
extends java.lang.Object
implements SearchStateForIntCostFn

This class represents a state of the world in a search problem.

Together with an appropriate implementation for actions, an implementation of a SearchStateForIntCostFn defines a search problem, which consists of four components:

Given a definition of a search problem in terms of these components and implemented by a class for SearchStateForIntCostFns and a class for IntCostActions, a search engine can be used to attempt to solve the search problem.

The extend this class one of the functions successors() or getAllPossibleActions() must be overridden. Only one of the default implementations provided here can be used. If getAllPossibleActions() is overridden the Array returned by this function is used to create a generic Iterator to be returned by successors(). This approach should only be used if there are few actions, most of which are usually applicable. Otherwise the function successors() should be overridden and this can create a more efficient Iterator to enumerate the successors of this state.

Author:
Gerhard Wickler
See Also:
IntCostAction, SearchEngineForIntCostFn

Nested Class Summary
(package private)  class AbstractSearchStateForIntCostFn.GenericSuccessorIterator
           
 
Constructor Summary
AbstractSearchStateForIntCostFn()
           
 
Method Summary
abstract  IntCostAction[] getAllPossibleActions()
           This function returns an array of all the actions that are in principle possible in this state.
 java.util.Iterator<inf.util.Pair<IntCostAction,SearchStateForIntCostFn>> successors()
           This function indirectly generates the successors for this state in the context of the search problem defined by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ai.search.SearchStateForIntCostFn
apply, getActionClass, isApplicable, isGoalState
 

Constructor Detail

AbstractSearchStateForIntCostFn

public AbstractSearchStateForIntCostFn()
Method Detail

getAllPossibleActions

public abstract IntCostAction[] getAllPossibleActions()

This function returns an array of all the actions that are in principle possible in this state. There is no guarantee that these actions are also applicable. If this function is implemented correctly then the default implementation of successors() will return a correctly working Iterator. This default implementation only throws an UnsupportedOperationException.

Extensions of this class should override either this function or successors().

Returns:
an Array containing all potentially applicable IntCostActions

successors

public java.util.Iterator<inf.util.Pair<IntCostAction,SearchStateForIntCostFn>> successors()

This function indirectly generates the successors for this state in the context of the search problem defined by this class. The returned Iterator will generate a sequence of Pairs consisting of an IntCostAction and a SearchStateForIntCostFn, where the action if applied in this state will result in the paired state.

The default implementation provided here relies on the function getAllPossibleActions() to work correctly. Extensions of this class should override either this function or getAllPossibleActions().

Specified by:
successors in interface SearchStateForIntCostFn
Returns:
an Iterator over the successor states of this state