def __init__(self, layout, QLearner): self._initBlocks(layout) self._initIntersections(layout) self.layout = layout startX = layout.getStartX() startY = layout.getStartY() startDirName = layout.getJuniorDir() self.junior = AutoDriver(QLearner) self.junior.setup(Vec2d(startX, startY), startDirName, Vec2d(0, 0)) self.cars = [self.junior] self.otherCars = [] self.finish = Block(layout.getFinish()) agentComm = AgentCommunication() if self.layout.getWorldName() != 'highway': agentGraph = layout.getAgentGraph() for _ in range(Const.NUM_AGENTS): startNode = self._getStartNode(agentGraph) other = Agent(startNode, layout.getAgentGraph(), self, agentComm) self.cars.append(other) self.otherCars.append(other) else: agentGraphCarB = layout.getAgentGraphCarB() startNode = self._getStartNode(agentGraphCarB) other = Agent(startNode, layout.getAgentGraphCarB(), self, agentComm) self.cars.append(other) self.otherCars.append(other) agentGraphTruck = layout.getAgentGraphTruck() startNode = self._getStartNode(agentGraphTruck) other = Agent(startNode, layout.getAgentGraphTruck(), self, agentComm) self.cars.append(other) self.otherCars.append(other) self.observations = [] agentComm.addAgents(self.otherCars) self.modelLock = threading.Lock() self.probCarSet = False