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


Python Tree.goToEndNode方法代码示例

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


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

示例1: main

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import goToEndNode [as 别名]
def main():

	# Car1 = Car(22, False, 3)
	# Car2 = Car(9, False, 2)
	# Car3 = Car(10, True, 2)
	# RedCar = Car(20, True, 2)

	# CARS_LIST.cars.append(Car1)
	# CARS_LIST.cars.append(Car2)
	# CARS_LIST.cars.append(Car3)
	# CARS_LIST.cars.append(RedCar)

	RedCar = Car(20, True, 2)
	Car1 = Car(0, False, 2)
	Car2 = Car(12, True, 2)
	Car3 = Car(3, False, 2)
	Car4 = Car(4, True, 2)
	Car5 = Car(10, True, 2)
	Car6 = Car(14, True, 2)
	Car7 = Car(16, False, 2)
	Car8 = Car(17, False, 3)
	Car9 = Car(25, True, 2)
	Car10 = Car(27, True, 2)
	Car11 = Car(32, True, 2)
	Car12 = Car(34, True, 2)

	CARS_LIST.cars.append(Car1)
	CARS_LIST.cars.append(Car2)
	CARS_LIST.cars.append(Car3)
	CARS_LIST.cars.append(Car4)
	CARS_LIST.cars.append(Car5)
	CARS_LIST.cars.append(Car6)
	CARS_LIST.cars.append(Car7)
	CARS_LIST.cars.append(Car8)
	CARS_LIST.cars.append(Car9)
	CARS_LIST.cars.append(Car10)
	CARS_LIST.cars.append(Car11)
	CARS_LIST.cars.append(Car12)
	CARS_LIST.cars.append(RedCar)

	# TEST dept first algorithme:
	global INITIAL_STATE; INITIAL_STATE = CARS_LIST.getFirstState()
	global STATES_ARCHIVE; STATES_ARCHIVE = Tree(WIDTH, CARS_LIST.getDirectionsList())
	algorithm(INITIAL_STATE)
	path1 = SOLUTION_PATHS[0]

	# print results
	# print "length solutions ", len(SOLUTIONS)
	#rint SOLUTIONS
	print len(SOLUTION_PATHS)
	listSolutionsPaths = []
	for sols in SOLUTION_PATHS:
		listSolutionsPaths.append(len(sols))
	print listSolutionsPaths

	pathDepth = []
	for state in path1[:-1]:
		print len(state), state
		pathDepth.append(STATES_ARCHIVE.goToEndNode(state).depth)
	print pathDepth
开发者ID:A-meerdervan,项目名称:RushHourGit,代码行数:62,代码来源:DeptFirst2.py

示例2: main

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import goToEndNode [as 别名]
def main():
    bordVariables = bord(2)  # return [carsList,width,exit]
    global WIDTH
    WIDTH = bordVariables[1]
    global EXIT
    EXIT = bordVariables[2]
    global CARS_LIST
    CARS_LIST = bordVariables[0]
    # TEST dept first algorithme:
    global INITIAL_STATE
    INITIAL_STATE = CARS_LIST.getFirstState()
    global STATES_ARCHIVE
    STATES_ARCHIVE = Tree(WIDTH, CARS_LIST.getDirectionsList())
    algorithm(INITIAL_STATE)

    print "Algorithm is done"
    path1 = SOLUTION_PATHS[-1]
    print len(SOLUTION_PATHS)

    # listOfLengths = []
    # for solution in SOLUTION_PATHS:
    # 	listOfLengths.append(len(solution))
    # print listOfLengths

    # print path1
    # print path1[-1]

    path1Copy = deepCopyList(path1)
    shortPath = [path1Copy[-1]]

    listOfDepths = []
    for states in path1Copy[:-1]:
        listOfDepths.append(STATES_ARCHIVE.goToEndNode(states).depth)
        if STATES_ARCHIVE.goToEndNode(states).depth == 70:
            print states, "70"
        if STATES_ARCHIVE.goToEndNode(states).depth == 71:
            print states, "71"
        if STATES_ARCHIVE.goToEndNode(states).depth == 33:
            print states, "33"
        if STATES_ARCHIVE.goToEndNode(states).depth == 32:
            print states, "32"
        if STATES_ARCHIVE.goToEndNode(states).depth == 30:
            print states, "30"
    print "list of depths", listOfDepths

    i = len(path1Copy) - 2
    while i > 0:
        depthOfState = STATES_ARCHIVE.goToEndNode(path1Copy[i]).depth
        if depthOfState in listOfDepths[0:i]:
            index = listOfDepths.index(depthOfState)
            if compare(path1Copy[i], path1Copy[i + 1]) < compare(
                path1Copy[listOfDepths.index(depthOfState)], path1Copy[i + 1]
            ):
                i = index
            else:
                shortPath.append(path1Copy[i])
                i -= 1
        else:
            shortPath.append(path1Copy[i])
            i -= 1
    shortPath.append(path1Copy[0])

    depthsOfShort = []
    for states in shortPath[1:]:
        depthsOfShort.append(STATES_ARCHIVE.goToEndNode(states).depth)
    print "depths of short", depthsOfShort[::-1]

    reverseDepth = depthsOfShort[::-1]
    reverseShort = shortPath[::-1]
    print reverseShort[14], reverseDepth[14]
    print reverseShort[15], reverseDepth[15]
    print reverseShort[16], reverseDepth[16]
    # print results
    # print "length solutions ", len(SOLUTIONS)
    # print SOLUTIONS
    # print SOLUTION_PATHS
    # print "START"
    # for i in range(0, 3100, 30):
    # 	print len(SOLUTION_PATHS[i])

    runSimulation(CARS_LIST.getVisualisationList(), shortPath[::-1], WIDTH, WIDTH, 0.5)  # slordig dubble WIDTH meegeven
开发者ID:A-meerdervan,项目名称:RushHourGit,代码行数:83,代码来源:DeptFirst3.py


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