Gaming games
Reading time: 2 minutes
Chess.com is a great online chess server and content creator. One of their hallmark features is their chess puzzles:
-
Present the player with a position
-
The player needs to find the ’tactic’: the best sequence of moves, typically resulting in an advantage over the opponent
-
The quicker the player completes a puzzle, the more points they earn
They look like this:
Puzzles are nice because they help players train their pattern recognition and develop their intuition for chess.
Puzzles are nicer because they lead to pretty stats and graphs. Like this!
Rating solved puzzles opens up the meta-game of improving our stats. Can we use the power of The Cloud™ to improve our score?
Pointless cheating
When you visit the Chess.com homepage, one of the things you’re presented with is this dashboard encouraging more play:
The puzzle shown there isn’t a static image, but is in fact a real puzzle that’ll be served up to the user if they click through.
It’s provided by the https://www.chess.com/callback/tactics/rated/next
endpoint.
Interestingly, lots of information about the puzzle is returned to the client, including its solution!
The endpoint returns FEN for how the puzzle’s board should be set up, as well as the puzzle’s continuation (i.e. the solution) in a couple formats: PGN, and a format internal to Chess.com called TCN
:
{
// ...
"id": 1319119,
"initialFen": "2r1k3/p2b1r2/4p3/3p3Q/3P1p2/1Pp1n1N1/Pn2K2P/3R1R2 b - - 1 31",
"internalNote": "Generated from CEAC",
"tcnMoveList": "udfDskN1871T7YmlYPwm"
// ...
}
When the player completes the puzzle, the client POST
s some data to https://www.chess.com/callback/tactics/submitMoves
, with a body something like the following:
{
"moves": "<Player's move list, encoded in TCN>",
"outcome": "<Did the player win?>",
"tacticsProblemId": "<Puzzle ID>",
}
Could… could we just plug in the TCN
solution from when we were served the puzzle?
Yep.
I stopped the bot after a couple hours with a rating near 9k, well past the point of absurdity✱.
✱ Note
Other interesting information about the puzzles are returned too, such as internal notes and historical human games that the puzzles were derived from. Some things are also displayed in the Chess.com UI, such as the average pass rate for the puzzle and estimated difficulty rating. Apparantly, based on the internal notes, lots of their puzzles are auto-generated from their CEAC (Computer Engine Analysis in the Cloud) system.
The puzzle response also includes the average time it took other players to solve the puzzle. To avoid being too egregious, I inserted a delay prior to submitting each solution (with a bit of jitter to emulate my CPU thinking really hard). But if Chess.com banned the account, that’d be an interesting and welcome outcome too.
Is this useful?