If you think I have been a little absent the last two weeks it is because I have been working on learning how to code together with GPT-4. I have always been fascinated with people who could create programs and understand the code, but I always saw it as too big of an investment of time to learn the skill. Maybe that is how some people have it with chess. Anyways, GPT-4 is like having a very patient super coder at your side while you ask stupid questions.
So, what did I create, or let's say, what am I trying to create?
My idea is to create a mailing service that will send you an opening survey of your most recently played game up until the first new move. I think this is useful because you often don’t take the time to look at your games after each game. Also when you study the opening in Chessable you might be training openings in 10-20 moves depth, while you had a completely new position for you at move 7. My idea is to make the user aware of when this moment occurs.
Since I’m just just a code beginner I will start with a proof of concept.
I have succeeded in running the script, retrieving the data via the Lichess API, analyzing the game data, printing the data, and sending an email to the user! I actually feel like it’s quite amazing that this is possible to do based on my starting point as a beginner.
The output delivered to my mail looks like this (the board embed is a Substack feature, but I will try to figure out how to get diagrams printed):
Game Information:
White: SayChessClassical
Black: Sujith_KJ
ECO: A49
Date: 2023.04.12
Time Control: 180+0
Analyzing position after move 1. d4
Total games in this position: 1790 Games, Win rate: 50%
d5: Played 655 times (36%), Win rate: 52%
Nf6: Played 607 times (33%), Win rate: 48%
e6: Played 132 times (7%), Win rate: 46%
c5: Played 75 times (4%), Win rate: 50%
d6: Played 64 times (3%), Win rate: 62%
c6: Played 63 times (3%), Win rate: 42%
g6: Played 57 times (3%), Win rate: 54%
e5: Played 46 times (2%), Win rate: 58%
f5: Played 45 times (2%), Win rate: 46%
b6: Played 21 times (1%), Win rate: 66%
----
Analyzing position after move 1... Nf6
Total games in this position: 607 Games, Win rate: 48%
Nf3: Played 302 times (49%), Win rate: 49%
c4: Played 259 times (42%), Win rate: 48%
Bf4: Played 31 times (5%), Win rate: 38%
Nc3: Played 9 times (1%), Win rate: 55%
g3: Played 2 times (0%), Win rate: 50%
f4: Played 1 times (0%), Win rate: 0%
c3: Played 1 times (0%), Win rate: 0%
f3: Played 1 times (0%), Win rate: 100%
b3: Played 1 times (0%), Win rate: 100%
----
Analyzing position after move 2. Nf3
Total games in this position: 304 Games, Win rate: 49%
g6: Played 108 times (35%), Win rate: 46%
e6: Played 68 times (22%), Win rate: 48%
d5: Played 58 times (19%), Win rate: 58%
d6: Played 28 times (9%), Win rate: 53%
c5: Played 24 times (7%), Win rate: 37%
c6: Played 7 times (2%), Win rate: 14%
b6: Played 7 times (2%), Win rate: 71%
e5: Played 2 times (0%), Win rate: 50%
Ne4: Played 1 times (0%), Win rate: 0%
Nc6: Played 1 times (0%), Win rate: 100%
----
Analyzing position after move 2... g6
Total games in this position: 108 Games, Win rate: 46%
g3: Played 59 times (54%), Win rate: 45%
Nc3: Played 38 times (35%), Win rate: 47%
h4: Played 6 times (5%), Win rate: 50%
Bf4: Played 4 times (3%), Win rate: 25%
c4: Played 1 times (0%), Win rate: 100%
----
Analyzing position after move 3. g3
Total games in this position: 59 Games, Win rate: 45%
Bg7: Played 54 times (91%), Win rate: 42%
d5: Played 3 times (5%), Win rate: 100%
d6: Played 2 times (3%), Win rate: 50%
----
Analyzing position after move 3... d5
Total games in this position: 16 Games, Win rate: 68%
Bg2: Played 16 times (100%), Win rate: 68%
----
Analyzing position after move 4. Bg2
Total games in this position: 16 Games, Win rate: 68%
Bg7: Played 15 times (93%), Win rate: 66%
Ne4: Played 1 times (6%), Win rate: 100%
----
Analyzing position after move 4... Bg7
Total games in this position: 16 Games, Win rate: 62%
O-O: Played 16 times (100%), Win rate: 62%
----
Analyzing position after move 5. O-O
Total games in this position: 17 Games, Win rate: 58%
O-O: Played 16 times (94%), Win rate: 56%
c5: Played 1 times (5%), Win rate: 100%
----
Analyzing position after move 5... c5
Total games in this position: 1 Games, Win rate: 100%
b3: Played 1 times (100%), Win rate: 100%
c5 is a new move for you after move 5
I have quite a few ideas about further information that would be helpful, but first I need to get it up and running and test if it actually works, before I make it more complicated.
I plan to invite the paid subscribers of Say Chess to join as testers when I have figured out to make a user database.
Let me hear what you think about the idea and concept! Maybe some coding experts are reading this?
/Martin
Hello Martin
I have also been playing around with python - chatgpt acts as a helpful programming buddy. So far I have got to the point where I can supply a collated pgn file of all my games (e.g. lichess, chess.com, chessbase) and get it analysed by opening (but applies to any pgn file).
I can get a break down of my win / draw / loss / score based on ECO, opening name / variation name or alternatively based on a specified number of moves currently.
There are quite a few useful python chess packages hanging around - e.g. pgnhelper will recategorise openings based on a file you supply - double checking opening / variation names and ECO codes (esp useful if missing). My thoughts were to get an automated report based on my openings to focus down on which openings have best results for me, which openings need more focus or are maybe not suited to me) and need changing.
You can do this by stepping through moves in lichess, chess.com but i wanted to have all my games analysed in one place.
I have a basic prototype working and thinking on where to go with it. My thoughts for next steps are to build out an eco / opening classification file that is geared to my repertoire and then analyse the games on that basis. pgnhelper provides a default opening classification but from what I can see you could substitute something geared more towards your own.
Regards
Nigel
thats really cool. are you coding it in python?