// qlrn_alg.h : // Q_learning algoritm implementation. #include template class QLrn_Alg : public StepLrn_Alg { public: QLrn_Alg (double lambdaVal=1.0) : StepLrn_Alg (lambdaVal) { } void get_step (Action stepAction, State nextState, double stepReward) { StepCount++; Action best_act = find_best(nextState); StepsData [Step(CurrState,stepAction)] += (1.0/sqrt(StepCount))*(stepReward + Lambda*StepsData[Step(nextState,best_act)] - StepsData[Step(CurrState,stepAction)]); CurrState = nextState; } void finish_run () { //Do nothing } };