ported over the valueiteration class for testing