Example #1
0
    def __init__(self, world_map, surface):
        super().__init__()
        self.cells = []
        self.surface = surface
        self.obstacles = []
        self.color = constants.SILVER
        self.cp1 = []
        self.cp2 = []
        posCell = 0
        for col, tiles in enumerate(world_map):
            for row, tile in enumerate(tiles):
                if tile == '.' or tile == 'a':
                    posCell += 1
                    #keep this to update sprite when agent cross cell
                    c = Cell(posCell, row, col, obs=False)
                    self.cells.append(c)

                    self.color = constants.SILVER
                    self.setCell(row, col, 'cell', False, False, True, None,
                                 '')

                elif tile == 'o':
                    #o = type('obj', (object,), {'x': row, 'y': col})
                    o = Obstacles.Obstacle(row, col)
                    self.obstacles.append(o)

                    self.color = constants.SILVER
                    self.setCell(row, col, 'cell', True, False, False, None,
                                 '')
                elif tile == '1':
                    self.color = constants.GRAY
                    cp = Company.Company(row, col, 'cp1')
                    self.cp1.append(cp)
                    self.setCell(row, col, 'cp1', False, False, True, None, '')
                elif tile == '2':
                    self.color = constants.LIGHTLATEGREY
                    cp = Company.Company(row, col, 'cp2')
                    self.cp2.append(cp)
                    self.setCell(row, col, 'cp2', False, False, True, None, '')