ai.search
Class RouteProblem

java.lang.Object
  extended byai.search.Problem
      extended byai.search.RouteProblem
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.lang.Runnable
Direct Known Subclasses:
RomanianProblem

public class RouteProblem
extends Problem

Find a route between cities on a map.

Author:
Jill Zimmerman -- jill.zimmerman@goucher.edu

Field Summary
 
Fields inherited from class ai.search.Problem
algorithm, canvas, currentNode, display, goal, heuristic, initialState, numExpanded, q, search, searchResult
 
Method Summary
 java.lang.String actionToString(java.lang.Object action)
          Convert an action to a string.
 int edgeCost(Node n, java.lang.Object action, java.lang.Object state)
          Determine the cost of an edge which is the distance between the cities.
 boolean equalState(java.lang.Object state1, java.lang.Object state2)
          Determine if two states are equivalent.
 boolean goalReached(java.lang.Object state)
          Is the state a goal state?
 int hCost(java.lang.Object state)
          Estimate the cost to goal by taking straight-line distance.
 java.lang.String stateToString(java.lang.Object state)
          Convert a state to a string.
 java.util.Vector successors(java.lang.Object state)
          Determine all the states which are successors of the given state.
 
Methods inherited from class ai.search.Problem
actionPerformed, run, solve, start, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

goalReached

public boolean goalReached(java.lang.Object state)
Description copied from class: Problem
Is the state a goal state?

Overrides:
goalReached in class Problem

successors

public java.util.Vector successors(java.lang.Object state)
Determine all the states which are successors of the given state.

Specified by:
successors in class Problem
Parameters:
state - is the given state
Returns:
a vector of successors of state-action, which are both the name of the city

edgeCost

public int edgeCost(Node n,
                    java.lang.Object action,
                    java.lang.Object state)
Determine the cost of an edge which is the distance between the cities.

Overrides:
edgeCost in class Problem

hCost

public int hCost(java.lang.Object state)
Estimate the cost to goal by taking straight-line distance.

Overrides:
hCost in class Problem

equalState

public boolean equalState(java.lang.Object state1,
                          java.lang.Object state2)
Description copied from class: Problem
Determine if two states are equivalent.

Specified by:
equalState in class Problem
Parameters:
state1 - and states are the two states
Returns:
true if equal

stateToString

public java.lang.String stateToString(java.lang.Object state)
Description copied from class: Problem
Convert a state to a string.

Specified by:
stateToString in class Problem
Parameters:
state - is the given state
Returns:
a string expressing the state

actionToString

public java.lang.String actionToString(java.lang.Object action)
Description copied from class: Problem
Convert an action to a string.

Specified by:
actionToString in class Problem
Parameters:
action - is the given action
Returns:
a string expressing the action