예제 #1
0
 def get_state_space(self):
     if self.processor is None:
         return Space.convert_openai_space(self.env.observation_space)
     else:
         self.reset()
         shape = self.current_state.shape
         min = np.zeros(shape, dtype=np.uint8)
         max = np.full(shape, 255, dtype=np.uint8)
         return Space(min, max, True)
예제 #2
0
파일: ale.py 프로젝트: oniondevs/Fruit-API
 def get_state_space(self):
     if self.__processor is None:
         shape = self.__current_buffer.shape
     else:
         shape = self.__processor.process(self.__current_buffer).shape
     min_value = np.zeros(shape, dtype=np.uint8)
     max_value = np.full(shape, 255)
     return Space(min_value, max_value, True)
예제 #3
0
파일: dml.py 프로젝트: oniondevs/Fruit-API
 def get_state_space(self):
     from fruit.types.priv import Space
     state_spec = self.env.observation_spec()
     for d in state_spec:
         if d['name'] == self.mode:
             shape = d['shape']
             return Space(np.full(shape, 0), np.full(shape, 255), True)
     return None
예제 #4
0
파일: juice.py 프로젝트: vhtu/Fruit-API
 def get_state_space(self):
     from fruit.types.priv import Space
     if self.processor is None:
         return self.game.get_state_space()
     else:
         min = np.zeros([84, 84], dtype=np.uint8)
         max = np.full([84, 84], 255)
         return Space(min, max, True)
예제 #5
0
    def get_action_space(self, act_space=None):
        from fruit.types.priv import Space
        if act_space is None:
            act_space = self.environment.actions()
        print(act_space)
        if 'num_values' in act_space:
            return Space(0, act_space['num_values'] - 1, True)
        elif 'num_actions' in act_space:
            return Space(0, act_space['num_actions'] - 1, True)
        elif 'shape' in act_space:
            if 'min_value' in act_space and 'max_value' in act_space:
                min_value = act_space['min_value']
                max_value = act_space['max_value']
                if np.asarray(
                        act_space['min_value']).shape != act_space['shape']:
                    min_value = np.full(act_space['shape'],
                                        act_space['min_value'])
                    max_value = np.full(act_space['shape'],
                                        act_space['max_value'])
            elif 'type' in act_space:
                if isinstance(act_space['type'],
                              bool) or act_space['type'] == 'bool':
                    min_value = np.full(act_space['shape'], 0)
                    max_value = np.full(act_space['shape'], 1)
                    return Space(min_value, max_value, True)
                else:
                    min_value = np.full(act_space['shape'], 0)
                    max_value = np.full(act_space['shape'], 1)
            else:
                min_value = np.full(act_space['shape'], 0)
                max_value = np.full(act_space['shape'], 1)

            return Space(min_value, max_value, False)
        elif 'gymtpl0' in act_space:
            values = []
            for i in range(len(act_space)):
                key = 'gymtpl' + str(i)
                values.append(self.get_action_space(act_space[key]))
            return tuple(values)
        else:
            raise ValueError(
                'Action space {} is not supported !'.format(act_space))
예제 #6
0
파일: cl.py 프로젝트: oniondevs/Fruit-API
 def get_action_space(self):
     from fruit.types.priv import Space
     return tuple([Space(0.0, 1.0, False),
                   Space(-1.0, 1.0, False),
                   Space(0.0, 1.0, False),
                   Space(0, 1, True),
                   Space(0, 1, True),
                   Space(0, 1, True),
                   Space(0, 2, True)])
예제 #7
0
 def get_state_space(self, st_space=None):
     from fruit.types.priv import Space
     if st_space is None:
         st_space = self.environment.states()
     print(st_space)
     if 'num_values' in st_space:
         return Space(0, st_space['num_values'] - 1, True)
     elif 'shape' in st_space:
         if self.processor is None:
             shape = st_space['shape']
         else:
             shape = self.current_state.shape
         min_value = np.zeros(shape)
         max_value = np.full(shape, 1.)
         return Space(min_value, max_value, True)
     elif 'gymtpl0' in st_space:
         values = []
         for i in range(len(st_space)):
             key = 'gymtpl' + str(i)
             values.append(self.get_state_space(st_space[key]))
         return tuple(values)
     else:
         raise ValueError('State space {} is not supported !'.format(st_space))
예제 #8
0
파일: ale.py 프로젝트: oniondevs/Fruit-API
 def get_action_space(self):
     if self.__action_reduction >= 1:
         return Space(0, self.__action_reduction - 1, True)
     else:
         return Space(0, len(self.__action_set) - 1, True)
예제 #9
0
 def get_action_space(self):
     return Space.convert_openai_space(self.env.action_space)
예제 #10
0
파일: juice.py 프로젝트: vhtu/Fruit-API
 def get_action_space(self):
     from fruit.types.priv import Space
     return Space(0, len(self.game.get_action_space()) - 1, True)
예제 #11
0
 def get_state_space(self):
     from fruit.types.priv import Space
     shape = (20, 1)
     min_value = np.zeros(shape)
     max_value = np.full(shape, 100)
     return Space(min_value, max_value, True)
예제 #12
0
파일: dml.py 프로젝트: oniondevs/Fruit-API
 def get_action_space(self):
     from fruit.types.priv import Space
     action_spec = self.env.action_spec()
     min_values = [d['min'] for d in action_spec]
     max_values = [d['max'] for d in action_spec]
     return Space(min_values, max_values, True)
예제 #13
0
 def get_state_space(self):
     from fruit.types.priv import Space
     return Space(0, 3**(self.size * self.size), True)
예제 #14
0
 def get_state_space(self):
     if self.graphical_state:
         return [self.screen_width, self.screen_height]
     else:
         from fruit.types.priv import Space
         return Space(0, self.num_of_rows * self.num_of_columns - 1, True)
예제 #15
0
 def get_action_space(self):
     from fruit.types.priv import Space
     return Space(0, 5, True)
예제 #16
0
파일: cl.py 프로젝트: oniondevs/Fruit-API
 def get_state_space(self):
     from fruit.types.priv import Space
     shape = (self.width, self.height, 3)
     min_value = np.zeros(shape)
     max_value = np.full(shape, 255)
     return Space(min_value, max_value, True)
예제 #17
0
파일: engine.py 프로젝트: vhtu/Fruit-API
 def get_state_space(self):
     if self.graphical_state:
         return [self.screen_size, self.screen_size]
     else:
         from fruit.types.priv import Space
         return Space(0, self.max_states_per_dim * self.max_states_per_dim - 1, True)