Exemplo n.º 1
0
 def __init__(self, worldName):
     self.loadData(worldName)
     self.worldName = worldName
     if worldName != 'highway':
         self.agentGraph = AgentGraph(self.data['agentGraph'])
         self.juniorGraph = AgentGraph(self.data['agentGraph'])
         self.juniorGraph.add(self.data['juniorGraph'])
     else:
         self.agentGraphCarB = AgentGraph(self.data['agentGraphCarB'],self.data['agentCarBStarts'])
         self.agentGraphTruck = AgentGraph(self.data['agentGraphTruck'],self.data['agentTruckStarts'])
         self.juniorGraph = AgentGraph(self.data['juniorGraph'])
     self.assertValid()
Exemplo n.º 2
0
 def __init__(self, worldName):
     self.loadData(worldName)
     self.worldName = worldName
     if worldName != 'highway':
         self.agentGraph = AgentGraph(self.data['agentGraph'])
         self.juniorGraph = AgentGraph(self.data['agentGraph'])
         self.juniorGraph.add(self.data['juniorGraph'])
     else:
         self.agentGraphCarB = AgentGraph(self.data['agentGraphCarB'],
                                          self.data['agentCarBStarts'])
         self.agentGraphTruck = AgentGraph(self.data['agentGraphTruck'],
                                           self.data['agentTruckStarts'])
         self.juniorGraph = AgentGraph(self.data['juniorGraph'])
     self.assertValid()
Exemplo n.º 3
0
class Layout(object):
    def __init__(self, worldName):
        self.loadData(worldName)
        self.worldName = worldName
        if worldName != 'highway':
            self.agentGraph = AgentGraph(self.data['agentGraph'])
            self.juniorGraph = AgentGraph(self.data['agentGraph'])
            self.juniorGraph.add(self.data['juniorGraph'])
        else:
            self.agentGraphCarB = AgentGraph(self.data['agentGraphCarB'],
                                             self.data['agentCarBStarts'])
            self.agentGraphTruck = AgentGraph(self.data['agentGraphTruck'],
                                              self.data['agentTruckStarts'])
            self.juniorGraph = AgentGraph(self.data['juniorGraph'])
        self.assertValid()

    def loadData(self, worldName):
        layoutFileName = worldName + '.json'
        layoutDir = Const.LAYOUT_DIR
        layoutPath = os.path.join(layoutDir, layoutFileName)
        layoutFile = open(layoutPath)
        self.data = json.load(layoutFile)
        layoutFile.close()

    def getWorldName(self):
        return self.worldName

    def getAgentStart(self):
        return self.data['starts']

    def getWidth(self):
        return self.data['size'][0]

    def getHeight(self):
        return self.data['size'][1]

    def getStartX(self):
        return self.data['junior'][0]

    def getStartY(self):
        return self.data['junior'][1]

    def getFinish(self):
        return self.data['finish']

    def getBlockData(self):
        return self.data['blocks']

    def getIntersectionNodes(self):
        return self.data['intersections']['nodes']

    def getIntersectionData(self):
        return self.data['intersections']

    def getJuniorDir(self):
        return self.data['juniorDir']

    def getBeliefRows(self):
        return int(self.getHeight() / Const.BELIEF_TILE_SIZE)

    def getBeliefCols(self):
        return int(self.getWidth() / Const.BELIEF_TILE_SIZE)

    def getAgentGraph(self):
        return self.agentGraph

    def getAgentGraphCarB(self):
        return self.agentGraphCarB

    def getAgentCarBStarts(self):
        return self.agentCarBStarts

    def getAgentGraphTruck(self):
        return self.agentGraphTruck

    def getAgentTruckStarts(self):
        return self.agentTruckStarts

    def getJuniorGraph(self):
        return self.juniorGraph

    def assertValid(self):
        width = self.getWidth()
        height = self.getHeight()
        assert (width % Const.BELIEF_TILE_SIZE == 0)
        assert (height % Const.BELIEF_TILE_SIZE == 0)
Exemplo n.º 4
0
 def __init__(self, worldName):
     self.loadData(worldName)
     self.agentGraph = AgentGraph(self.data['agentGraph'])
     self.juniorGraph = AgentGraph(self.data['agentGraph'])
     self.juniorGraph.add(self.data['juniorGraph'])
     self.assertValid()
Exemplo n.º 5
0
class Layout(object):

    def __init__(self, worldName):
        self.loadData(worldName)
        self.agentGraph = AgentGraph(self.data['agentGraph'])
        self.juniorGraph = AgentGraph(self.data['agentGraph'])
        self.juniorGraph.add(self.data['juniorGraph'])
        self.assertValid()
        
    def loadData(self, worldName):
        layoutFileName = worldName + '.json'
        layoutDir = Const.LAYOUT_DIR
        layoutPath = os.path.join(layoutDir, layoutFileName)
        layoutFile = open(layoutPath)
        self.data = json.load(layoutFile)
        layoutFile.close()
        
    def getAgentStart(self):
        return self.data['starts']

    def getWidth(self):
        return self.data['size'][0]
    
    def getHeight(self):
        return self.data['size'][1]
    
    def getStartX(self):
        return self.data['junior'][0]
    
    def getStartY(self):
        return self.data['junior'][1]
    
    def getFinish(self):
        return self.data['finish']
    
    def getBlockData(self):
        return self.data['blocks']
    
    def getIntersectionNodes(self):
        return self.data['intersections']['nodes']
    
    def getIntersectionData(self):
        return self.data['intersections']
    
    def getJuniorDir(self):
        return self.data['juniorDir']
    
    def getBeliefRows(self):
        return int(self.getHeight() / Const.BELIEF_TILE_SIZE)
    
    def getBeliefCols(self):
        return int(self.getWidth() / Const.BELIEF_TILE_SIZE)
    
    def getAgentGraph(self):
        return self.agentGraph
    
    def getJuniorGraph(self):
        return self.juniorGraph
    
    def assertValid(self):
        width = self.getWidth()
        height = self.getHeight()
        assert(width % Const.BELIEF_TILE_SIZE == 0)
        assert(height % Const.BELIEF_TILE_SIZE == 0)
Exemplo n.º 6
0
 def __init__(self, worldName):
     self.loadData(worldName)
     self.agentGraph = AgentGraph(self.data['agentGraph'])
     self.juniorGraph = AgentGraph(self.data['agentGraph'])
     self.juniorGraph.add(self.data['juniorGraph'])
     self.assertValid()