EPD to PGN

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

EPD to PGN

Post by Brunetti »

Hello,
do you know if there is a utility that can do this? I would provide it with an EPD position, and it should return a PGN game that reaches that position, regardless of the move sequence as long as they are legal. I need this to convert some opening files I had generated previously, typically involving positions reached after 8 moves for each side. It shouldn't be too complicated to write, but if it already exists, it would save me time :D

Thanks,
Alex
petero2
Posts: 729
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: EPD to PGN

Post by petero2 »

Constructing a game that leads to a position is known as the "proof game" problem and is in general difficult to solve.

https://en.wikipedia.org/wiki/Proof_game

However, if the positions you are interested in come from relatively short opening lines, the problem should be much simpler. "texelutil proofgame" should be able to solve such problems. It does however take a FEN, not an EPD as input, and it produces a move sequence in short algebraic notation as output, not a full PGN, so some additional scripting will be required to use it.

Example (assuming bash shell):

$ echo "r1bqkb1r/pppp1ppp/2n2n2/8/3NP3/8/PPP2PPP/RNBQKB1R w KQkq - 1 5" | texelutil proofgame -f -o out 2>log
...
$ cat out02
r1bqkb1r/pppp1ppp/2n2n2/8/3NP3/8/PPP2PPP/RNBQKB1R w KQkq - 1 5 legal: proof: e4 Nc6 Qe2 Nd4 Qd1 Ne2 d4 e5 dxe5 Nf4 e6 Ne2 e7 Qxe7 Nf3 Qg5 Ng1 Qd8 Nf3 Nf6 Ng1 Nd4 Nf3 Nc6 Nd4 Ba3 Qf3 Bd6 Qd1 Bf8

Some documentation is available here: https://github.com/peterosterlund2/texe ... oofgame.md
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: EPD to PGN

Post by Brunetti »

petero2 wrote: Sun Oct 29, 2023 5:35 am "texelutil proofgame" should be able to solve such problems. It does however take a FEN, not an EPD as input, and it produces a move sequence in short algebraic notation as output, not a full PGN, so some additional scripting will be required to use it.
Hi Peter,
I've used TexelUtils, and it works very well for some positions, but for others, it takes too long. For example, for this position "2kr1b1r/pp2pppp/2n2n2/2P5/6b1/2P5/PP2BPPP/RNB1K1NR w - - 0 9," it takes several minutes. I ran the program on my 50,000 positions for a few hours, but the converted part wasn't significant. Setting a low value for maxnodes results in too many positions being discarded. Now, I will try to write a specific simplified function for my 16 half-moves positions.
Thanksel anyway!

Alex
petero2
Posts: 729
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: EPD to PGN

Post by petero2 »

Brunetti wrote: Sun Oct 29, 2023 2:19 pm I've used TexelUtils, and it works very well for some positions, but for others, it takes too long. For example, for this position "2kr1b1r/pp2pppp/2n2n2/2P5/6b1/2P5/PP2BPPP/RNB1K1NR w - - 0 9," it takes several minutes. I ran the program on my 50,000 positions for a few hours, but the converted part wasn't significant. Setting a low value for maxnodes results in too many positions being discarded. Now, I will try to write a specific simplified function for my 16 half-moves positions.
Hi Alex,

Did you use the "-f -o ..." options? Your position was solved in around 0.1 seconds when I tried:

$ echo "2kr1b1r/pp2pppp/2n2n2/2P5/6b1/2P5/PP2BPPP/RNB1K1NR w - - 0 9" | texelutil proofgame -f -o out 2>log ; cat out02
legal: 0 path: 0 kernel: 1 fail: 0 illegal: 0 time: 0.005
legal: 0 path: 1 kernel: 0 fail: 0 illegal: 0 time: 0.069
legal: 1 path: 0 kernel: 0 fail: 0 illegal: 0 time: 0.084
2kr1b1r/pp2pppp/2n2n2/2P5/6b1/2P5/PP2BPPP/RNB1K1NR w - - 0 9 legal: proof: d4 c5 dxc5 d5 Qxd5 Qxd5 e4 Qf5 exf5 Bxf5 c3 Bc8 Nh3 Kd7 Nf4 Nc6 Nh3 Nf6 Bc4 Kc7 Be2 Bg4 Ng1 Rd8 Kf1 Kb8 Ke1 Kc8
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: EPD to PGN

Post by Dann Corbit »

Load them into a book and then use this:
viewtopic.php?f=7&t=81702&sid=5d176349c ... 2c961a59a5
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: EPD to PGN

Post by Brunetti »

Dann Corbit wrote: Mon Oct 30, 2023 11:31 am Load them into a book and then use this:
viewtopic.php?f=7&t=81702&sid=5d176349c ... 2c961a59a5
Thanks, and how to load them into a book? :)

Alex
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: EPD to PGN

Post by Brunetti »

petero2 wrote: Sun Oct 29, 2023 5:07 pm Hi Alex,

Did you use the "-f -o ..." options? Your position was solved in around 0.1 seconds when I tried:

$ echo "2kr1b1r/pp2pppp/2n2n2/2P5/6b1/2P5/PP2BPPP/RNB1K1NR w - - 0 9" | texelutil proofgame -f -o out 2>log ; cat out02
Hi,
I'm using Windows, and I couldn't manage in any way to generate the proof games for the entire EPD file with TexelUtil, despite various attempts with pipes and redirections.

Alex
Norm Pollock
Posts: 1077
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: EPD to PGN

Post by Norm Pollock »

If you want a simple solution and the sequence of moves is not important (as long as they are legal), then use a FEN tag and go from there. This method will not be useful if you are building an opening book.

I wrote a simple tool to convert an epd to a pgn with a fen tag. It is called "epdConvert" and it is in the "40H-EPD" download on my chess page (link is at the bottom).
Updated links for 40H Tools and Databases
http://40Hchess.epizy.com
http://nk-qy.info/40h
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: EPD to PGN

Post by Brunetti »

Norm Pollock wrote: Sat Dec 09, 2023 3:32 pm If you want a simple solution and the sequence of moves is not important (as long as they are legal), then use a FEN tag and go from there. This method will not be useful if you are building an opening book.
Hello, my issue is not that one. That would be trivial. I want to convert my EPD file into a PGN file to use it with engines that do not allow the input of positions (UCI "position fen" or XB "edit"). Therefore, I need to replace my EPD positions with sequences of moves from the starting position. Unfortunately, I did not think about this problem when I created the file a long time ago, spending hours in processing and then throwing away various original files. I created my set of positions through a lengthy process of evaluation and selection to obtain a very diversified and balanced set, and I consider it a crucial tool for evaluating engines, both for mine and those on my ultrabullet list. The set of positions is essential for obtaining accurate evaluations even with a limited number of games, and I am proud of my set. That's why I would like to preserve it, but not having saved the move sequences poses a problem.

Alex
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: EPD to PGN

Post by Dann Corbit »

If you have a very large database of games, then you can use Scid effectively.
Post the position in Scid, and then do an opening report.
It will show you the most frequent move list to achieve that position.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.