bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::envs::connect2::Connect2 Class Referencefinal

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>

Inheritance diagram for bitrl::envs::connect2::Connect2:
Collaboration diagram for bitrl::envs::connect2::Connect2:

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_tstate_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_tget_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().
 
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_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

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.

Member Typedef Documentation

◆ action_space_type

The type of the action space for the environment.

◆ action_type

typedef base_type::action_type bitrl::envs::connect2::Connect2::action_type

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

◆ base_type

◆ state_space_type

The type describing the state space for the environment.

◆ state_type

◆ time_step_type

Constructor & Destructor Documentation

◆ Connect2()

bitrl::envs::connect2::Connect2::Connect2 ( )

Constructor.

Member Function Documentation

◆ close()

void bitrl::envs::connect2::Connect2::close ( )
inlinefinaloverridevirtual

◆ get_valid_moves()

std::vector< uint_t > bitrl::envs::connect2::Connect2::get_valid_moves ( ) const

Get the valid moves.

◆ has_legal_moves()

bool bitrl::envs::connect2::Connect2::has_legal_moves ( ) const
noexcept

Returns true if there are still legal moves to do.

◆ is_win()

bool bitrl::envs::connect2::Connect2::is_win ( uint_t  player) const
noexcept

Returns true if the player wins.

◆ make()

void bitrl::envs::connect2::Connect2::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< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > >.

◆ move()

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.

◆ n_actions()

uint_t bitrl::envs::connect2::Connect2::n_actions ( ) const
inlinenoexcept

n_actions. Returns the number of actions

◆ n_copies()

static uint_t bitrl::envs::connect2::Connect2::n_copies ( )
inlinestatic

Get the number of copies of this class

Returns

◆ n_states()

uint_t bitrl::envs::connect2::Connect2::n_states ( ) const
inlinenoexcept

n_states. Returns the number of states

◆ reset()

Connect2::time_step_type bitrl::envs::connect2::Connect2::reset ( )
finaloverridevirtual

◆ step()

Connect2::time_step_type bitrl::envs::connect2::Connect2::step ( const action_type action)
finaloverridevirtual

step. Move in the environment with the given action This function always moves player_1

Parameters
action
Returns

Member Data Documentation

◆ name

const std::string bitrl::envs::connect2::Connect2::name = "Connect2"
static

name


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