本文整理汇总了Python中tree.Node.apply_action方法的典型用法代码示例。如果您正苦于以下问题:Python Node.apply_action方法的具体用法?Python Node.apply_action怎么用?Python Node.apply_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.apply_action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_algorithm
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import apply_action [as 别名]
def run_algorithm():
balloons = [(24, 167, -1) for b in range(B)] # liste de B triplets
sky = [[0 for c in range(C)] for r in range(R)]
sky[24][167] = B
actions = [] # liste de T tours contenant une liste de B actions (-1,0,1)
current_node = Node(balloons, sky, [(24, 167, -1), (24, 167, -1), (24, 167, -1), None])
current_score = 0
depth = 1
for current_T in range(T):
action = []
for current_B in range(B):
expand_tree(current_node, current_B, depth, expand_function, heuristic)
print(current_node.balloons[current_B])
# time.sleep(1)
current_node = max(current_node.children, key=lambda x: x.heuristic_value)
action.append(current_node.prev_action[3])
current_node.apply_action()
current_node.prev_action[0] = current_node.balloons[current_B % B]
current_node.prev_action[2] = current_node.balloons[current_B % B]
current_node.prev_action[3] = None
print(get_score(current_node.sky))
time.sleep(1)
actions.append(action)
tour_score = get_score(current_node.sky)
current_score += tour_score
if current_T % 1 == 0:
print("tour %i: %i" % (current_T, tour_score))
# print("lost: %i"%get_lost(current_node.balloons))
save_result_in_file(actions, "lolilol.txt")
return current_score