lichess-org / database

Public exports of all rated games, puzzles, and computer evaluations.
https://database.lichess.org
GNU Affero General Public License v3.0
86 stars 28 forks source link

Chess puzzles write move number as #Some(23) #49

Closed carlini closed 10 months ago

carlini commented 10 months ago

The lichess puzzle db at https://database.lichess.org/#puzzles does not follow the specified format. Instead of encoding puzzles with the move number as in the example:

00sHx,q3k1nr/1pp1nQpp/3p4/1P2p3/4P3/B1PP1b2/B5PP/5K2 b k - 0 17,e8d7 a2e6 d7d8 f7f8,1760,80,83,72,mate mateIn2 middlegame short,https://lichess.org/yyznGmXs/black#34,Italian_Game Italian_Game_Classical_Variation
00sJ9,r3r1k1/p4ppp/2p2n2/1p6/3P1qb1/2NQR3/PPB2PP1/R1B3K1 w - - 5 18,e3g3 e8e1 g1h2 e1c1 a1c1 f4h6 h2g1 h6c1,2671,105,87,325,advantage attraction fork middlegame sacrifice veryLong,https://lichess.org/gyFeQsOE#35,French_Defense French_Defense_Exchange_Variation

The move number is written as

00008,r6k/pp2r2p/4Rp1Q/3p4/8/1N1P2R1/PqP2bPP/7K b - - 0 24,f2g3 e6e7 b2b1 b3c1 b1c1 h6c1,1951,77,94,5235,crushing hangingPiece long middlegame,[https://lichess.org/787zsVup/black#Some(47)](https://lichess.org/787zsVup/black#Some%2847%29),
0000D,5rk1/1p3ppp/pq3b2/8/8/1P1Q1N2/P4PPP/3R2K1 w - - 2 27,d3d6 f8d8 d6d8 f6d8,1470,75,96,25000,advantage endgame short,[https://lichess.org/F8M8OS71#Some(52)](https://lichess.org/F8M8OS71#Some%2852%29),
0008Q,8/4R3/1p2P3/p4r2/P6p/1P3Pk1/4K3/8 w - - 1 64,e7f7 f5e5 e2f1 e5e6,1277,75,90,488,advantage endgame rookEndgame short,[https://lichess.org/MQSyb3KW#Some(126)](https://lichess.org/MQSyb3KW#Some%28126%29),

Note the "#Some(47)" etc.

I believe this is an error caused by the fact that this line

https://github.com/lichess-org/database/blob/690c473edf12c03fbd8e2ec5956297b75e552870/src/main/scala/Puzzles.scala#L80

calls readPly which returns an Option[Ply] (https://github.com/lichess-org/scalachess/blob/6cffb30ecf55b9859263bb150cafb7812e6180ef/src/main/scala/format/FenReader.scala#L99) and so serializing it results in Some in the URL.

carlini commented 10 months ago

Amazing! Thanks so much for the quick fix. (And for doing so much with lichess. It's the best.)