Play chess, and do physical exercise.
Both will develop your mental stamina, and chess especially will hone your adversarial thinking.
You may even find that your chess fitness is directly comparable to your programming fitness and vice-versa. When you're programming fit through working on some incredibly hard problems in the week (think distributed systems or file systems or algorithms), then your chess will show an improvement. And when you're playing several hours of chess a day against a good opponent, then your programming will likewise benefit and your bug count drop as you naturally start thinking further ahead.