本文整理汇总了Python中Sliding.children方法的典型用法代码示例。如果您正苦于以下问题:Python Sliding.children方法的具体用法?Python Sliding.children怎么用?Python Sliding.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sliding
的用法示例。
在下文中一共展示了Sliding.children方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
return_list = [value]
children = Sliding.children(HEIGHT, WIDTH, Sliding.hash_to_board(WIDTH, HEIGHT, value[0]))
for child in children:
return_list.append((Sliding.board_to_hash(WIDTH, HEIGHT, child), value[1]+1))
return return_list
示例2: bfs_flat_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_flat_map(state):
""" """
self_list = [state]
if get_level(state) == level-1:
#expand children if state is on current (highest) level
children = Sliding.children(WIDTH, HEIGHT, get_board(state))
return [make_state(level, board) for board in children] + self_list
return self_list
示例3: press_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def press_map(data):
""" YOUR CODE HERE """
# get children output list of them
if level == data[1]:
# form k,v pairs from children
return [data] + [(k, level+1) for k in Sliding.children(WIDTH,HEIGHT,data[0])]
else:
return [data]
示例4: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
result = []
if value[1] == level - 1:
result = Sliding.children(WIDTH, HEIGHT, Sliding.hash_to_board(WIDTH, HEIGHT, value[0]))
for i in range(0, len(result)):
result[i] = (Sliding.board_to_hash(WIDTH, HEIGHT, result[i]), level)
result.append(value)
return result
示例5: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
# value is a (position, level) pair
result = [value]
if value[1] == level:
# if the node is at frontier
for child in Sliding.children(WIDTH, HEIGHT, value[0]):
result.append((child, level + 1))
return result
示例6: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value): #value is the (puzzle, level) tuple
""" YOUR CODE HERE """
lst = [(value)]
if value[1] == level:
children = Sliding.children(WIDTH,HEIGHT,Sliding.hash_to_board(WIDTH, HEIGHT, value[0]))
for child in children:
lst.append((Sliding.board_to_hash(WIDTH, HEIGHT, child),level+1))
return lst
return lst
示例7: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
# Add board's children to global position list
if value[1] == level:
children = Sliding.children(WIDTH, HEIGHT, value[0])
for i in range(0, len(children)):
positions.append((children[i], level+1))
# level += 1
return positions
示例8: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
if (value[1] != (level - 1)):
return [value]
else:
children = Sliding.children(WIDTH, HEIGHT, Sliding.hash_to_board(WIDTH,HEIGHT,value[0]))
childList = [value]
for child in children:
childList.append((Sliding.board_to_hash(WIDTH,HEIGHT,child), level))
return childList
示例9: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
"""
children = Sliding.children(WIDTH, HEIGHT, value[0])
items = []
for child in children:
items.append((child, value[1] + 1))
return items
"""
child_boards = Sliding.children(WIDTH, HEIGHT, value[0])
return [(child, value[1] + 1) for child in child_boards]
示例10: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
mapVal = []
mapVal.append((value[0], value[1]))
if value[1] == level:
pos = Sliding.hash_to_board(WIDTH, HEIGHT, value[0])
for cpos in Sliding.children(WIDTH, HEIGHT, pos):
cpos2 = Sliding.board_to_hash(WIDTH, HEIGHT, cpos)
mapVal.append((cpos2,level+1))
return mapVal
示例11: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
items = []
if value[1] < level:
items.append((value[0],value[1]))
if value[1] == level-1:
children_board = Sliding.hash_to_board(WIDTH, HEIGHT, value[0])
children = Sliding.children(WIDTH, HEIGHT, children_board)
for child in children:
items.append((Sliding.board_to_hash(WIDTH, HEIGHT, child), value[1] + 1))
return items
示例12: bfs_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_map(value):
""" YOUR CODE HERE """
prev = [(value[0], value[1])]
if value[1] == level:
children = Sliding.children(WIDTH, HEIGHT, value[0])
curr = []
for i in range(0, len(children)):
curr.append((children[i], level+1))
return prev + curr
return prev
示例13: bfs_flat_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_flat_map(state):
"""Takes in a state (level and board) and
returns a list containing the original state
with the addition of the children if the state is
at the current level (in the frontier)
"""
self_list = (state,)
if get_level(state) == level-1:
children = Sliding.children(WIDTH, HEIGHT, get_board(state))
return tuple(make_state(level, board) for board in children) + self_list
return self_list
示例14: bfs_flat_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def bfs_flat_map(parentValue):
mappedList = []
mappedList.append(parentValue)
# if the parentValue is from the last level we checked, look for its children and append them
if parentValue[1] == level - 1:
children = Sliding.children(WIDTH, HEIGHT, parentValue[0])
for element in children:
mappedList.append((element, level))
return mappedList
示例15: sol_map
# 需要导入模块: import Sliding [as 别名]
# 或者: from Sliding import children [as 别名]
def sol_map(value):
lst = []
if (value[1] < level):
lst.append(value)
return lst
lst.append(value)
children = Sliding.children(WIDTH, HEIGHT, value[0])
for each in children:
lst.append((tuple(each), value[1]+1))
del children
return lst