// td0_alg.h :
// td0 algoritm implementation.

#include <cmath>

template  <class State,class Action>
class TD0_Alg : public Evaluation_Alg<State,Action> {

public:

  TD0_Alg (double lambdaVal=1.0) : Evaluation_Alg<State,Action> (lambdaVal) {
  }

  // this is real update performed by TD0
  void get_step (Action  stepAction,
                 State   nextState,
                 double  stepReward) {

    StepCount++;
    this->check_in_table (nextState); // initializes entry for the state if needed.

    ValuesFunc [CurrState] += (1/sqrt(StepCount))*(stepReward + 
					      Lambda*ValuesFunc[nextState] -
					      ValuesFunc[CurrState]); 

    CurrState = nextState;

  }

  void finish_run () {

    //Do nothing
  }

  virtual void set_in_table (State stepState, Action stepAction) {

    //No need for it...??.
  }

};
