Implementation of Q learning (a machine learning technique)