The method for designing loops is to ask two questions:
- Will it always end?
- Whenever it terminates, will the data meet the conditions required?
Well, the loop terminates (and the game ends) when:
- The mouse runs to the hole.
- The mouse runs into the cat.
- The cat catches the mouse.