class_docstr: A TestEnvironment to swap in for `starcraft2.env.sc2_env.SC2Env`.
  
  Repeatedly returns a mock observation for 10 calls to `step` whereupon it
  sets discount to 0. and changes state to READY_TO_END_EPISODE.
  
  Example:
  
  ```
  @mock.patch(
      'starcraft2.env.sc2_env.SC2Env',
      mock_sc2_env.SC2TestEnv)
  def test_method(self):
    env = sc2_env.SC2Env('nonexisting map')  # Really a SC2TestEnv.
    ...
  ```
  
  See base class for more details.
class_docstr_tok: ["A","TestEnvironment","to","swap","in","for","`","starcraft2.env.sc2_env.SC2Env","`",".","Repeatedly","returns","a","mock","observation","for","10","calls","to","`","step","`","whereupon","it","sets","discount","to","0.","and","changes","state","to","READY_TO_END_EPISODE",".","Example",":","``","`","@","mock.patch","(","'starcraft2.env.sc2_env.SC2Env","'",",","mock_sc2_env.SC2TestEnv",")","def","test_method","(","self",")",":","env","=","sc2_env.SC2Env","(","'nonexisting","map","'",")","#","Really","a","SC2TestEnv",".","...","``","`","See","base","class","for","more","details","."]
docstr: Initializes an SC2TestEnv.
  
  Args:
    map_name: Map name. Ignored.
    players: A list of Agent and Bot instances that specify who will play.
    agent_interface_format: A sequence containing one AgentInterfaceFormat per
      agent, matching the order of agents specified in the players list. Or
      a single AgentInterfaceFormat to be used for all agents. Note that
      InterfaceOptions may be supplied in place of AgentInterfaceFormat, in
      which case no action or observation processing will be carried out by
      PySC2. The sc_pb.ResponseObservation proto will be returned as the
      observation for the agent and passed actions must be instances of
      sc_pb.Action. This is intended for agents which use custom environment
      conversion code.
    discount: Unused.
    discount_zero_after_timeout: Unused.
    visualize: Unused.
    step_mul: Unused.
    realtime: Not supported by the mock environment, throws if set to true.
    save_replay_episodes: Unused.
    replay_dir: Unused.
    game_steps_per_episode: Unused.
    score_index: Unused.
    score_multiplier: Unused.
    random_seed: Unused.
    disable_fog: Unused.
    ensure_available_actions: Whether to throw an exception when an
      unavailable action is passed to step().
    version: Unused.
  Raises:
    ValueError: if args are passed.
