original_docstring: Print agent statistics. If `map_id` is given, statistics are given
          for the specified map only. Otherwise, statistics are given for all
          maps, with a summary.
  
          Args:
              eval_time:
          
docstring: Print agent statistics. If `map_id` is given, statistics are given
  for the specified map only. Otherwise, statistics are given for all
  maps, with a summary.
docstring_tokens: Print agent statistics . If ` map_id ` is given statistics are given for the specified map only . Otherwise statistics are given for all maps with a summary .
code: def print_statistics(self, eval_time=None):
          """Print agent statistics. If `map_id` is given, statistics are given
          for the specified map only. Otherwise, statistics are given for all
          maps, with a summary.
  
          Args:
              eval_time:
          """
          if 'all' in self.statistics:
              del self.statistics['all']
          map_ids = sorted(self.statistics.keys())
          if len(map_ids) == 0:
              logger.info("No statistics to show!")
              return
          for v in self.statistics.values():
              assert set(self.stat_keys) == set(v.keys())
  
          # sum the results on all maps for global statistics
          self.statistics['all'] = {
              k: sum(v[k] for v in self.statistics.values())
              for k in self.stat_keys
          }
  
          # number of frags (kills - suicides)
          # 100% accurate if the number of frags is given by 'FRAGCOUNT'
          # almost 100% accurate if it is based on an internal ACS variable
          for v in self.statistics.values():
              v['frags'] = v['kills'] - v['suicides']
  
          # number of frags per minutes (with and without respawn time)
          if eval_time is not None:
              assert eval_time % 60 == 0
              for k, v in self.statistics.items():
                  eval_minutes = eval_time / 60
                  if k == 'all':
                      eval_minutes *= (len(self.statistics) - 1)
                  respawn_time = (v['deaths'] * RESPAWN_SECONDS * 1.0 / 60)
                  v['frags_pm'] = v['frags'] * 1.0 / eval_minutes
                  v['frags_pm_r'] = v['frags'] * 1.0 / (eval_minutes + respawn_time)
  
          # Kills / Deaths
          # 100% accurate if the number of kills is given by an ACS variable
          # almost 100% accurate if it is based on 'FRAGCOUNT'
          for v in self.statistics.values():
              v['k/d'] = v['kills'] * 1.0 / max(1, v['deaths'])
  
          # statistics to log
          log_lines = [
              [''] + ['Map%02i' % i for i in map_ids] + ['All'],
              ('Kills', 'kills'),
              ('Deaths', 'deaths'),
              ('Suicides', 'suicides'),
              ('Frags', 'frags'),
              ('Frags/m', 'frags_pm'),
              ('Frags/m (r)', 'frags_pm_r'),
              ('K/D', 'k/d'),
              None,
              ('Medikits', 'medikits'),
              ('Armors', 'armors'),
              ('SuperShotgun', 'shotgun'),
              ('Chaingun', 'chaingun'),
              ('RocketLauncher', 'rocketlauncher'),
              ('PlasmaRifle', 'plasmarifle'),
              ('BFG9000', 'bfg9000'),
              ('Bullets', 'bullets'),
              ('Shells', 'shells'),
              ('Rockets', 'rockets'),
              ('Cells', 'cells'),
          ]
  
          # only show statistics on all maps if there is more than one map
          if len(map_ids) > 1:
              map_ids.append('all')
  
          logger.info('*************** Game statistics summary ***************')
          log_pattern = '{: >15}' + ('{: >8}' * len(map_ids))
          for line in log_lines:
              if line is None:
                  logger.info('')
              else:
                  if type(line) is tuple:
                      assert len(line) == 2
                      name, k = line
                      if k in ['frags_pm', 'frags_pm_r'] and eval_time is None:
                          continue
                      line = ['%s:' % name]
                      line += [self.statistics[map_id][k] for map_id in map_ids]
                  else:
                      assert type(line) is list
                      line = line[:len(map_ids) + 1]
                  line = ['%.3f' % x if type(x) is float else x for x in line]
                  logger.info(log_pattern.format(*line))
