本文整理汇总了Python中search.breadthFirstSearch方法的典型用法代码示例。如果您正苦于以下问题:Python search.breadthFirstSearch方法的具体用法?Python search.breadthFirstSearch怎么用?Python search.breadthFirstSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search.breadthFirstSearch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findPathToClosestDot
# 需要导入模块: import search [as 别名]
# 或者: from search import breadthFirstSearch [as 别名]
def findPathToClosestDot(self, gameState):
"""
Returns a path (a list of actions) to the closest dot, starting from
gameState.
"""
# Here are some useful elements of the startState
startPosition = gameState.getPacmanPosition()
food = gameState.getFood()
walls = gameState.getWalls()
problem = AnyFoodSearchProblem(gameState)
path = search.breadthFirstSearch(problem) # in the search, we implemented BreadthFirstSearch which is greedy and find the nesrest goal to eat
return path
util.raiseNotDefined()
示例2: findPathToClosestDot
# 需要导入模块: import search [as 别名]
# 或者: from search import breadthFirstSearch [as 别名]
def findPathToClosestDot(self, gameState):
"""
Returns a path (a list of actions) to the closest dot, starting from
gameState.
"""
# Here are some useful elements of the startState
startPosition = gameState.getPacmanPosition()
food = gameState.getFood()
walls = gameState.getWalls()
problem = AnyFoodSearchProblem(gameState)
action_list = breadthFirstSearch(problem)
return action_list