|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjecthSearch.State
public abstract class State
State serves as a base class for a problem specific state. Any particular problem should extend the state class, add problem specific state details to it and give implementations for the abstract methods. It may optionally override the non final methods. Important: Override Object.equals to check the equality of two states and toString method for a suitable display function.
| Field Summary | |
|---|---|
protected int |
cost
|
protected State |
parent
|
protected java.util.ArrayList<State> |
successors
|
| Constructor Summary | |
|---|---|
State()
|
|
State(State parent)
|
|
| Method Summary | |
|---|---|
protected void |
addSuccessor(State successor)
|
int |
compareTo(State obj)
Compare desirability with another state. |
int |
f()
Comparability Function = Desirability - Cost |
int |
g()
|
int |
gChild()
Cost of Child, default is 1+g, available for overriding |
abstract java.util.ArrayList<State> |
generateSuccessors()
Returns a successor list by applying suitable operators but should not add any state to the successors list or set the successor list to this list. |
State |
getParent()
|
java.lang.String |
getPath()
Returns the path from the initial state to this (goal) state as a string. |
java.lang.String |
getPath(java.lang.String path)
|
int |
getPathLength()
Returns the length of a state from the initial state. |
java.util.ArrayList<State> |
getSuccessors()
|
abstract int |
h()
Desirabilty Function |
abstract boolean |
isGoal()
Whether or not a given state is a goal state. |
protected void |
setParent(State parent)
|
void |
show()
A display routine specific to the problem state. |
void |
showPath()
Routine to print the path from the initial state to this (goal) state. |
void |
updateCost()
UpdateCost() and UpdateCost(State) together in a chained recursive fashion are able to depth first traverse the successor tree and update cost values in case the best parent has just got better! |
void |
updateCost(State caller)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.ArrayList<State> successors
protected State parent
protected int cost
| Constructor Detail |
|---|
public State(State parent)
public State()
| Method Detail |
|---|
public final State getParent()
public final java.util.ArrayList<State> getSuccessors()
protected final void setParent(State parent)
protected final void addSuccessor(State successor)
public int g()
public int gChild()
public abstract int h()
public final int f()
public final int compareTo(State obj)
compareTo in interface java.lang.Comparable<State>public final void updateCost()
public final void updateCost(State caller)
public void showPath()
public java.lang.String getPath()
public java.lang.String getPath(java.lang.String path)
public int getPathLength()
public abstract boolean isGoal()
public abstract java.util.ArrayList<State> generateSuccessors()
public void show()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||