bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::envs::grid_world::Gridworld< side_size_ > Class Template Referencefinal

#include <grid_world_env.h>

Inheritance diagram for bitrl::envs::grid_world::Gridworld< side_size_ >:
Collaboration diagram for bitrl::envs::grid_world::Gridworld< side_size_ >:

Public Types

typedef EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > > base_type
 The base_type.
 
typedef base_type::time_step_type time_step_type
 The time step type we return every time a step in the environment is performed.
 
typedef base_type::state_space_type state_space_type
 The type describing the state space for the environment.
 
typedef base_type::action_space_type action_space_type
 The type of the action space for the environment.
 
typedef base_type::action_type action_type
 The type of the action to be undertaken in the environment.
 
typedef base_type::state_type state_type
 The type of the action to be undertaken in the environment.
 
- Public Types inherited from bitrl::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >
typedef TimeStep< detail::board_state_type > time_step_type
 Alias for the type returned when stepping the environment.
 
typedef SpaceType::state_space state_space_type
 Type describing the environment state space.
 
typedef SpaceType::state_type state_type
 Type describing an individual state.
 
typedef SpaceType::action_space action_space_type
 Type describing the environment action space.
 
typedef SpaceType::action_type action_type
 Type representing an individual action.
 

Public Member Functions

 Gridworld ()
 Constructor.
 
void make (const std::string &version, const std::unordered_map< std::string, std::any > &options, const std::unordered_map< std::string, std::any > &reset_options) override final
 make. Builds the environment. Optionally we can choose if the environment will be slippery
 
time_step_type reset () override final
 Reset the environment.
 
time_step_type step (const action_type &action) override final
 step
 
void close () override final
 close
 
bool has_random_state () const noexcept
 has_random_state
 
uint_t n_states () const noexcept
 n_states. Returns the number of states
 
uint_t n_actions () const noexcept
 n_actions. Returns the number of actions
 
uint_t seed () const noexcept
 seed
 
real_t noise_factor () const noexcept
 noise_factor
 
bool is_game_lost () const
 Returns true if the PLAYER position is the same as the PIT position.
 
GridWorldInitType init_type () const noexcept
 init_type
 
- Public Member Functions inherited from bitrl::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >
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().
 
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().
 

Static Public Member Functions

static uint_t n_copies ()
 

Static Public Attributes

static const std::string name = "Gridworld"
 name
 
static const uint_t n_components = 4
 n_components
 
static const uint_t side_size = side_size_
 side_size
 
- Static Public Attributes inherited from bitrl::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >
static const uint_t DEFAULT_ENV_SEED
 Default seed used in reset() if none provided.
 

Additional Inherited Members

- Protected Member Functions inherited from bitrl::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >
 EnvBase (const std::string &idx=bitrl::consts::INVALID_STR, const std::string &name=bitrl::consts::INVALID_STR)
 Constructor (protected — for subclassing only).
 
 EnvBase (const EnvBase &)
 Copy constructor.
 
void set_version_ (const std::string &version) noexcept
 Set internal version string.
 
void set_idx_ (const std::string &idx) noexcept
 Set the id of the environment.
 
void set_make_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store options for future access.
 
void set_reset_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store reset options for future access.
 
void invalidate_is_created_flag_ () noexcept
 Mark environment as not created.
 
void make_created_ () noexcept
 Mark environment creation as successful.
 
time_step_typeget_current_time_step_ () noexcept
 Mutable access to the current time step.
 
const time_step_typeget_current_time_step_ () const noexcept
 Read-only access to the current time step.
 

Detailed Description

template<uint_t side_size_>
class bitrl::envs::grid_world::Gridworld< side_size_ >

The Gridworld class models a square board. There are three ways to initialize the board.

  • static
  • random
  • player See the GridworldInitType enumeration. Static initialization means that the objects on the board are initialized at the same predetermined locations. Player initialization means that the player is initialized at a random position on the board. Random initialization means that all the objects are placed randomly

Member Typedef Documentation

◆ action_space_type

template<uint_t side_size_>
typedef base_type::action_space_type bitrl::envs::grid_world::Gridworld< side_size_ >::action_space_type

