소스 검색

use the correct initialization for custom gym space

saleml 2 년 전
부모
커밋
e782182d9b
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      gym_minigrid/minigrid.py

+ 1 - 2
gym_minigrid/minigrid.py

@@ -620,11 +620,10 @@ class StringGymSpace(gym.spaces.space.Space):
     A gym space that represents a string of characters of bounded length
     A gym space that represents a string of characters of bounded length
     """
     """
     def __init__(self, min_length=0, max_length=1000):
     def __init__(self, min_length=0, max_length=1000):
+        super().__init__(shape=(), dtype='U')
         self.min_length = min_length
         self.min_length = min_length
         self.max_length = max_length
         self.max_length = max_length
         self.letters = string.ascii_letters + string.digits + ' .,!- '
         self.letters = string.ascii_letters + string.digits + ' .,!- '
-        self._shape = ()
-        self.dtype = np.dtype('U')
 
 
     def sample(self):
     def sample(self):
         length = np.random.randint(self.min_length, self.max_length)
         length = np.random.randint(self.min_length, self.max_length)