示例#1
0
 def action_space(self):
     if isinstance(self.inter.action_space, NoneSpace):
         return NoneSpace()
     assert isinstance(self.inter.action_space, spaces.Tuple)
     sps = self.inter.action_space.spaces
     if any([isinstance(sp, NoneSpace) for sp in sps]):
         return NoneSpace()
     numdim = sum([np.int(np.prod(sps[i].shape)) for i in range(len(sps))])
     return spaces.Box(-1., 1., shape=(numdim, ))
示例#2
0
 def __init__(self,
              env_id='Pomme1v1',
              random_side=True,
              agent_list=None,
              rule_agents=[],
              replay_dir=None):
     super(pommerman_1v1, self).__init__(env_id,
                                         random_side,
                                         agent_list,
                                         rule_agents,
                                         replay_dir,
                                         n_player=2)
     ac_sp = self.env.action_space
     self.action_space = spaces.Tuple([ac_sp] * 2)
     self.observation_space = spaces.Tuple([NoneSpace(), NoneSpace()])
示例#3
0
 def observation_space(self):
     if isinstance(self.inter.observation_space, NoneSpace):
         return NoneSpace()
     assert isinstance(self.inter.observation_space, spaces.Tuple)
     low = np.concatenate([box.low for box in self.inter.observation_space.spaces])
     high = np.concatenate([box.high for box in self.inter.observation_space.spaces])
     return spaces.Box(low=low, high=high)
示例#4
0
 def __init__(self,
              env_id='PommeTeam-v0',
              random_side=True,
              agent_list=None,
              rule_agents=[],
              replay_dir=None):
     super(pommerman_2v2, self).__init__(env_id,
                                         random_side,
                                         agent_list,
                                         rule_agents,
                                         replay_dir,
                                         n_player=4)
     ac_sp = spaces.Tuple([spaces.Discrete(6)] * 2)
     self.action_space = spaces.Tuple([ac_sp] * 2)
     ob_sp = spaces.Tuple([NoneSpace(), NoneSpace()])
     self.observation_space = spaces.Tuple([ob_sp] * 2)
示例#5
0
 def __init__(self,
              team_size=2,
              time_limit=45,
              disable_walker_contacts=True,
              team_num=2,
              render_name="human"):
     self.team_size = team_size
     self.team_num = team_num
     self.env = dm_soccer.load(self.team_size, time_limit,
                               disable_walker_contacts)
     ac_sp_i = spaces.Box(low=-1.0, high=1.0, shape=(3, ), dtype=np.float32)
     ac_sp = spaces.Tuple(
         [spaces.Tuple(tuple([ac_sp_i] * self.team_size))] * self.team_num)
     self.action_space = ac_sp
     #print(self.action_space)
     self.observation_space = spaces.Tuple([NoneSpace(), NoneSpace()])
     self.timestep = None
     odict_sp = {}
     odict = self.env.observation_spec()
     for key in odict[0]:
         odict_sp[key] = spaces.Box(-np.inf,
                                    np.inf,
                                    shape=(np.int(
                                        np.prod(odict[0][key].shape)), ))
     self.observation_space = spaces.Tuple(
         [spaces.Tuple([spaces.Dict(odict_sp)] * self.team_size)] *
         self.team_num)
     # render
     render_mode_list = self.create_render_mode(render_name,
                                                show=False,
                                                return_pixel=True)
     if render_mode_list is not None:
         self.metadata['render.modes'] = list(render_mode_list.keys())
         self.viewer = {key: None for key in render_mode_list.keys()}
     else:
         self.metadata['render.modes'] = []
     self.render_mode_list = render_mode_list
     # set seed
     self._seed()
示例#6
0
 def observation_space(self):
     inter_space = self.inter.observation_space
     if isinstance(inter_space, NoneSpace):
         return NoneSpace()
     elif isinstance(inter_space, spaces.Box):
         return spaces.Box(low=self.op(inter_space.low),
                           high=self.op(inter_space.high),
                           dtype=inter_space.dtype)
     else:
         assert isinstance(inter_space, spaces.Tuple)
         sps = list(inter_space.spaces)
         assert isinstance(sps[self.index], spaces.Box)
         sps[self.index] = spaces.Box(low=self.op(sps[self.index].low),
                                      high=self.op(sps[self.index].high),
                                      dtype=sps[self.index].dtype)
         return spaces.Tuple(tuple(sps))
示例#7
0
 def observation_space(self):
     if isinstance(self.inter.observation_space, gym.spaces.Tuple):
         return self.inter.observation_space[0]
     else:
         return NoneSpace()
示例#8
0
 def observation_space(self):
     inter_space = self.inter.observation_space
     if isinstance(inter_space, NoneSpace):
         return NoneSpace()
     else:
         return stack_space(inter_space, self.k)
示例#9
0
 def observation_space(self):
     if self.wrapper:
         return self.wrapper.observation_space
     else:
         return NoneSpace()
示例#10
0
 def observation_space(self):
     if isinstance(self.inter.observation_space, NoneSpace):
         return NoneSpace()
     else:
         assert isinstance(self.inter.observation_space, spaces.Tuple)
         return self.inter.observation_space.spaces[0]
示例#11
0
 def observation_space(self):
     if isinstance(self.inter.observation_space, NoneSpace):
         return NoneSpace()
     assert isinstance(self.inter.observation_space, spaces.Dict)
     return self.convert_OrderedDict(self.inter.observation_space.spaces)
示例#12
0
 def __init__(self, env, cheat_players=None):
     super(AllObs, self).__init__(env)
     self.observation_space = NoneSpace()
     self.cheat_players = cheat_players
示例#13
0
 def __init__(self):
     self._observation_space = NoneSpace()
     self._action_space = NoneSpace()
     self.steps = None