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


Python Node.currentcsp方法代码示例

本文整理汇总了Python中Node.Node.currentcsp方法的典型用法代码示例。如果您正苦于以下问题:Python Node.currentcsp方法的具体用法?Python Node.currentcsp怎么用?Python Node.currentcsp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.currentcsp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createChildNodes

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import currentcsp [as 别名]
    def createChildNodes(self, sortedVarValues, currentNode, currentVariable):
        newChildren = []

        for value in sortedVarValues:
            # make new node and set currentNode as the parent
            newChild = Node(currentNode)

            # grab the assignment from the parent node
            newChild.assignment = copy.deepcopy(currentNode.assignment)
            # newChild.printAssignment()
            newChild.currentcsp = copy.deepcopy(currentNode.currentcsp)

            # grab the value we wanted to change and put it in the assignment of the new child
            newChild.assignment[currentVariable.name] = value

            # add the child to the list, we will use this list later
            newChildren.append(copy.deepcopy(newChild))

        # now that we've made all the children, set their parent nodes, and altered their assignment
        # with the proper value, now we're gonna set all their right sibling pointers
        #basically, this pointer makes printing the tree easier
        i = 1
        for child in newChildren:
           child.rightSibling = newChildren[i]
           if i is len(newChildren):
               child.rightSibling is None

        currentNode.children = newChildren

        return newChildren
开发者ID:dtbinh,项目名称:stuff,代码行数:32,代码来源:Backtracking_Search_Heuristics.py


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