Perfect foresight simulation problem

My hunch is that you have the issue at