Markov Decision Process code