Python implementation of Value Iteration