Implementing the Q_learner class's learn method