Module ucSearch

PQ
Slow implementation of a priority queue that just finds the minimum
element for each extraction.

Functions

search(initialState,
goalTest,
actions,
successor,
heuristic=<function <lambda> at 0x1755af0>,
maxNodes=10000)
Returns:
path from initial state to a goal state as a list of (action, state)
tuples

smSearch(smToSearch,
initialState=None,
goalTest=None,
heuristic=<function <lambda> at 0x1788f30>,
maxNodes=10000)
Returns:
a list of the form [(a0, s0), (a1, s1), (a2, s2), ...]
where the a's are legal actions of c{smToSearch} and s's are states
of that machine.

smToSearch - instance of sm.SM defining a search domain;
getNextValues is used to determine the successor of
a state given an action; the output field of getNextValues is
interpreted as a cost.

initialState - initial state for the search; if not provided, will use
smToSearch.startState

goalTest - function that takes a state as an argument and returns
True if it is a goal state, and False
otherwise

heuristic - function from state to estimated cost to reach a goal; defaults
to a heuristic of 0, making this uniform cost search

maxNodes - maximum number of nodes to be searched; prevents runaway
searches

Returns:

a list of the form [(a0, s0), (a1, s1), (a2, s2),
...] where the a's are legal actions of c{smToSearch} and
s's are states of that machine. s0 is the start
state; the last state is a state that satisfies the goal test.
If the goal is unreachable (within the search limit), it returns
None.