trenton

Testing my first chess AI: Four Pawn Game Solved

7 posts in this topic

I have recently taken an interest in programming chess computers. My dream is to one day combine a C++ model with a LLM to create an advanced chess computer that both finds the best move and can articulate complex strategic reasoning in terms a human can understand. One day this might become a universal chess coach that anybody can access. It would be cool if the method of reasoning were adapted to the player's reasoning style. This would have to combine a chat function similar to Claude or some other bot with a chess engine capable of deep and precise calculation combined with reinforcement learning. I tried to build a prototype of this using Claude programming, but something went wrong and I need to rethink the project. The usage limits are problematic and they slow my progress considerably. I might require a large database of annotated grandmaster games to teach the machine patterns in human reasoning. I am also looking for a team that might be able to help me with this kind of project. For now I scaled back the project to focus on solving something simple first.

This project I am submitting is based on a simple chess variant called the pawn game. This variant uses four pawns for each side. The pawns move the same way as in normal chess including en passant. The objective of this game is to get one of your pawns to the other side of the board. With perfect play, I believe white wins by force. Therefore, if you play against the computer as black, you should lose no matter what you do. I published a study on this chess variant on lichess.org. I originally solved it through human analysis and concluded that white should always win with either 1. e4 or 1. d4. the AI appears to agree with my analysis. My next attempt will be to expand this to the eight pawn game. Although I solved the simple version through my own analysis, the larger version is much more complex and I struggled. Apparently, white can win, but it is not with the intuitive central grab that I assumed. It might be with a flank pawn instead as it maintains flexibility with the central pawns.

Here is version 3 of this project. It might be a little slow to load up at first, but it is working for me.

https://claude.ai/public/artifacts/072e5c52-b844-41b1-b7ac-2d17e01aca50

Are you able to open the link? If so, feel free to test yourself against this computer as either color. If you find a line that allows you draw or win with black, then it indicates that this AI is probably broken or has a bug. I refuted versions 1 and 2 by winning with black. The line I used was as follows, but should no longer be possible in version 3.

1. d4 f5 2. e3 e6 3. f3 d6 4. f4 d5 5. c3 c6 6. c4 dxc4 7. e4 c3 8. d5 c2 9. dxc6 c1

Here is a link to my lichess study if you are interested.

https://lichess.org/study/ORdmNFQD/RcBMDy26

If you are able to access everything just fine, then what do you think of this sort of project so far? Personally, I find myself really sucked into this.

Share this post


Link to post
Share on other sites

I made an updated version. I found some bugs with the previous version involving draw and win conditions. This version 5 now allows the player to flip the board. It also has a description of the rules that can be accessed. The AI is set to play the most efficient win.

https://claude.ai/public/artifacts/53204627-e589-4a97-95a5-61a405d2b7c2

If anybody wants to test this out, I hope you have as much fun as I had solving this game and using AI to verify my analysis.

Share this post


Link to post
Share on other sites

I tested it out. Pretty cool man! Good for practice. 


"It is of no avail to fret and fume and chafe at the chains which bind you; you must know why and how you are bound. " - James Allen 

Share this post


Link to post
Share on other sites

@Joshe I'm glad you like it.

I submitted version 5 to chess in schools. These chess programs often use simplified chess variants for teachings young beginners. These variants are simple enough for a strong human to solve. This analysis can be verified with a chess computer that can calculate the limited number of positions.

This is good because children often love chess computers anyway. This would make learning even more engaging and it would help the children to learn optimal strategy and play quickly.

I haven't tried the full pawn game yet. It would be much more complex and the computer would need more time to calculate everything. I might require a more efficient computer for that variant.

Share this post


Link to post
Share on other sites
18 minutes ago, trenton said:

This is good because children often love chess computers anyway. This would make learning even more engaging and it would help the children to learn optimal strategy and play quickly.

I agree. Isolating things like this would develop competency much faster. I'm 1500 ELO rapid and I've never dove into how to properly work the pawns, and I've lost many games because of it, so something as simple as this is really good. 


"It is of no avail to fret and fume and chafe at the chains which bind you; you must know why and how you are bound. " - James Allen 

Share this post


Link to post
Share on other sites

@Joshe One of the key winning strategies in this variant is to exploit en passant. The reason white wins is because by advancing the pawns to the fifth rank first, it limits black's options greatly. en passant can then be used at any moment while running the opponent out of moves. This is also the reason why if en passant were not allowed, then this variant would be a draw as white's strategic set ups would no longer be effective.

Sometimes this is a theme in a real chess game such as variations of the Sicilian or king's Indian defense. In the Sicilian white can sometimes push a4-a5. Once black has already played a6 preparing b5, this en passant set up can limit black's options for expansion. Similarly in the King's indian defense, white sometimes wants to play a3-b4 to expand on the queenside for a strong attack. In some positions black can slow this by using the maneuver Nb8-d7-c5 in conjunction with a5-a4. This kind of set up would limit white's option as using the en passant set up prevents white's expansion on the queenside with b4.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now