#Generating tactics DB from a pgn of Master games (for an opening of chioce)

9 messages · Page 1 of 1 (latest)

scenic needle
#

Hi all,

Posted this in general-programming-chat and was advised to forward this here. Thank you to @ tors (quoting is bad practice, right?) for sharing useful links at https://github.com/ornicar/lichess-puzzler & https://github.com/kraktus/lichess-puzzler. Unfortunately, I am not quite sure how to use them for my application as the documentation is rather scant.

I was very interested in how lichess.org generates tactics for his Puzzles DB. I was thinking of using something similar to find all combinations within games played in a certain opening (I am studying the Semi-Slav, Botvinnik and having a database of thematic tactics would be helpful). I intend to run the algo on a .pgn containing Master and model games in my opening of interest, and extracting all tactics to practice later.

I stumbled upon this: https://github.com/vitogit/pgn-tactics-generator (which is based upon https://github.com/clarkerubber/Python-Puzzle-Creator ) and played around w/ it a little, but w/o much success. The program seemingly analyzes the games and does detect tactics within my test.pgn, but it does not store the them in tactics.pgn (where I would expect to find the FEN and soution, though I am mostly just interested in the FEN). I am running the latest version of Stockfish 17 and Python 3.13.2.

If anyone has experience w/ this, all hints and tips are appreciated. Thanks!

scenic needle
#

Was suggested by @ NanoPixel to look into https://github.com/linrock/chess-puzzle-maker .

Much like w/ https://github.com/vitogit/pgn-tactics-generator , it analyzes the games and detects positions where tactical opportunities might exist (e.g., CP: 541, Investigate!), it creates a batch of positions to consider but eventually always says "Not going deeper: ambiguous - Puzzle incomplete".

I have run it on a test game from lichess.org Puzzles, so it clearly was deemed as a game that contains puzzle(s). Am I the only one experiencing issues w/ these tools?

oak wagon
scenic needle
#

Thank @ TBest. Yes, that is what @ tors suggested (see above). Have you used it yourself?

scenic needle
#

[update (10.03.2025, 4:40pm)]

@ NanoPixel shared valuable feedback on his experience w/ chess-puzzle-maker. He says:

"The script is quite strict about what it allows as a valid puzzle: no "double solutions" are allowed from the side that plays the puzzle (that is, at no point in the line the improving side should have two top moves with relatively close scores), so you might not get a large amount of puzzles generated in the end. IIRC I was getting a complete puzzle every 2-3 games analyzed (though this statistic is probably very volatile depending on the quality of the games...)"

I offer some details about my experiments as reaction:

I am using this game as my test.pgn: https://lichess.org/2ge8gy4 . Running both pgn-tactics-generator and chess-puzzle-maker I get no puzzles created. Using lichess-puzzler I get one (6rk/1pq4p/p3p1n1/3p1p2/5P2/P2N1P2/1P3Q1P/6RK b - - 5 35) . Now, from a visual inspection, I would say that all these are puzzle-worthy positions: 2r4k/1p3q1p/p3p2b/2Npnp2/5P2/P3BPQ1/1P5P/6RK w - - 0 30 , 2r4k/1p3qbp/p3p3/3pnp2/3B1P2/P2N1PQ1/1P5P/6RK b - - 3 31 , 6rk/1pq4p/p3p3/3p1p2/5n2/P2N1P2/1P3Q1P/6RK w - - 0 36 (incidentally, this is the puzzle from lichess I got the game from), 6rk/1pq4p/p3p3/3p1p2/3Q1n2/P2N1P2/1P5P/6RK b - - 1 36 , 8/6N1/1pk5/p2p3p/P3n2P/K7/1P6/8 b - - 3 59 , 8/8/1p6/p2k3p/P2N2nP/3K4/1P6/8 b - - 0 64 and 8/2k5/1p1N4/p2K4/8/1P1n4/8/8 b - - 12 89 . Interestingly, the one flagged by lichess-puzzler is not even amongst them.

@ NanoPixel reply: Well, in that case, 6rk/1pq4p/p3p1n1/3p1p2/5P2/P2N1P2/1P3Q1P/6RK b - - 5 35 is not flagged as a puzzle because after 35... Qc4 36. Rd1 both 36... d4 and 36... Rg7 maintain the advantage, which is why chess-puzzle-maker discards it

scenic needle
#

[update (10.03.2025, 6:20pm)]

From the discussion w/ @ NanoPixel, I learn that 6rk/1pq4p/p3p3/3p1p2/5n2/P2N1P2/1P3Q1P/6RK w - - 0 36 (lichess' own puzzle) is not flagged probably because lichess and chess-puzzle-maker follow a different logic when evaluating puzzle-worthy positions. I inquire whether these strict constraints are relaxable and I get the insightful reply:

"I haven't looked at lichess' codebase that much, so I cannot comment on how they filter positions for puzzle generation.
After some manual tweaking of the code, the FEN you gave does generate a 9-move puzzle, with the mainline being 36. Rxg8+ Kxg8 37. Qg3+ Kf7 38. Qxf4 Qxf4 39. Nxf4 Ke7 40. Nd3 Kd6 41. f4 d4 42. Kg2 Kd5 43. Kf3 Kc4 44. Nc1"

warm wyvern
#

(non-related, thanks so much for posting these updates - this is very valuable information you are sharing - thanks!)

oak wagon
scenic needle
# oak wagon I have not used it, but as stated in the readme, Lichess has used it ( usually t...

Indeed, and thank you for pointing me in that direction! As I write above, it was the only app, of the three tested, that returned one (though only one) puzzle in the test game. However, the proposed puzzle is not one you would really consider as puzzle-worthy from a human-analysis perspective. Perhaps more importantly, lichess-puzzler failed to flag the position offered as puzzle by lichess itself.