Online and Offline Reinforcement Learning by Planning with a Learned Model