(self, maze, xy_scale=2.0, z_height=2.0,
             skybox_texture=None, wall_textures=None, floor_textures=None,
             aesthetic='default', name='maze')
Initializes this maze arena.

    Args:
      maze: A `labmaze.BaseMaze` instance.
      xy_scale: The size of each maze cell in metres.
      z_height: The z-height of the maze in metres.
      skybox_texture: (optional) A `composer.Entity` that provides a texture
        asset for the skybox.
      wall_textures: (optional) Either a `composer.Entity` that provides texture
        assets for the maze walls, or a dict mapping printable characters to
        such Entities. In the former case, the maze walls are assumed to be
        represented by '*' in the maze's entity layer. In the latter case,
        the dict's keys specify the different characters that can be present
        in the maze's entity layer, and the dict's values are the corresponding
        texture providers.
      floor_textures: (optional) A `composer.Entity` that provides texture
        assets for the maze floor. Unlike with walls, we do not currently
        support per-variation floor texture. Instead, we sample textures from
        the same texture provider for each variation in the variations layer.
      aesthetic: option to adjust the material properties and skybox
      name: (optional) A string, the name of this arena.
Initializes this maze arena.
Initializes this maze arena .
def _build(self, maze, xy_scale=2.0, z_height=2.0,
             skybox_texture=None, wall_textures=None, floor_textures=None,
             aesthetic='default', name='maze'):
    """Initializes this maze arena.

    Args:
      maze: A `labmaze.BaseMaze` instance.
      xy_scale: The size of each maze cell in metres.
      z_height: The z-height of the maze in metres.
      skybox_texture: (optional) A `composer.Entity` that provides a texture
        asset for the skybox.
      wall_textures: (optional) Either a `composer.Entity` that provides texture
        assets for the maze walls, or a dict mapping printable characters to
        such Entities. In the former case, the maze walls are assumed to be
        represented by '*' in the maze's entity layer. In the latter case,
        the dict's keys specify the different characters that can be present
        in the maze's entity layer, and the dict's values are the corresponding
        texture providers.
      floor_textures: (optional) A `composer.Entity` that provides texture
        assets for the maze floor. Unlike with walls, we do not currently
        support per-variation floor texture. Instead, we sample textures from
        the same texture provider for each variation in the variations layer.
      aesthetic: option to adjust the material properties and skybox
      name: (optional) A string, the name of this arena.
    """
    super()._build(name)
    self._maze = maze
    self._xy_scale = xy_scale
    self._z_height = z_height

    self._x_offset = (self._maze.width - 1) / 2
    self._y_offset = (self._maze.height - 1) / 2

    self._mjcf_root.default.geom.rgba = [1, 1, 1, 1]

    if aesthetic != 'default':
      sky_info = locomotion_arenas_assets.get_sky_texture_info(aesthetic)
      texturedir = locomotion_arenas_assets.get_texturedir(aesthetic)
      self._mjcf_root.compiler.texturedir = texturedir
      self._skybox = self._mjcf_root.asset.add(
          'texture', name='aesthetic_skybox', file=sky_info.file,
          type='skybox', gridsize=sky_info.gridsize,
          gridlayout=sky_info.gridlayout)
    elif skybox_texture:
      self._skybox_texture = skybox_texture.texture
      self.attach(skybox_texture)
    else:
      self._skybox_texture = self._mjcf_root.asset.add(
          'texture', type='skybox', name='skybox', builtin='gradient',
          rgb1=[.4, .6, .8], rgb2=[0, 0, 0], width=100, height=100)

    self._texturing_geom_names = []
    self._texturing_material_names = []
    if wall_textures:
      if isinstance(wall_textures, dict):
        for texture_provider in set(wall_textures.values()):
          self.attach(texture_provider)
        self._wall_textures = {
            wall_char: texture_provider.textures
            for wall_char, texture_provider in wall_textures.items()
        }
      else:
        self.attach(wall_textures)
        self._wall_textures = {_DEFAULT_WALL_CHAR: wall_textures.textures}
    else:
      self._wall_textures = {_DEFAULT_WALL_CHAR: [self._mjcf_root.asset.add(
          'texture', type='2d', name='wall', builtin='flat',
          rgb1=[.8, .8, .8], width=100, height=100)]}

    if aesthetic != 'default':
      ground_info = locomotion_arenas_assets.get_ground_texture_info(aesthetic)
      self._floor_textures = [
          self._mjcf_root.asset.add(
              'texture',
              name='aesthetic_texture_main',
              file=ground_info.file,
              type=ground_info.type),
          self._mjcf_root.asset.add(
              'texture',
              name='aesthetic_texture',
              file=ground_info.file,
              type=ground_info.type)
      ]
    elif floor_textures:
      self._floor_textures = floor_textures.textures
      self.attach(floor_textures)
    else:
      self._floor_textures = [self._mjcf_root.asset.add(
          'texture', type='2d', name='floor', builtin='flat',
          rgb1=[.2, .2, .2], width=100, height=100)]

    ground_x = ((self._maze.width - 1) + 1) * (xy_scale / 2)
    ground_y = ((self._maze.height - 1) + 1) * (xy_scale / 2)
    self._mjcf_root.worldbody.add(
        'geom', name='ground', type='plane',
        pos=[0, 0, 0], size=[ground_x, ground_y, 1], rgba=[0, 0, 0, 0])

    self._maze_body = self._mjcf_root.worldbody.add('body', name='maze_body')

    self._mjcf_root.visual.map.znear = 0.0005

    # Choose the FOV so that the maze always fits nicely within the frame
    # irrespective of actual maze size.
    maze_size = max(self._maze.width, self._maze.height)
    top_camera_fovy = (360 / np.pi) * np.arctan2(
        _TOP_CAMERA_Y_PADDING_FACTOR * maze_size * self._xy_scale / 2,
        _TOP_CAMERA_DISTANCE)
    self._top_camera = self._mjcf_root.worldbody.add(
        'camera', name='top_camera',
        pos=[0, 0, _TOP_CAMERA_DISTANCE], zaxis=[0, 0, 1], fovy=top_camera_fovy)

    self._target_positions = ()
    self._spawn_positions = ()

    self._text_maze_regenerated_hook = None
    self._tile_geom_names = {}
