// qlrn_alg.h :
// Q_learning algoritm implementation.
#include <cmath>

template  <class State,class Action>
class QLrn_Alg : public StepLrn_Alg<State,Action> {

public:

  QLrn_Alg (double lambdaVal=1.0) : StepLrn_Alg<State,Action> (lambdaVal) {
  }

  void get_step (Action  stepAction,
                 State   nextState,
                 double  stepReward) {

    StepCount++;

    Action best_act = find_best(nextState);

    StepsData [Step<State,Action>(CurrState,stepAction)] +=
      (1.0/sqrt(StepCount))*(stepReward + 
			Lambda*StepsData[Step<State,Action>(nextState,best_act)] -
			StepsData[Step<State,Action>(CurrState,stepAction)]);

    CurrState  = nextState;
  }

  void finish_run () {

    //Do nothing
  }

};
