Hello, please help with the problem. There is the following task:
Write a program that generates or reads a chess position and determines whether one of the kings is under the check and is not a check. The program should provide 2 options for inputting the initial data: 1. The chess position is generated using random number sensors; 2. Chess position is entered from the computer keyboard
Say, with generation and reading, I'll figure it out. But with the definition of the mat problem. Already wrote the function checking on a step. I started writing a check on the checkmate, I have already written code that will determine whether the king can get out of the step somewhere, possibly beating the enemy. But then it came to the conclusion that there are still such situations as the removal of the attacking figure of one of his own and the king's barrier from the shah, if possible. At first, I thought simply to check if the fields of the attacking opponent's battlefield and the fields between it and the king are beating (with the same check function on the check it would not be very difficult to do everything). But there is another problem, and if the Shah is from several pieces at once? In general, I am in a stupor. I do not even know what to do. Busting all the moves of black pieces is hardly good.
Help, please, can someone faced with a similar task. Or have an idea how beautiful it is to solve it.
PS If someone is interested, he solved the problem. Without busting, in his own way, as he wanted. I believe that it is so much more effective, since with my method, at worst there will be 20 checks for the check (in my opinion ...), and if there is a brute force, very, very much. I consider the effectiveness of checks on the shah, as they are, in this case, the most time consuming. (02/10/14)