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


Python Node.getValue方法代码示例

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


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

示例1: simulate

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]
    def simulate(self):

        currentNode = Node(Sudoku(self.m_sudokuProblem, self.m_fixedNodes))
        currentNode.m_sudoku.populate()
        found = False

        while not found:
            self.m_temperature = self.scheduleTemp()

            if currentNode.getValue() <= 0 and currentNode.m_sudoku.validateSudoku():
                found = True
                return currentNode

            if self.m_temperature < 0.00027:
                currentNode = self.reheat()
                print "REHEAT"

            nextNode = currentNode.getRandomSucessor()

            deltaE = currentNode.getValue() - nextNode.getValue()
            print nextNode.getValue()

            probability = self.getProbability(deltaE)
            if random.random() < probability:
                currentNode = nextNode
开发者ID:provenchez,项目名称:AI,代码行数:27,代码来源:recuit_simule.py

示例2: __insert

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]
    def __insert(self, root, value):
        if root == None:
            root = Node(value)
            print(root.getValue())
            return

        # Go to the right if value >= value of the root
        if value >= root.getValue():
            if root.getRight():
                self.__insert(root.getRight(), value)
            else:
                root.setRight(Node(value))
        else:
            if root.getLeft():
                self.__insert(root.getLeft(), value)
            else:
                root.setLeft(Node(value))
开发者ID:paolo215,项目名称:problems,代码行数:19,代码来源:binary_search_tree_problems.py

示例3: build_path

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]

#.........这里部分代码省略.........
                firstNode = nodes[0]
                n = Node()
                
                '''force first node of each path to absolute command'''
                if pathIndex > 0 and firstNode.command.islower():
                        firstNode.command = firstNode.command.upper()
                        lastCoordinate = pathLastNode.getTarget()
                        firstNode.attrib = [ str(float(lastCoordinate[0]) + float(firstNode.attrib[0])),  str(float(lastCoordinate[1]) + float(firstNode.attrib[1])) ]
                
                n.attrib = firstNode.getTarget()
                n.showCommand = True
                n.command = "L"
                    
                nodes.insert(-1,  n)
                pathLastNode = n
                lastNode = nodes.pop()
            
            if self.options['circlepath']:
                tempBuilt = built[:]
                
            index = 0
            while nodes:
                if not self.isRunning: return
                
                if not self.options['fullpath']:
#                    node = nodes.pop(0)
#                    built.append(node.getValue())
#                        built.append( points.pop(0) )
#                    while nodes and not re.match(r'^[a-zA-Z]$', nodes[0].showCommand):
                    command = nodes[0].command
                    while nodes:
                        node = nodes.pop(0)
#                        print node.getValue()
                        built.append(node.getValue())
                        
                        if node.command.lower() != command.lower():
                            break
                        
                else:
                    if self.options['circlepath'] and closedPath:
                        if len(nodes) > 0:
                            node = nodes.pop(0)
                            leftPath.append(node)
                        if len(nodes) > 0:
                            node = nodes.pop()
                            rightPath.insert(0, node)
                        
                        cleanPath = []
                        for node in nodes:
                            n = Node()
                            if node.command.islower():
                                n.command = "m"
                            else:
                                n.command = "M"
                            
                            n.showCommand = True
                            n.attrib = node.attrib[-2:]
                            cleanPath.append(n)
                            
                        if self.options['closepath']:
                            currentPoint = ["0", "0"]
                            absolutePath = False
                            for node in cleanPath:
                                if node.command.islower():
                                    currentPoint[0] = str(float(currentPoint[0]) + float(node.attrib[0]))
                                    currentPoint[1] = str(float(currentPoint[1]) + float(node.attrib[1]))
开发者ID:fpermana,项目名称:svgbuild-gui,代码行数:70,代码来源:SVGBuild.py


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