Ah, the most powerful piece in the game. The queen. She can move in eight directions over great distances, she can outmaneuver any single piece on the board, she is used in more attacks and mates (statistically) than any other piece. Very valuable. So valuable, that she is worth 3 bishops, or 3 knights, or almost 2 rooks. In chess, that’s valuable.

However, my favorite queen story is that of sacrifice. A top notch player, Paul Morphy, once faced two opponents who collaborated against him in the Italian Opera House in Paris, Salle Le Peletier. His opponents were the Duke of Brunswick and Count Isouard. The story itself is quite fascinating, which you can read up on Wikipedia, or elsewhere, but the interesting thing to me, is how Mr. Morphy sacrificed his queen, despite already having a “material disadvantage”, in order to gain check mate!

Since that was before world chess championships, Mr. Morphy was never officially a reigning champion. However, he beat every opponent so soundly, that before he was 30, he gave up playing chess because no one was a challenge. If only I was that smart!

When it comes to programming our queen into our chess engine, though, we can be really smart! In fact, we can quickly create our queen in minutes, because all we are doing is making a piece that is both a rook and a bishop and combining them in the same method.

As you peruse the queen commit, I’d like to point out something. While we don’t have a full king is safe check yet, notice that we are trying to speed up the making of a list of available moves by first generating the list of possible moves, THEN checking to see if they are “king is safe” moves. If it is not a valid move, then there is no reason to check if it is a safe move in relation to our king.

One of the big goals of this engine is to be an open source alternative for Android app creators, and as such, it will need to run on cell phones, which typically have less processing power than a desktop computer. One of the reasons I started the Just Chess Engine, as opposed to the Beginners Chess Engine, is to get rid of all the try/catch blocks. In the Beginners Chess Engine, we often rely on a try/catch block to fail, so we can stop some part of the process. This leads to wasted processing and time. Here, we are trying to write simple, clean code that doesn’t need a (or at least reduces) try/catch block because it should not return an error.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *