So just to preface, my reset() needs to return 7 integers, 3 of them are either 1 or 0, and the other 4 can be any number from 0-6.
Initially, I tried to use the spaces.Dict method of creating the spaces:
In the init()
space = {
"left_line": spaces.Box(low=np.array([0]), high=np.array([1]), dtype=np.int32),
"mid_line": spaces.Box(low=np.array([0]), high=np.array([1]), dtype=np.int32),
"right_line": spaces.Box(low=np.array([0]), high=np.array([1]), dtype=np.int32),
"left_prox": spaces.Box(low=np.array([0]), high=np.array([6]), dtype=np.int32),
"front_left_prox": spaces.Box(low=np.array([0]), high=np.array([6]), dtype=np.int32),
"front_right_prox": spaces.Box(low=np.array([0]), high=np.array([6]), dtype=np.int32),
"right_prox": spaces.Box(low=np.array([0]), high=np.array([6]), dtype=np.int32),
}
self.observation_space = spaces.Dict(space)
And in the reset()
state = {
"left_line" : left_line_data,
"mid_line" : mid_line_data,
"right_line" : right_line_data,
"left_prox" : left_prox_data,
"front_left_prox" : front_left_prox_data,
"front_right_prox" : front_right_prox_data,
"right_prox" : right_prox_data,
}
return state
This gave me the error: AssertionError: The observation returned by the reset() method is not contained with the observation space (Dict(front_left_prox: Box(0, 6, (1,), int32), front_right_prox: Box(0, 6, (1,), int32), left_line: Box(0, 1, (1,), int32), left_prox: Box(0, 6, (1,), int32), mid_line: Box(0, 1, (1,), int32), right_line: Box(0, 1, (1,), int32), right_prox: Box(0, 6, (1,), int32)))
I've then tried just using one np.array instead of dictionary, making my init()
self.low_state = np.array(
[0, 0, 0, 0, 0, 0, 0], dtype=np.int32
)
self.high_state = np.array(
[1, 1, 1, 6, 6, 6, 6], dtype=np.int32
)
self.observation_space = spaces.Box(low=self.low_state, high=self.high_state,dtype=np.int32)
With the reset()
state = np.array([left_line_data, mid_line_data, right_line_data, left_prox_data, front_left_prox_data, front_right_prox_data, right_prox_data], dtype=np.int32)
return state
But now this gives a different error:
File "/usr/local/lib/python3.8/dist-packages/gym/spaces/box.py", line 198, in contains x = np.asarray(x, dtype=self.dtype) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
I'm so friggin' lost, I've been trying different combinations of ways I've seen people make gym environments, going through the documentation, and I'm stumped! Any help would be greatly appreciated :)