当前位置: 首页>>代码示例>>Python>>正文


Python Sliding.children方法代码示例

本文整理汇总了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
开发者ID:rtadinada,项目名称:cs61c-proj2-1,代码行数:9,代码来源:SlidingBfsSpark.py

示例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
开发者ID:rlaprade,项目名称:61c-Spark,代码行数:10,代码来源:SlidingBfsSpark.py

示例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]
开发者ID:lukelev07,项目名称:proj2-spark,代码行数:10,代码来源:SlidingBfsSpark.py

示例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
开发者ID:podfog,项目名称:SchoolWork,代码行数:11,代码来源:SlidingBfsSpark.py

示例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
开发者ID:yuluntian,项目名称:Spark,代码行数:11,代码来源:SlidingBfsSpark.py

示例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
开发者ID:shauryakalsi,项目名称:CS61C,代码行数:11,代码来源:SlidingBfsSpark.py

示例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
开发者ID:warlck,项目名称:cs61c,代码行数:11,代码来源:copy.py

示例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
开发者ID:Jananiravichandran,项目名称:cs61c,代码行数:12,代码来源:SlidingBfsSpark.py

示例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]
开发者ID:poywoo,项目名称:61cproj2,代码行数:12,代码来源:SlidingBfsSpark_sid.py

示例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
开发者ID:aparsrinara,项目名称:slidingBlockPuzzle,代码行数:12,代码来源:SlidingBfsSpark.py

示例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
开发者ID:poywoo,项目名称:61cproj2-2,代码行数:12,代码来源:SlidingBfsSpark.py

示例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
开发者ID:warlck,项目名称:cs61c,代码行数:12,代码来源:SlidingBfsSpark.py

示例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
开发者ID:hansongcal,项目名称:CS61C,代码行数:13,代码来源:SlidingBfsSpark.py

示例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
开发者ID:kimfairhurst,项目名称:MapReduce,代码行数:13,代码来源:SlidingBfsSpark.py

示例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
开发者ID:ShihengJiang666,项目名称:proj2-MapReduce-sliding-matrix,代码行数:13,代码来源:SlidingBfsSpark.py


注:本文中的Sliding.children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。