(env, obs)
return a, b
Maps an observation to state
Maps an observation to state
Maps an observation to state
def obs_to_state(env, obs):
    """ Maps an observation to state """
    # we quantify the continous state space into discrete space
    env_low = env.observation_space.low
    env_high = env.observation_space.high
    env_dx = (env_high - env_low) / n_states
    a = int((obs[0] - env_low[0])/env_dx[0])
    b = int((obs[1] - env_low[1])/env_dx[1])
    a = a if a < n_states else n_states - 1
    b = b if b < n_states else n_states - 1
    return a, b
def obs_to_state ( env , obs ) : # we quantify the continous state space into discrete space env_low = env . observation_space . low env_high = env . observation_space . high env_dx = ( env_high - env_low ) / n_states a = int ( ( obs [ 0 ] - env_low [ 0 ] ) / env_dx [ 0 ] ) b = int ( ( obs [ 1 ] - env_low [ 1 ] ) / env_dx [ 1 ] ) a = a if a < n_states else n_states - 1 b = b if b < n_states else n_states - 1 return a , b