|
bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
|
Implementation of Connect2 environment from https://github.com/JoshVarty/AlphaZeroSimple Initially the environment has all its positions set to zero. When a player makes a move then the position corresponding to this move. More...
#include <connect2_env.h>


Public Types | |
| typedef EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > > | base_type |
| The base type. | |
| typedef base_type::time_step_type | time_step_type |
| The type of the time step. | |
| 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 state type. | |
Public Types inherited from bitrl::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > > | |
| typedef TimeStep< std::vector< uint_t > > | 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 Types inherited from bitrl::envs::DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > | |
| typedef DiscreteVectorSpace< StateSpaceSize, uint_t > | state_space |
| the state space type | |
| typedef state_space::space_item_type | state_type |
| the State type | |
| typedef ScalarDiscreteSpace< AS, AE > | action_space |
| the action space type | |
| typedef action_space::space_item_type | action_type |
| the Action type | |
Public Member Functions | |
| Connect2 () | |
| Constructor. | |
| virtual 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 | |
| virtual time_step_type | step (const action_type &action) override final |
| step. Move in the environment with the given action This function always moves player_1 | |
| virtual void | close () override final |
| close | |
| virtual time_step_type | reset () override final |
| Reset the environment. | |
| 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 | |
| time_step_type | move (const uint_t pid, const action_type &action) |
| Make a move for the player with the given id. | |
| bool | is_win (uint_t player) const noexcept |
| Returns true if the player wins. | |
| bool | has_legal_moves () const noexcept |
| Returns true if there are still legal moves to do. | |
| std::vector< uint_t > | get_valid_moves () const |
| Get the valid moves. | |
Public Member Functions inherited from bitrl::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > > | |
| 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(). | |
Static Public Member Functions | |
| static uint_t | n_copies () |
Static Public Attributes | |
| static const std::string | name = "Connect2" |
| name | |
Static Public Attributes inherited from bitrl::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > > | |
| static const uint_t | DEFAULT_ENV_SEED |
| Default seed used in reset() if none provided. | |
Static Public Attributes inherited from bitrl::envs::DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > | |
| static constexpr uint_t | STATE_SPACE_SIZE |
| state space size | |
| static constexpr uint_t | ACTION_SPACE_SIZE |
| state space size | |
Additional Inherited Members | |
Protected Member Functions inherited from bitrl::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > > | |
| 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_type & | get_current_time_step_ () noexcept |
| Mutable access to the current time step. | |
| const time_step_type & | get_current_time_step_ () const noexcept |
| Read-only access to the current time step. | |
Implementation of Connect2 environment from https://github.com/JoshVarty/AlphaZeroSimple Initially the environment has all its positions set to zero. When a player makes a move then the position corresponding to this move.
The type of the action space for the environment.
| typedef base_type::action_type bitrl::envs::connect2::Connect2::action_type |
The type of the action to be undertaken in the environment.
| typedef EnvBase<TimeStep<std::vector<uint_t> >, DiscreteVectorStateDiscreteActionEnv<53, 0, 4, uint_t> > bitrl::envs::connect2::Connect2::base_type |
The base type.
The type describing the state space for the environment.
The state type.
The type of the time step.
| bitrl::envs::connect2::Connect2::Connect2 | ( | ) |
Constructor.
|
inlinefinaloverridevirtual |
| std::vector< uint_t > bitrl::envs::connect2::Connect2::get_valid_moves | ( | ) | const |
Get the valid moves.
|
noexcept |
Returns true if there are still legal moves to do.
|
noexcept |
Returns true if the player wins.
|
finaloverridevirtual |
make. Builds the environment. Optionally we can choose if the environment will be slippery
| Connect2::time_step_type bitrl::envs::connect2::Connect2::move | ( | const uint_t | pid, |
| const action_type & | action | ||
| ) |
Make a move for the player with the given id.
|
inlinenoexcept |
n_actions. Returns the number of actions
|
inlinestatic |
Get the number of copies of this class
|
inlinenoexcept |
n_states. Returns the number of states
|
finaloverridevirtual |
Reset the environment.
|
finaloverridevirtual |
step. Move in the environment with the given action This function always moves player_1
| action |
|
static |
name