Open wadmes opened 2 months ago
from gymnasium.spaces import Dict, Box, Discrete from gymnasium import spaces observation_space = Dict({"position": Box(-1, 1, shape=(2,)), "color": Discrete(5)}, seed=42) flatten = spaces.flatten_space(observation_space) obs1 = flatten.sample() unflat = spaces.utils.unflatten(observation_space,obs1) print(obs1) print(unflat)
obs1:
array([ 0.47568119, 0.64470851, 0.93992918, 0.0658021 , 0.74573835, 0.68031875, -0.96546865])
unflat:
OrderedDict({'color': 0, 'position': array([ 0.6803188 , -0.96546865], dtype=float32)})
The result of unflat will always gives color = 0, even though it is not inobs1`
unflat
color
, even though it is not in
obs1:
unflat:
The result of
unflat
will always givescolor
= 0, even though it is not in
obs1`