When it comes to the function of the mind, it is an interesting scientific standpoint that scientists continue to do research in. They continue to look towards the functions of all the brainwaves and how all the thoughts interact during the day and night.
During every hour of the day, the mind is able to adapt itself to any new situation. Whether the mind is trying to get food, get a drink, get out of the car, walking through a door, or just get some rest, the mind constantly will try to find new ways to survive and flourish. It will continue through the cycle of getting enough resources during the day to then have enough energy to heal and rest during the night.