original_docstring: Start the game. If `episode_time` is given, the game will end after
          the specified time.
  
          Args:
              map_id:
              episode_time:
              manual_control:
              log_events:
          
docstring: Start the game. If `episode_time` is given, the game will end after
  the specified time.
docstring_tokens: Start the game . If ` episode_time ` is given the game will end after the specified time .
code: def start(self, map_id, episode_time=None, manual_control=False, log_events=False):
          """Start the game. If `episode_time` is given, the game will end after
          the specified time.
  
          Args:
              map_id:
              episode_time:
              manual_control:
              log_events:
          """
          assert type(manual_control) is bool
          self.manual_control = manual_control
  
          # Save statistics for this map
          self.statistics[map_id] = {k: 0 for k in self.stat_keys}
  
          # Episode time
          self.episode_time = episode_time
  
          # initialize the game
          self.game = DoomGame()
          self.game.set_doom_scenario_path(self.scenario_path)
          self.game.set_doom_game_path(self.game_path)
  
          # map
          assert map_id > 0
          self.map_id = map_id
          self.game.set_doom_map("map%02i" % map_id)
  
          # time limit
          if episode_time is not None:
              self.game.set_episode_timeout(int(35 * episode_time))
  
          # log events that happen during the game (useful for testing)
          self.log_events = log_events
  
          # game parameters
          args = []
  
          # host / server
          if self.players_per_game > 1:
              port = 5092 + (self.player_rank // self.players_per_game)
              if self.player_rank % self.players_per_game == 0:
                  args.append('-host %i -port %i' % (self.players_per_game, port))
              else:
                  args.append('-join 127.0.0.1:%i' % port)
          else:
              args.append('-host 1')
  
          # screen buffer / depth buffer / labels buffer / mode
          screen_resolution = getattr(ScreenResolution, self.screen_resolution)
          self.game.set_screen_resolution(screen_resolution)
          self.game.set_screen_format(getattr(ScreenFormat, self.screen_format))
          self.game.set_depth_buffer_enabled(self.use_depth_buffer)
          self.game.set_labels_buffer_enabled(self.use_labels_buffer or
                                              self.use_game_features)
          self.game.set_mode(getattr(Mode, self.mode))
  
          # rendering options
          self.game.set_render_hud(self.render_hud)
          self.game.set_render_minimal_hud(self.render_minimal_hud)
          self.game.set_render_crosshair(self.render_crosshair)
          self.game.set_render_weapon(self.render_weapon)
          self.game.set_render_decals(self.render_decals)
          self.game.set_render_particles(self.render_particles)
          self.game.set_render_effects_sprites(self.render_effects_sprites)
  
          # deathmatch mode
          # players will respawn automatically after they die
          # autoaim is disabled for all players
          args.append('-deathmatch')
          args.append('+sv_forcerespawn 1')
          args.append('+sv_noautoaim 1')
  
          # respawn invincibility / distance
          # players will be invulnerable for two second after spawning
          # players will be spawned as far as possible from any other players
          args.append('+sv_respawnprotect %i' % self.respawn_protect)
          args.append('+sv_spawnfarthest %i' % self.spawn_farthest)
  
          # freelook / agent name / agent color
          args.append('+freelook %i' % (1 if self.freelook else 0))
          args.append('+name %s' % self.name)
          args.append('+colorset %i' % self.color)
  
          # enable the cheat system (so that we can still
          # send commands to the game in self-play mode)
          args.append('+sv_cheats 1')
  
          # load parameters
          self.args = args
          for arg in args:
              self.game.add_game_args(arg)
  
          # window visibility
          self.game.set_window_visible(self.visible)
  
          # available buttons
          self.mapping = add_buttons(self.game, self.action_builder.available_buttons)
  
          # doom skill (https://zdoom.org/wiki/GameSkill)
          self.game.set_doom_skill(self.doom_skill + 1)
  
          # start the game
          self.game.init()
  
          # initialize the game after player spawns
          self.initialize_game()
code_tokens: def start ( self , map_id , episode_time = None , manual_control = False , log_events = False ) : assert type ( manual_control ) is bool self . manual_control = manual_control self . statistics [ map_id ] = { k : 0 for k in self . stat_keys } self . episode_time = episode_time self . game = DoomGame ( ) self . game . set_doom_scenario_path ( self . scenario_path ) self . game . set_doom_game_path ( self . game_path ) assert map_id > 0 self . map_id = map_id self . game . set_doom_map ( "map%02i" % map_id ) if episode_time is not None : self . game . set_episode_timeout ( int ( 35 * episode_time ) ) self . log_events = log_events args = [ ] if self . players_per_game > 1 : port = 5092 + ( self . player_rank // self . players_per_game ) if self . player_rank % self . players_per_game == 0 : args . append ( '-host %i -port %i' % ( self . players_per_game , port ) ) else : args . append ( '-join 127.0.0.1:%i' % port ) else : args . append ( '-host 1' ) screen_resolution = getattr ( ScreenResolution , self . screen_resolution ) self . game . set_screen_resolution ( screen_resolution ) self . game . set_screen_format ( getattr ( ScreenFormat , self . screen_format ) ) self . game . set_depth_buffer_enabled ( self . use_depth_buffer ) self . game . set_labels_buffer_enabled ( self . use_labels_buffer or self . use_game_features ) self . game . set_mode ( getattr ( Mode , self . mode ) ) self . game . set_render_hud ( self . render_hud ) self . game . set_render_minimal_hud ( self . render_minimal_hud ) self . game . set_render_crosshair ( self . render_crosshair ) self . game . set_render_weapon ( self . render_weapon ) self . game . set_render_decals ( self . render_decals ) self . game . set_render_particles ( self . render_particles ) self . game . set_render_effects_sprites ( self . render_effects_sprites ) args . append ( '-deathmatch' ) args . append ( '+sv_forcerespawn 1' ) args . append ( '+sv_noautoaim 1' ) args . append ( '+sv_respawnprotect %i' % self . respawn_protect ) args . append ( '+sv_spawnfarthest %i' % self . spawn_farthest ) args . append ( '+freelook %i' % ( 1 if self . freelook else 0 ) ) args . append ( '+name %s' % self . name ) args . append ( '+colorset %i' % self . color ) args . append ( '+sv_cheats 1' ) self . args = args for arg in args : self . game . add_game_args ( arg ) self . game . set_window_visible ( self . visible ) self . mapping = add_buttons ( self . game , self . action_builder . available_buttons ) self . game . set_doom_skill ( self . doom_skill + 1 ) self . game . init ( ) self . initialize_game ( )
short_docstring: Start the game.
short_docstring_tokens: Start the game .
comment: """Start the game. If `episode_time` is given, the game will end after
          the specified time.
  
          Args:
              map_id:
              episode_time:
              manual_control:
              log_events:
          """$SEP$# Save statistics for this map$SEP$# Episode time$SEP$# initialize the game$SEP$# map$SEP$# time limit$SEP$# log events that happen during the game (useful for testing)$SEP$# game parameters$SEP$# host / server$SEP$# screen buffer / depth buffer / labels buffer / mode$SEP$# rendering options$SEP$# deathmatch mode$SEP$# players will respawn automatically after they die$SEP$# autoaim is disabled for all players$SEP$# respawn invincibility / distance$SEP$# players will be invulnerable for two second after spawning$SEP$# players will be spawned as far as possible from any other players$SEP$# freelook / agent name / agent color$SEP$# enable the cheat system (so that we can still$SEP$# send commands to the game in self-play mode)$SEP$# load parameters$SEP$# window visibility$SEP$# available buttons$SEP$# doom skill (https://zdoom.org/wiki/GameSkill)$SEP$# start the game$SEP$# initialize the game after player spawns