You might be interested in post #2 in this topic...
https://www.chess.com/clubs/forum/view/guide-unofficial-api-documentation
I may be wrong but I'm not sure ordinary members are supposed to be using the 'callback' feature?
You might be interested in post #2 in this topic...
https://www.chess.com/clubs/forum/view/guide-unofficial-api-documentation
I may be wrong but I'm not sure ordinary members are supposed to be using the 'callback' feature?
I'm not "using" anything. I'm merely curious what notation the site is using internally when previous games are loaded.
It's clearly in some form of code although I can't say why other that it appears shorter than regular notation. To prove my point though you can see the 'last move' is 'P6' and that matches the notations' set with the last move of the 'moveset': 'mC0Kgv!TbsYIft5QegQziqztktWGvKZRKA6EnvENdm7ZAPZ6P6' being P6. you could probably look at a few games and compare pieces and positions to convert it since its likely some sort of replacement cipher. Sound like a good project for a python user.
This is not an answer to the OP's question but might be interesting anyway. The standard algebraic notation has a lot of entropy (i.e., the average amount of information represented by a single character is low). Pretty much any move may be represented by the start square and the end square (e.g., Ng1-f3 may be represented by 2 squares, [g1, f3]). The only exception to this is a pawn promotion, so let's ignore this for a while. **
64 squares on the chessboard means you need 64 unique characters to represent a square, let's say A-Z (that's 26), a-z (another 26), 0-9 (another 10) gives you 62 characters, just choose any other 2 characters (say, ! and @) and you can represent any square with a single character, and thus any move with 2 characters.
Thus, 1. e4 e5 2. Ke2 Ke7 3. Ke1 Ke8 4. Ke2 Ke7 5. Ke1 Ke8 etc. may be represented, for instance, as Ec0kEM80ME08EM80ME08 etc. (or with move numbers emphasised, 1. Ec 0k 2. EM 80 3. ME 08 4. EM 80 5. ME 08 etc.).
** Alright, so what about the pawn promotion? The start square still identifies the pawn to promote and we can use some clearly illegal moves to represent, where the promoting pawn goes and which piece it promotes to. 4 pieces the pawn can promote to (Q, R, B, N). So, e7-e8=Q may be represented as (for example) e7-e6, whereas e7-e8=R may be represented as e7-e5 (i.e., [e7, e6]), e7-e8=B as e7-e4 etc. Similarly, e7xd8=N may be represented as e7-d3 (or [e7, d3]). So a pair of 2 characters from the set of 64 possible symbols/characters is more than enough to represent any move.
Thank you WhiteDrake! That is very insightful and I understand where you are going with that analysis. I was looking at the letter combinations and I was thinking they might be a conversion from a binary representation where so many bits are reserved for the square the piece is moving to, etc.
Realistically, (unless I'm forgetting something important), you could just represent a game with the value a piece is moving to and a few bits to represent the piece. A piece could be:
King, Queen, Rook, Bishop, Knight, Pawn, Pawn2Queen, Pawn2Knight, Pawn2Bishop and Pawn2rook. If you just record the squares where a piece is moving to, I don't even think you would need to specify what piece it is (unless you are doing Chess960 or something) -- but the only unknown would be pawn promotion where you would need to know what the pawn becomes.
The board is 64 squares so that's handled by six bits. If you just record the square a piece is moving to and 4 bits for the piece itself (that covers 10 pieces). On second thought, the knights and rooks could be in a position where either could be a valid move to the new square -- so I guess you would need to know the origin square.
Anyway, this looks like a fun little project to play with via Python! Perhaps the javascript files have some clues, too.
def tcn_to_UCIs ( ml ) : """ Eats a chess.com TCN moveList string, and converts it to a list of UCI moves. Based on https://raw.githubusercontent.com/AnishN/bugaboo/master/tcn_parser.py which is based on https://r.cnpmjs.org/chess-tcn chesscom movelist format : every move are denoted by 2 letters, regular moves : letter of the source square, then the target square of the piece castles : letter of the source square, then the target square of the king en passants : letter of the source square, then the target square of the pawn drops : letter of the piece &,-,*,+,= -> q,n,r,b,p, then target square square promotions : letter of the promoting pawn's source square, then one of the letters of "{~}" "(^)" "[_]" "@#$" that means pawn to move left/straigth/right, and promote to q,n,r,b squares are numbered : a1,a2..h7,h8 with letters from abc..89!? pieces are denoted : &,-,*,+,= -> q,n,r,b,p UCI format : UCI drop : p@e4 UCI castle : e1g1 UCI promotion : e7e8q """ tcn_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?" + "{~}(^)[_]@#$" + "&-*+=" piece_chars = "qnrbp" ret = [] for i in range(0, len(ml), 2) : s = tcn_chars.index(ml[i]) # source t = tcn_chars.index(ml[i+1]) # target ss = tcn_chars[s % 8] + str(s//8 + 1) # source square ts = tcn_chars[t % 8] + str(t//8 + 1) # target square if s >= 76 : # source is not a square, this is a drop ! p = piece_chars[s - 76] ret.append( p + '@' + ts ) continue if t >= 64 : # target is not a square, this is a promotion ! p = piece_chars[(t-64)//3] t = s + (-8 if s < 16 else 8) + ( (t - 64) % 3) - 1 ts = tcn_chars[t % 8] + str( t//8 + 1) ret.append( ss + ts + p ) continue ret.append ( ss + ts ) return ret
I came up with this some months ago, i still think it's readable enough, but I see a plenty of room to improve it
So I was pretty close and my solution would not need more than 64 unique characters, unlike the actual Chess.com's solution The big advantage of Chess.com's solution is that it can be used for a chess variant like crazy house, where you need to represent a piece being dropped to an unoccupied square.
Thanks for the solution, @bmacho
If you need help, please contact our Help and Support team.
I was viewing the details of one of my games via the game ID API callback endpoint:
https://www.chess.com/callback/live/game/5906492213
I noticed the moveList key with the following move notation:
moveList: "mC0Kgv!TbsYIft5QegQziqztktWGvKZRKA6EnvENdm7ZAPZ6P6"
What type of chess move notation is that using? Looking at the Move list, it appears two characters represent a move since this game had a total of 25 ply. My guess is that each two letter combination is recording which piece has moved where but it might just hold to and from destinations. It looks like a neat notation but I haven't checked the Javascript files yet to see if there is any code there that gives more answers.
Anyone know?