top of page

Chess Engine

Humble Beginnings
starting_out_1.png
starting_out_2.png
starting_out_3.png

After much hair pulling and frustration, I created a simple chess board based on the interface from chess.com.

Screenshot (577).png

I quickly realized the monumental challenge it would be to have my chess engine identify all the legal moves in a position so I added some highlighting to show the user all the squares a piece can move to. Here the black queen on g5 has all its possible moves highlighted in red.

hanging_king_3.png
hanging_king_2.png
hanging_king_1.png

After I had nearly perfected my move generation code, I still found tricky situations that allowed my chess bot to expose its king to capture. 

In the above example, black captures the pawn on c4 via en passant, resulting in the black king on h4 being exposed to the white rook on b4. 

Accounting for all the special conditions en passant creates took me longer to program than all the rest of the move generation code. 

great_move_1.png
great_move_2.png
great_move_3.png

To test my program and bug fix, I played dozens of games against my chess engine. Initially the engine was rudimentary and made multiple bad moves. The above example is one such instance when I believed the engine had made a poor move. 

In the left most image, it is white's move and I planned to play rook from d3 to c3, pinning the black queen to the black king. This would result in white trading a rook for a queen which would lead to white winning the game. 

I played rook d3 to c3 and planned to start analyzing why my engine lost its queen. Within moments my chess engine played bishop from f8 to b4 (right most image) pinning my rook to MY king. I ended up losing the game and decided it was time to test my chess engine against competitive chess.com players.

Screenshot (577).png
Screenshot (578).png

My chess engine was able to surpass the chess.com 1000 Elo goal in a matter of days with a 92% win rate. 

With the goal of 1000 Elo surpassed, I concluded this project for the time being. 

I hope to revisit this project in the future with the goal of achieving 2000 Elo, (better than 99.9% of chess players).

ezgif.com-gif-maker.gif

Here is a game of my chess engine playing itself. If you are an experienced player I'm sure you can spot inaccuracies but there are still some interesting moves.

 

For example, on move 15 the engine chooses to sacrifice its knight on a3 for 3 pawns which came as a total shock to me.

I set out to create a chess program capable of beating 50% of competitive chess players on chess.com. Achieving a chess.com rank of >1000 is approximately equivalent to being better than 50% of players.
bottom of page