本文整理汇总了Python中scenario_generator.Scenario_Generator.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python Scenario_Generator.evaluate方法的具体用法?Python Scenario_Generator.evaluate怎么用?Python Scenario_Generator.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scenario_generator.Scenario_Generator
的用法示例。
在下文中一共展示了Scenario_Generator.evaluate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evaluate
# 需要导入模块: from scenario_generator import Scenario_Generator [as 别名]
# 或者: from scenario_generator.Scenario_Generator import evaluate [as 别名]
def evaluate(self, action, zones, graph):
scenario = Scenario_Generator(
self.width,
self.height,
self.immobile_objs,
self.mobile_objs,
self.manipulatable_obj,
self.target_obj,
showRender=False,
)
game_objects = scenario.getGameObjects()
end_position, shape = scenario.evaluate(action)
radius = shape.radius
end_position = Point(end_position)
circular_region_ball = end_position.buffer(radius)
occupied_zones = []
for i in xrange(len(zones)):
if zones[i].intersects(circular_region_ball):
occupied_zones.append(i)
if len(occupied_zones) == 0:
return len(zones) # set to the maximum length
min_d = 9999
for occupied_zone in occupied_zones:
length = nx.shortest_path_length(graph, source=occupied_zone, target=self.target_zone)
if length < min_d:
min_d = length
return min_d
示例2: test_old_evaluate
# 需要导入模块: from scenario_generator import Scenario_Generator [as 别名]
# 或者: from scenario_generator.Scenario_Generator import evaluate [as 别名]
def test_old_evaluate(self, action):
scenario = Scenario_Generator(self.width, self.height, self.immobile_objs, self.mobile_objs, self.manipulatable_obj, self.target_obj, showRender=False)
game_objects = scenario.getGameObjects()
graph, zones = triangulate(game_objects, self.width, self.height)
end_position, shape = scenario.evaluate(action)
end_position = Point(end_position)
last_zone = -1
for i in xrange(len(zones)):
if zones[i].contains(end_position):
last_zone = i
break
if last_zone == -1:
return len(zones) # set to the maximum length
score = nx.shortest_path_length(graph, source=i, target=self.target_zone)
return score