implemented qlearning algorithm