class_docstr: 2-player environment with "player_0" and "player_1", playing the 007 game.
  Each player state has:
  - a number of ammunition (init: 0)
  - a number of consecutive protection (init: 0)
  Each player can:
  - reload: to get one more ammunition
  - fire: to try to kill the other player (reloads instead if no ammunition)
  - protect: to avoid the other player's fire
  
  The winner is either:
  - the first to fire while the other people is reloading (or firing without ammunition)
  - the one that did not protect more that 4 times consecutively if the other one did.
  The game stops if nobody won after 100 iterations.
class_docstr_tok: ["2-player","environment","with","``","player_0","''","and","``","player_1","''",",","playing","the","007","game",".","Each","player","state","has",":","-","a","number","of","ammunition","(","init",":","0",")","-","a","number","of","consecutive","protection","(","init",":","0",")","Each","player","can",":","-","reload",":","to","get","one","more","ammunition","-","fire",":","to","try","to","kill","the","other","player","(","reloads","instead","if","no","ammunition",")","-","protect",":","to","avoid","the","other","player","'s","fire","The","winner","is","either",":","-","the","first","to","fire","while","the","other","people","is","reloading","(","or","firing","without","ammunition",")","-","the","one","that","did","not","protect","more","that","4","times","consecutively","if","the","other","one","did",".","The","game","stops","if","nobody","won","after","100","iterations","."]
docstr: Returns observations from ready agents.
  The returns are dicts mapping from agent_id strings to values. The
  number of agents in the env can vary over time.
  Returns
  -------
      obs (dict): New observations for each ready agent.
      rewards (dict): Reward values for each ready agent. If the
          episode is just started, the value will be None.
      dones (dict): Done values for each ready agent. The special key
          "__all__" (required) is used to indicate env termination.
      infos (dict): Optional info values for each agent id.
docstr_tok: ["Returns","observations","from","ready","agents",".","The","returns","are","dicts","mapping","from","agent_id","strings","to","values",".","The","number","of","agents","in","the","env","can","vary","over","time",".","Returns","--","--","--","-","obs","(","dict",")",":","New","observations","for","each","ready","agent",".","rewards","(","dict",")",":","Reward","values","for","each","ready","agent",".","If","the","episode","is","just","started",",","the","value","will","be","None",".","dones","(","dict",")",":","Done","values","for","each","ready","agent",".","The","special","key","``","__all__","''","(","required",")","is","used","to","indicate","env","termination",".","infos","(","dict",")",":","Optional","info","values","for","each","agent","id","."]
code: def step(self, action_dict: tp.Dict[str, int]) -> base.StepReturn:
      """Returns observations from ready agents.
      The returns are dicts mapping from agent_id strings to values. The
      number of agents in the env can vary over time.
      Returns
      -------
          obs (dict): New observations for each ready agent.
          rewards (dict): Reward values for each ready agent. If the
              episode is just started, the value will be None.
          dones (dict): Done values for each ready agent. The special key
              "__all__" (required) is used to indicate env termination.
          infos (dict): Optional info values for each agent id.
      """
      if self.verbose:
          strings: tp.List[str] = []
          for k in range(2):
              action = JamesBond.actions[action_dict[f"player_{k}"]]
              strings.append(
                  f"Player {k} {self.players[k].get_state()}: {action}"
              )
          print(" - ".join(strings))
      actions = [
          JamesBond.actions[action_dict[f"player_{k}"]]
          for k in range(2)
      ]
      self._step += 1
      info: tp.Dict[tp.Any, tp.Any] = {}
      rew = {"player_0": 0, "player_1": 0}
      # change impossible actions
      actions = [
          "reload" if a == "fire" and not p.ammunitions else a
          for p, a in zip(self.players, actions)
      ]
      # update players
      for player, action in zip(self.players, actions):
          player.update_with_action(action)
      # main way to win
      if actions[0] == "fire" and actions[1] == "reload":
          rew = {"player_0": 1, "player_1": 0}
      elif actions[0] == "reload" and actions[1] == "fire":
          rew = {"player_0": 0, "player_1": 1}
      # lose if you keep protecting
      if any(
          p.consecutive_protect > JamesBond.max_consecutive_protect
          for p in self.players
      ):
          if (
              self.players[0].consecutive_protect
              > self.players[1].consecutive_protect
          ):
              rew = {"player_0": 0, "player_1": 1}
          elif (
              self.players[1].consecutive_protect
              > self.players[0].consecutive_protect
          ):
              rew = {"player_0": 1, "player_1": 0}
          # if both keep protecting... well, it goes on...
      obs = self._make_observations()
      done = {
          "__all__": self._step == 100
          or sum(abs(x) for x in rew.values()) > 0
      }
      return obs, rew, done, info
  
file_path: nevergrad/nevergrad/functions/rl/envs.py
imports: import typing
  import numpy
  import gym
  from .None import base
label_desc: Use image node_id 5 for calling the DoubleOSeven obj's underlying member method code with example usage: obj.step(action_dict) and returns: obs,  rew,  done,  info