本文整理汇总了Python中driver.Driver.respawn方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.respawn方法的具体用法?Python Driver.respawn怎么用?Python Driver.respawn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.respawn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import respawn [as 别名]
def reset(self):
print ("ENTERED RESET MODEL\n")
# Spawn crossings
dim = self.parameters.get('grid_size')
self.crossings = [] # Crossings in grid orientation
row = 0
# Notice!! Location is [x, y], but in the grid, one first has to access row, then column (so [y][x])
while row < dim[1]:
cr_row = []
col = 0
while col < dim[0]:
cr_row.append(Crossing([col, row]))
col += 1
self.crossings.append(cr_row)
row += 1
# Spawn drivers
self.drivers = []
n = self.parameters.get('n_drivers')
#print ("DRIVERS SPAWNED\n")
while n > 0:
driver = Driver('driver' + str(n))
self.drivers.append(driver)
#TODO remove print
#print ("DRIVER ADDED TO LIST\n")
# Put at a grid edge
new_loc = driver.respawn(dim[0], dim[1])
self.crossings[new_loc[1]][new_loc[0]].put_spawn(driver, dim[0]-1, dim[1]-1)
n -= 1