def _build ( self , maze , xy_scale = 2.0 , z_height = 2.0 , skybox_texture = None , wall_textures = None , floor_textures = None , aesthetic = 'default' , name = 'maze' ) : super ( ) . _build ( name ) self . _maze = maze self . _xy_scale = xy_scale self . _z_height = z_height self . _x_offset = ( self . _maze . width - 1 ) / 2 self . _y_offset = ( self . _maze . height - 1 ) / 2 self . _mjcf_root . default . geom . rgba = [ 1 , 1 , 1 , 1 ] if aesthetic != 'default' : sky_info = locomotion_arenas_assets . get_sky_texture_info ( aesthetic ) texturedir = locomotion_arenas_assets . get_texturedir ( aesthetic ) self . _mjcf_root . compiler . texturedir = texturedir self . _skybox = self . _mjcf_root . asset . add ( 'texture' , name = 'aesthetic_skybox' , file = sky_info . file , type = 'skybox' , gridsize = sky_info . gridsize , gridlayout = sky_info . gridlayout ) elif skybox_texture : self . _skybox_texture = skybox_texture . texture self . attach ( skybox_texture ) else : self . _skybox_texture = self . _mjcf_root . asset . add ( 'texture' , type = 'skybox' , name = 'skybox' , builtin = 'gradient' , rgb1 = [ .4 , .6 , .8 ] , rgb2 = [ 0 , 0 , 0 ] , width = 100 , height = 100 ) self . _texturing_geom_names = [ ] self . _texturing_material_names = [ ] if wall_textures : if isinstance ( wall_textures , dict ) : for texture_provider in set ( wall_textures . values ( ) ) : self . attach ( texture_provider ) self . _wall_textures = { wall_char : texture_provider . textures for wall_char , texture_provider in wall_textures . items ( ) } else : self . attach ( wall_textures ) self . _wall_textures = { _DEFAULT_WALL_CHAR : wall_textures . textures } else : self . _wall_textures = { _DEFAULT_WALL_CHAR : [ self . _mjcf_root . asset . add ( 'texture' , type = '2d' , name = 'wall' , builtin = 'flat' , rgb1 = [ .8 , .8 , .8 ] , width = 100 , height = 100 ) ] } if aesthetic != 'default' : ground_info = locomotion_arenas_assets . get_ground_texture_info ( aesthetic ) self . _floor_textures = [ self . _mjcf_root . asset . add ( 'texture' , name = 'aesthetic_texture_main' , file = ground_info . file , type = ground_info . type ) , self . _mjcf_root . asset . add ( 'texture' , name = 'aesthetic_texture' , file = ground_info . file , type = ground_info . type ) ] elif floor_textures : self . _floor_textures = floor_textures . textures self . attach ( floor_textures ) else : self . _floor_textures = [ self . _mjcf_root . asset . add ( 'texture' , type = '2d' , name = 'floor' , builtin = 'flat' , rgb1 = [ .2 , .2 , .2 ] , width = 100 , height = 100 ) ] ground_x = ( ( self . _maze . width - 1 ) + 1 ) * ( xy_scale / 2 ) ground_y = ( ( self . _maze . height - 1 ) + 1 ) * ( xy_scale / 2 ) self . _mjcf_root . worldbody . add ( 'geom' , name = 'ground' , type = 'plane' , pos = [ 0 , 0 , 0 ] , size = [ ground_x , ground_y , 1 ] , rgba = [ 0 , 0 , 0 , 0 ] ) self . _maze_body = self . _mjcf_root . worldbody . add ( 'body' , name = 'maze_body' ) self . _mjcf_root . visual . map . znear = 0.0005 # Choose the FOV so that the maze always fits nicely within the frame # irrespective of actual maze size. maze_size = max ( self . _maze . width , self . _maze . height ) top_camera_fovy = ( 360 / np . pi ) * np . arctan2 ( _TOP_CAMERA_Y_PADDING_FACTOR * maze_size * self . _xy_scale / 2 , _TOP_CAMERA_DISTANCE ) self . _top_camera = self . _mjcf_root . worldbody . add ( 'camera' , name = 'top_camera' , pos = [ 0 , 0 , _TOP_CAMERA_DISTANCE ] , zaxis = [ 0 , 0 , 1 ] , fovy = top_camera_fovy ) self . _target_positions = ( ) self . _spawn_positions = ( ) self . _text_maze_regenerated_hook = None self . _tile_geom_names = { }