本文整理汇总了Python中position.Position.column方法的典型用法代码示例。如果您正苦于以下问题:Python Position.column方法的具体用法?Python Position.column怎么用?Python Position.column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.column方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: expand_frontier
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import column [as 别名]
def expand_frontier(self, state):
for row in (-1, 0, 1):
for col in (-1, 0, 1):
# Only allow adjacent non-diagonal moves
#if row != 0 and col != 0:
# continue
# Get the new position
position = Position(state.row() + row, state.column() + col)
# Rule out invalid positions
if position.row() < 0 or position.column() < 0 or \
position.row() >= self.environment.height or position.column() >= self.environment.width:
return
p = position.as_tuple()
# If not an obstacle and not explored, then add to frontier
if p not in self.environment.obstacles and p not in self.explored:
self.f += 1
# Create the new state
new_state = State(position, state.target, state.cost + 1, state)
# Update state path cost
new_state.path_cost = new_state.cost + self.heuristic(new_state)
# Add to frontier
self.frontier.add(new_state)