Python code for Markov decision processes