docstr_tok: ["Initializes","an","SC2TestEnv",".","Args",":","map_name",":","Map","name",".","Ignored",".","players",":","A","list","of","Agent","and","Bot","instances","that","specify","who","will","play",".","agent_interface_format",":","A","sequence","containing","one","AgentInterfaceFormat","per","agent",",","matching","the","order","of","agents","specified","in","the","players","list",".","Or","a","single","AgentInterfaceFormat","to","be","used","for","all","agents",".","Note","that","InterfaceOptions","may","be","supplied","in","place","of","AgentInterfaceFormat",",","in","which","case","no","action","or","observation","processing","will","be","carried","out","by","PySC2",".","The","sc_pb.ResponseObservation","proto","will","be","returned","as","the","observation","for","the","agent","and","passed","actions","must","be","instances","of","sc_pb.Action",".","This","is","intended","for","agents","which","use","custom","environment","conversion","code",".","discount",":","Unused",".","discount_zero_after_timeout",":","Unused",".","visualize",":","Unused",".","step_mul",":","Unused",".","realtime",":","Not","supported","by","the","mock","environment",",","throws","if","set","to","true",".","save_replay_episodes",":","Unused",".","replay_dir",":","Unused",".","game_steps_per_episode",":","Unused",".","score_index",":","Unused",".","score_multiplier",":","Unused",".","random_seed",":","Unused",".","disable_fog",":","Unused",".","ensure_available_actions",":","Whether","to","throw","an","exception","when","an","unavailable","action","is","passed","to","step","(",")",".","version",":","Unused",".","Raises",":","ValueError",":","if","args","are","passed","."]
code: def __init__(
      self,
      *,
      map_name=None,
      players=None,
      agent_interface_format=None,
      discount=1.0,
      discount_zero_after_timeout=False,
      visualize=False,
      step_mul=None,
      realtime=False,
      save_replay_episodes=0,
      replay_dir=None,
      game_steps_per_episode=None,
      score_index=None,
      score_multiplier=None,
      random_seed=None,
      disable_fog=False,
      ensure_available_actions=True,
      version=None,
  ):
      """Initializes an SC2TestEnv.
  
      Args:
        map_name: Map name. Ignored.
        players: A list of Agent and Bot instances that specify who will play.
        agent_interface_format: A sequence containing one AgentInterfaceFormat per
          agent, matching the order of agents specified in the players list. Or
          a single AgentInterfaceFormat to be used for all agents. Note that
          InterfaceOptions may be supplied in place of AgentInterfaceFormat, in
          which case no action or observation processing will be carried out by
          PySC2. The sc_pb.ResponseObservation proto will be returned as the
          observation for the agent and passed actions must be instances of
          sc_pb.Action. This is intended for agents which use custom environment
          conversion code.
        discount: Unused.
        discount_zero_after_timeout: Unused.
        visualize: Unused.
        step_mul: Unused.
        realtime: Not supported by the mock environment, throws if set to true.
        save_replay_episodes: Unused.
        replay_dir: Unused.
        game_steps_per_episode: Unused.
        score_index: Unused.
        score_multiplier: Unused.
        random_seed: Unused.
        disable_fog: Unused.
        ensure_available_actions: Whether to throw an exception when an
          unavailable action is passed to step().
        version: Unused.
      Raises:
        ValueError: if args are passed.
      """
      del map_name  # Unused.
      del discount  # Unused.
      del discount_zero_after_timeout  # Unused.
      del visualize  # Unused.
      del step_mul  # Unused.
      del save_replay_episodes  # Unused.
      del replay_dir  # Unused.
      del game_steps_per_episode  # Unused.
      del score_index  # Unused.
      del score_multiplier  # Unused.
      del random_seed  # Unused.
      del disable_fog  # Unused.
      del ensure_available_actions  # Unused.
      del version  # Unused.
  
      if realtime:
          raise ValueError(
              "realtime mode is not supported by the mock env."
          )
  
      if not players:
          players = [sc2_env.Agent(sc2_env.Race.random)]
  
      num_agents = sum(
          1 for p in players if isinstance(p, sc2_env.Agent)
      )
  
      if agent_interface_format is None:
          raise ValueError("Please specify agent_interface_format.")
  
      if isinstance(
          agent_interface_format,
          (sc2_env.AgentInterfaceFormat, sc2api_pb2.InterfaceOptions),
      ):
          agent_interface_format = [agent_interface_format] * num_agents
  
      if len(agent_interface_format) != num_agents:
          raise ValueError(
              "The number of entries in agent_interface_format should "
              "correspond 1-1 with the number of agents."
          )
  
      self._game_info = _make_dummy_game_info(
          players, agent_interface_format
      )
      self._agent_interface_formats = agent_interface_format
      self._features = [
          features.features_from_game_info(
              game_info=g, agent_interface_format=aif
          )
          for g, aif in zip(
              self._game_info, self._agent_interface_formats
          )
      ]
  
      super(SC2TestEnv, self).__init__(
          num_agents=num_agents,
          action_spec=tuple(f.action_spec() for f in self._features),
          observation_spec=tuple(
              f.observation_spec() for f in self._features
          ),
      )
      self.episode_length = 10
  
imports: import numpy
  from pysc2.env import environment
  from pysc2.env import sc2_env
  from pysc2.lib import features
  from pysc2.lib import units
  from pysc2.tests import dummy_observation
  from s2clientprotocol import common_pb2
  from s2clientprotocol import raw_pb2
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 1 to create a new SC2TestEnv object from inherited base classes: _TestEnvironment with example: obj = SC2TestEnv()