Final version of Qlearning.