I had a problem similar to yours before. My computer was restarting itself especially while playing heavy games. There wasn't any problem while playing League of Legends. Sometimes it may restart randomly on idle. When I take look on Event Viewer, I saw the problem named "Kernel Power 41 (63)"
I tried to fix it for 6 months. I changed my PSU but the problem caused by rams. Even after it passed memtest for long hours. I sent my rams for rma and got new ones. Not a single problem happening now. I hope this helps.
Oh by the way, it was not just restarting problem. As you said, it was giving bsods, freezing, all kind of boring stuff.