Programming Challenges: Check the Check
PC/UVa IDs: 110107/10196, Popularity: B, Success rate: average, Level: 1
I had two approaches in mind for checking the check before solving this problem:
returna flag value from the move-generation functions as soon as opponent’s king is encountered in a reachable square.- Generate all reachable squares for a side first, and then check whether opponent’s king is positioned on one.
I opted for the latter because even though it was more performance-intensive, it made my move-generation functions more generic and appropriate for extensibility.
(more…)
