Chess endgame puzzle: Sacrifice the queen to corner the opponent’s king

I’m working on a computer chess program. Right now I’m in the research phase. I don’t know if I’m going to use machine learning for this. But if I do, I will need chess puzzles.

The easiest chess puzzles, in my opinion, are endgame puzzles. Especially those in which both sides have lost a lot of pieces. Like this one. White to play:

This is a typical corner-the-king puzzle. Such puzzles generally involve a queen sacrifice. But not right away. First, bring your queen to f7 to back the opponent king into the corner.

Next, queen to f8 even though your opponent will certainly capture your queen if they don’t resign.

If you balk at giving up your queen, you might still win, but it’ll take you a few moves. Assuming your opponent doesn’t take their rook to your home row.

The best solution to this puzzle requires a queen sacrifice. But I could be wrong. If you can find a good solution without a queen sacrifice, please post it in the comments.

You can try your hand at it against the computer on Lichess.

is a composer and photographer from Detroit, Michigan. He has been working on a Java program to display certain mathematical diagrams.