コード例 #1
0
def prune_bottom_h(root, depth):
    if depth == 1:
        shutil.rmtree(root)
    else:
        children = tree.children(root)
        for c in children:
            prune_bottom_h(c, depth - 1)
コード例 #2
0
def get_nodes(root, threshold):

    if folder.istrans(root):
        trans = folder.get_trans(root)
    else:
        trans = ''

    this_node = {
        'label': folder.get_parent_moves(root),
        'source': 0,
        'target': 0,
        'value': 0,
        'win_dif': folder.win_dif(root),
        'path': root,
        'parent moves': folder.get_parent_moves(root),
        'transposition': trans
    }

    node_list = [this_node]
    children = tree.children(root)
    for c in children:
        node_list = get_nodes_h(c, node_list, this_node, threshold)
    node_list = add_xy(node_list, root)
    node_list = link_transpositions(node_list)
    node_list = openingbook.add_names(node_list)
    node_report(node_list, root)
    return node_list
コード例 #3
0
def get_nodes_h(path, node_list, parent, threshold):
    if folder.get_percent(path) < threshold:
        return node_list

    if folder.istrans(path):
        trans = folder.get_trans(path)
    else:
        trans = ''

    this_node = {
        'label': path[path.rfind('/') + 1:],
        'source': parent['target'],
        'target': len(node_list),
        'value': folder.get_percent(path),
        'win_dif': folder.win_dif(path),
        'path': path,
        'parentpath': parent['path'],
        'parentvalue': parent['value'],
        'parent moves': folder.get_parent_moves(path),
        'transposition': trans
    }

    node_list.append(this_node)
    children = tree.children(path)
    if children == []:
        return node_list
    else:
        for c in children:
            node_list = get_nodes_h(c, node_list, this_node, threshold)
        return node_list
コード例 #4
0
def prune_bottom(root):
    # just deletes the lowest existing level of the tree, except will not delete the root itself
    depth = tree.depth(root)
    if depth == 1:
        print('prune_bottom error: no children at root level')
    else:
        children = tree.children(root)
        for c in children:
            prune_bottom_h(c, depth - 1)
コード例 #5
0
def split_one_level(root):
    if folder.istrans(root):
        return # don't split nodes that have been previously merged as transpositions
    if folder.issplit(root):
        # split the child nodes
        children = tree.children(root)
        if children == []: # this node is previously split, and all children were pruned 
            return
        for c in children:
            split_one_level(c)
    else: # we only get here if not already split
        split_children(root)
コード例 #6
0
def prune(root, threshold):

    # delete this node if it's a f****t node
    if 'PARENT NOT FOUND' in root or 'game over' in root:
        shutil.rmtree(root)

    # delete this node if it is below threshold
    elif folder.get_percent(root) < threshold:
        shutil.rmtree(root)
    else:
        # prune child nodes
        children = tree.children(root)
        for c in children:
            prune(c, threshold)
コード例 #7
0
ファイル: qrymed3.py プロジェクト: pleiadian53/tpheno
def test3():
    from tree import children
    codes = [
        60420,
        60456,
        60511,
        60513,
        60520,
    ]
    desctb, anctb = groupFromWithin(codes)  # partial adjacency list
    for k, v in desctb.items():
        print "base: %s => desc: %s" % (k, str(v))  #

    for code in codes:
        codewalk = children(code, desctb, mode='dfs')
        print "base: %s => walk: %s" % (code, codewalk)
コード例 #8
0
def add_eval_all(root, sec):
    add_eval(root, sec)
    childs = tree.children(root)
    for c in childs:
        add_eval_all(c, sec)