16 #ifndef MLPACK_METHODS_RL_ENVIRONMENT_MOUNTAIN_CAR_HPP    17 #define MLPACK_METHODS_RL_ENVIRONMENT_MOUNTAIN_CAR_HPP    49     State(
const arma::colvec& data): data(data)
    53     arma::colvec& 
Data() { 
return data; }
    66     const arma::colvec& 
Encode()
 const { 
return data; }
    92     static const size_t size = 3;
   108               const double positionMin = -1.2,
   109               const double positionMax = 0.6,
   110               const double positionGoal = 0.5,
   111               const double velocityMin = -0.07,
   112               const double velocityMax = 0.07,
   113               const double doneReward = 0) :
   115       positionMin(positionMin),
   116       positionMax(positionMax),
   117       positionGoal(positionGoal),
   118       velocityMin(velocityMin),
   119       velocityMax(velocityMax),
   120       doneReward(doneReward),
   141     int direction = action.
action - 1;
   145         velocityMin, velocityMax);
   150         positionMin, positionMax);
   159     if (done && maxSteps != 0 && stepsPerformed >= maxSteps)
   178     return Sample(state, action, nextState);
   192     state.
Position() = arma::as_scalar(arma::randu(1)) * 0.2 - 0.6;
   204     if (maxSteps != 0 && stepsPerformed >= maxSteps)
   206       Log::Info << 
"Episode terminated due to the maximum number of steps"   210     else if (state.
Position() >= positionGoal)
   212       Log::Info << 
"Episode terminated due to agent succeeding.";
   249   size_t stepsPerformed;
 Implementation of action of Mountain Car. 
bool IsTerminal(const State &state) const
This function checks if the car has reached the terminal state. 
size_t MaxSteps() const
Get the maximum number of steps allowed. 
Linear algebra utility functions, generally performed on matrices or vectors. 
State InitialSample()
Initial position is randomly generated within [-0.6, -0.4]. 
The core includes that mlpack expects; standard C++ includes and Armadillo. 
const arma::colvec & Encode() const
Encode the state to a column vector. 
double & Position()
Modify the position. 
double & Velocity()
Modify the velocity. 
Miscellaneous math clamping routines. 
double Sample(const State &state, const Action &action)
Dynamics of Mountain Car. 
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ]. 
State(const arma::colvec &data)
Construct a state based on the given data. 
arma::colvec & Data()
Modify the internal representation of the state. 
MountainCar(const size_t maxSteps=200, const double positionMin=-1.2, const double positionMax=0.6, const double positionGoal=0.5, const double velocityMin=-0.07, const double velocityMax=0.07, const double doneReward=0)
Construct a Mountain Car instance using the given constant. 
Implementation of state of Mountain Car. 
State()
Construct a state instance. 
Implementation of Mountain Car task. 
size_t StepsPerformed() const
Get the number of steps performed. 
size_t & MaxSteps()
Set the maximum number of steps allowed. 
double Sample(const State &state, const Action &action, State &nextState)
Dynamics of Mountain Car. 
double Position() const
Get the position. 
static constexpr size_t dimension
Dimension of the encoded state. 
double Velocity() const
Get the velocity. 
double ClampRange(double value, const double rangeMin, const double rangeMax)
Clamp a number between a particular range.