code_tokens: def print_statistics ( self , eval_time = None ) : if 'all' in self . statistics : del self . statistics [ 'all' ] map_ids = sorted ( self . statistics . keys ( ) ) if len ( map_ids ) == 0 : logger . info ( "No statistics to show!" ) return for v in self . statistics . values ( ) : assert set ( self . stat_keys ) == set ( v . keys ( ) ) self . statistics [ 'all' ] = { k : sum ( v [ k ] for v in self . statistics . values ( ) ) for k in self . stat_keys } for v in self . statistics . values ( ) : v [ 'frags' ] = v [ 'kills' ] - v [ 'suicides' ] if eval_time is not None : assert eval_time % 60 == 0 for k , v in self . statistics . items ( ) : eval_minutes = eval_time / 60 if k == 'all' : eval_minutes *= ( len ( self . statistics ) - 1 ) respawn_time = ( v [ 'deaths' ] * RESPAWN_SECONDS * 1.0 / 60 ) v [ 'frags_pm' ] = v [ 'frags' ] * 1.0 / eval_minutes v [ 'frags_pm_r' ] = v [ 'frags' ] * 1.0 / ( eval_minutes + respawn_time ) for v in self . statistics . values ( ) : v [ 'k/d' ] = v [ 'kills' ] * 1.0 / max ( 1 , v [ 'deaths' ] ) log_lines = [ [ '' ] + [ 'Map%02i' % i for i in map_ids ] + [ 'All' ] , ( 'Kills' , 'kills' ) , ( 'Deaths' , 'deaths' ) , ( 'Suicides' , 'suicides' ) , ( 'Frags' , 'frags' ) , ( 'Frags/m' , 'frags_pm' ) , ( 'Frags/m (r)' , 'frags_pm_r' ) , ( 'K/D' , 'k/d' ) , None , ( 'Medikits' , 'medikits' ) , ( 'Armors' , 'armors' ) , ( 'SuperShotgun' , 'shotgun' ) , ( 'Chaingun' , 'chaingun' ) , ( 'RocketLauncher' , 'rocketlauncher' ) , ( 'PlasmaRifle' , 'plasmarifle' ) , ( 'BFG9000' , 'bfg9000' ) , ( 'Bullets' , 'bullets' ) , ( 'Shells' , 'shells' ) , ( 'Rockets' , 'rockets' ) , ( 'Cells' , 'cells' ) , ] if len ( map_ids ) > 1 : map_ids . append ( 'all' ) logger . info ( '*************** Game statistics summary ***************' ) log_pattern = '{: >15}' + ( '{: >8}' * len ( map_ids ) ) for line in log_lines : if line is None : logger . info ( '' ) else : if type ( line ) is tuple : assert len ( line ) == 2 name , k = line if k in [ 'frags_pm' , 'frags_pm_r' ] and eval_time is None : continue line = [ '%s:' % name ] line += [ self . statistics [ map_id ] [ k ] for map_id in map_ids ] else : assert type ( line ) is list line = line [ : len ( map_ids ) + 1 ] line = [ '%.3f' % x if type ( x ) is float else x for x in line ] logger . info ( log_pattern . format ( * line ) )
short_docstring: Print agent statistics.
short_docstring_tokens: Print agent statistics .
comment: """Print agent statistics. If `map_id` is given, statistics are given
          for the specified map only. Otherwise, statistics are given for all
          maps, with a summary.
  
          Args:
              eval_time:
          """$SEP$# sum the results on all maps for global statistics$SEP$# number of frags (kills - suicides)$SEP$# 100% accurate if the number of frags is given by 'FRAGCOUNT'$SEP$# almost 100% accurate if it is based on an internal ACS variable$SEP$# number of frags per minutes (with and without respawn time)$SEP$# Kills / Deaths$SEP$# 100% accurate if the number of kills is given by an ACS variable$SEP$# almost 100% accurate if it is based on 'FRAGCOUNT'$SEP$# statistics to log$SEP$# only show statistics on all maps if there is more than one map