simple model of a day implemented by using finite state machine
The states of the machine is changing every 30 minutes for given number of days.
You can find ploted diagram of the implemented finite state machine in fsm_diagram.png. There you will be able to observe all possible changes in states and what inputs trigger them.
You can pass different arguments for numbers of days and rarity for random occasions from outter scope. Try to survive for the greatest number of days. Adjust rarity as you believe is better.