|
| typedef EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t > > | base_type |
| typedef base_type::time_step_type | time_step_type |
| typedef base_type::state_type | state_type |
| typedef base_type::action_type | action_type |
| typedef TimeStep< std::vector< real_t > > | time_step_type |
| | Alias for the type returned when stepping the environment.
|
| typedef ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t >::state_space | state_space_type |
| | Type describing the environment state space.
|
| typedef ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t >::state_type | state_type |
| | Type describing an individual state.
|
| typedef ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t >::action_space | action_space_type |
| | Type describing the environment action space.
|
| typedef ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t >::action_type | action_type |
| | Type representing an individual action.
|
| typedef ContinuousVectorSpace< StateSpaceSize, StateSpaceItemType > | state_space |
| typedef state_space::space_item_type | state_type |
| | the State type
|
| typedef ScalarDiscreteSpace< action_start, action_end > | action_space |
| | item_t
|
| typedef action_space::space_item_type | action_type |
| | the Action type
|
|
| | CartPole () |
| void | make (const std::string &version, const std::unordered_map< std::string, std::any > &make_options, const std::unordered_map< std::string, std::any > &reset_options) override |
| | Construct the environment instance.
|
| void | close () override |
| | Close and release any acquired environment resources.
|
| time_step_type | reset () override |
| | Start an episode with the next seed.
|
| time_step_type | reset (uint_t seed) |
| | Start an episode with the given seed.
|
| time_step_type | step (const action_type &action) override |
| | Push the cart: 0 to the left, 1 to the right.
|
| uint_t | n_steps () const noexcept |
| uint_t | max_steps () const noexcept |
| const bitsim::dynamics::CartPoleDynamics & | dynamics () const noexcept |
| virtual | ~EnvBase ()=default |
| | Virtual destructor.
|
| virtual time_step_type | step (const action_type &action)=0 |
| | Perform one step in the environment using an action.
|
| const std::unordered_map< std::string, std::any > & | make_options () const noexcept |
| | Access the configuration options provided to make().
|
| const std::unordered_map< std::string, std::any > & | reset_options () const noexcept |
| | Access the configuration options provided to make().
|
| T | read_option (const std::string &op_name) const |
| | Read a specific make() option and cast it to the requested type.
|
| std::string | idx () const noexcept |
| | Get the id identifying this environment within a simulation batch. The id is valid only if make has been called.
|
| bool | is_created () const noexcept |
| | Check if make() has successfully initialized the environment.
|
| std::string | env_name () const noexcept |
| | Get the name of this environment instance.
|
| std::string | version () const noexcept |
| | Get the environment version set during make().
|
| uint_t | last_reset_seed () const noexcept |
| | The seed of the latest reset(), for the environments that take one. The first reset after make() uses the "seed" reset option, or DEFAULT_ENV_SEED, and every reset after it the next seed, so that the episodes start differently and a run is the same every time.
|
The cart-pole of Barto, Sutton and Anderson, simulated in this process with bitsim::dynamics::CartPoleDynamics.
It is the task of Gymnasium's CartPole, without a server: push the cart left (action 0) or right (action 1) with max_force, every dt seconds, and keep the pole within 12 degrees of upright and the cart within 2.4 m of the centre. The observation is [x, x_dot, theta, theta_dot]; every step is worth 1, the step that fails included. An episode starts with every value uniform in [-0.05, 0.05], drawn with the seed of the reset, and ends when the pole falls, the cart leaves the track, or after max_steps steps; then the time step's extra "truncated" is true.
Unlike Gymnasium, which takes one Euler step, the dynamics integrate with fourth order Runge-Kutta, so the numbers are close to Gymnasium's but not the same.
Make options, all optional: "max_steps" (uint_t, 500), "dt" (real_t, 0.02), "max_force" (real_t, 10.0). Reset option: "seed" (uint_t), the seed of the first reset; every reset after it takes the next seed.