def __init__(self, data, id): self.data = data self.block = Block(data) self.id = id self.sides = { 'north': IntersectionSide(), 'south': IntersectionSide(), 'east': IntersectionSide(), 'west': IntersectionSide() } self.centerNode = None
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
def _initIntersections(self, layout): self.intersections = [] for blockData in layout.getIntersectionNodes(): block = Block(blockData) self.intersections.append(block)
def _initBlocks(self, layout): self.blocks = [] for blockData in layout.getBlockData(): block = Block(blockData) self.blocks.append(block)