The type of the action space for the environment.

◆ action_type

template<uint_t side_size_>
typedef base_type::action_type bitrl::envs::grid_world::Gridworld< side_size_ >::action_type

The type of the action to be undertaken in the environment.

◆ base_type

template<uint_t side_size_>
typedef EnvBase<TimeStep<detail::board_state_type>, detail::GridWorldEnv<side_size_> > bitrl::envs::grid_world::Gridworld< side_size_ >::base_type

The base_type.

◆ state_space_type

template<uint_t side_size_>
typedef base_type::state_space_type bitrl::envs::grid_world::Gridworld< side_size_ >::state_space_type

The type describing the state space for the environment.

◆ state_type

template<uint_t side_size_>
typedef base_type::state_type bitrl::envs::grid_world::Gridworld< side_size_ >::state_type

The type of the action to be undertaken in the environment.

◆ time_step_type

template<uint_t side_size_>
typedef base_type::time_step_type bitrl::envs::grid_world::Gridworld< side_size_ >::time_step_type

The time step type we return every time a step in the environment is performed.

Constructor & Destructor Documentation

◆ Gridworld()

template<uint_t side_size_>
bitrl::envs::grid_world::Gridworld< side_size_ >::Gridworld ( )

Constructor.

Member Function Documentation

◆ close()

template<uint_t side_size_>
void bitrl::envs::grid_world::Gridworld< side_size_ >::close ( )
finaloverridevirtual

◆ has_random_state()

template<uint_t side_size_>
bool bitrl::envs::grid_world::Gridworld< side_size_ >::has_random_state ( ) const
inlinenoexcept

has_random_state

Returns

◆ init_type()

template<uint_t side_size_>
GridWorldInitType bitrl::envs::grid_world::Gridworld< side_size_ >::init_type ( ) const
inlinenoexcept

init_type

Returns

◆ is_game_lost()

template<uint_t side_size_>
bool bitrl::envs::grid_world::Gridworld< side_size_ >::is_game_lost ( ) const

Returns true if the PLAYER position is the same as the PIT position.

◆ make()

template<uint_t side_size_>
void bitrl::envs::grid_world::Gridworld< side_size_ >::make ( const std::string &  version,
const std::unordered_map< std::string, std::any > &  options,
const std::unordered_map< std::string, std::any > &  reset_options 
)
finaloverridevirtual

make. Builds the environment. Optionally we can choose if the environment will be slippery

Implements bitrl::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >.

◆ n_actions()

template<uint_t side_size_>
uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::n_actions ( ) const
inlinenoexcept

n_actions. Returns the number of actions

◆ n_copies()

template<uint_t side_size_>
static uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::n_copies ( )
inlinestatic

Get the number of copies of this class

Returns

◆ n_states()

template<uint_t side_size_>
uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::n_states ( ) const
inlinenoexcept

n_states. Returns the number of states

◆ noise_factor()

template<uint_t side_size_>
real_t bitrl::envs::grid_world::Gridworld< side_size_ >::noise_factor ( ) const
inlinenoexcept

noise_factor

Returns

◆ reset()

template<uint_t side_size_>
Gridworld< side_size_ >::time_step_type bitrl::envs::grid_world::Gridworld< side_size_ >::reset ( )
finaloverridevirtual

◆ seed()

template<uint_t side_size_>
uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::seed ( ) const
inlinenoexcept

seed

Returns

◆ step()

template<uint_t side_size_>
Gridworld< side_size_ >::time_step_type bitrl::envs::grid_world::Gridworld< side_size_ >::step ( const action_type action)
finaloverride

step

Parameters
action
Returns

Member Data Documentation

◆ n_components

template<uint_t side_size_>
const uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::n_components = 4
static

n_components

◆ name

template<uint_t side_size>
const std::string bitrl::envs::grid_world::Gridworld< side_size >::name = "Gridworld"
static

name

◆ side_size

template<uint_t side_size_>
const uint_t bitrl::envs::grid_world::Gridworld< side_size_ >::side_size = side_size_
static

side_size


The documentation for this class was generated from the following file: