Note that there are some explanatory texts on larger screens.

plurals
  1. POError!!! cant concatenate the tuple to non float
    primarykey
    data
    text
    <pre><code>stack = [] closed = [] currNode = problem.getStartState() stack.append(currNode) while (len(stack) != 0): node = stack.pop() if problem.isGoalState(node): print "true" closed.append(node) else: child = problem.getSuccessors(node) if not child == 0: stack.append(child) closed.apped(node) return None </code></pre> <p>code of successor is:</p> <pre><code>def getSuccessors(self, state): """ Returns successor states, the actions they require, and a cost of 1. As noted in search.py: For a given state, this should return a list of triples, (successor, action, stepCost), where 'successor' is a successor to the current state, 'action' is the action required to get there, and 'stepCost' is the incremental cost of expanding to that successor """ successors = [] for action in [Directions.NORTH, Directions.SOUTH, Directions.EAST, Directions.WEST]: x,y = state dx, dy = Actions.directionToVector(action) nextx, nexty = int(x + dx), int(y + dy) if not self.walls[nextx][nexty]: nextState = (nextx, nexty) cost = self.costFn(nextState) successors.append( ( nextState, action, cost) ) # Bookkeeping for display purposes self._expanded += 1 if state not in self._visited: self._visited[state] = True self._visitedlist.append(state) return successors </code></pre> <p>The error is:</p> <pre><code>File line 87, in depthFirstSearch child = problem.getSuccessors(node) File line 181, in getSuccessors nextx, nexty = int(x + dx), int(y + dy) TypeError: can only concatenate tuple (not "float") to tuple </code></pre> <p>When we run the following commands:</p> <pre><code> print "Start:", problem.getStartState() print "Is the start a goal?", problem.isGoalState(problem.getStartState()) print "Start's successors:", problem.getSuccessors(problem.getStartState()) </code></pre> <p>we get:</p> <pre><code>Start: (5, 5) Is the start a goal? False Start's successors: [((5, 4), 'South', 1), ((4, 5), 'West', 1)] </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload