I was in junior high school and obsessed with Dance Dance revolution. If I went to bed directly after playing DDR, I'd shut my eyes and see arrows scrolling across the back of my eyelids. It was kinda cool, but annoying at the same time since I was trying to sleep.
Fast forward to college and I find myself in my dorm at 2:00 AM working on a take-home final.
The final's objective:
Take a buggy implementation of a Red Black Tree given by the professor and fix it.
It was late so I figured I'd call it a day and resume my work in the morning.
I could NOT fall asleep. I'd close my eyes but my brain wouldn't shut up. My mind kept going back to my code, recalling rules associated with Red Black Trees, mindlessly making up scenarios that had no solutions.
I ended up getting out of bed and working on it further. I even took Benadryl in hopes to get drowsy enough to sleep. I didn't make any progress despite spending a lot more time on it that evening.
So what was I suppose to do? After a few years of experience, I've noticed myself occasionally reliving this episode. I've discovered high correlation with not being able to sleep and coding into the late hours of the night. Solution: no coding within a few hours of going to bed.
I've become a true believer of winding down before bed. No coding. I try to avoid looking at screens in general and utilize blue light filters if possible. If I do end up playing my Nintendo Switch I'll play the zenful Stardew Valley instead of Splatoon 2 which tends to get me all riled up.
I still have restless nights occasionally, and a hard-to-find bug is quite capable of absorbing my mind's thoughts when I'm going to bed, but the more I try to unwind before going to sleep the better I'm able to.
This is my first post :)