Creating EPD from PGN leaf nodes

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

Moderator: Ras

PaulieD
Posts: 240
Joined: Tue Jun 25, 2013 8:19 pm

Creating EPD from PGN leaf nodes

Post by PaulieD »

Looking to simply convert PGN to EPD, but it needs to be the ending pgn positions (leaf nodes) not every move like PGN Extract GUI does.

I have Python 3.4 installed and Ferdinand's PGN sorting tool. Can a simple bat file be creating to convert any pgn file to EPD with ending FEN? PGN Extract Gui does not allow switches to be added to the GUI commands.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Creating EPD from PGN leaf nodes

Post by zullil »

PaulieD wrote:Looking to simply convert PGN to EPD, but it needs to be the ending pgn positions (leaf nodes) not every move like PGN Extract GUI does.

I have Python 3.4 installed and Ferdinand's PGN sorting tool. Can a simple bat file be creating to convert any pgn file to EPD with ending FEN? PGN Extract Gui does not allow switches to be added to the GUI commands.
This comes to mind. Does it help?

http://talkchess.com/forum/viewtopic.ph ... 00&t=55439
User avatar
Steve Maughan
Posts: 1295
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Creating EPD from PGN leaf nodes

Post by Steve Maughan »

Sounds like a good task for Python Chess:

https://github.com/niklasf/python-chess

Here's a post which will explain more:

http://www.talkchess.com/forum/viewtopic.php?t=54779

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
User avatar
Steve Maughan
Posts: 1295
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Creating EPD from PGN leaf nodes

Post by Steve Maughan »

Sounds like a good task for Python Chess:

https://github.com/niklasf/python-chess

Here's a post which will explain more:

http://www.talkchess.com/forum/viewtopic.php?t=54779

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
PaulieD
Posts: 240
Joined: Tue Jun 25, 2013 8:19 pm

Re: Creating EPD from PGN leaf nodes

Post by PaulieD »

zullil wrote:
PaulieD wrote:Looking to simply convert PGN to EPD, but it needs to be the ending pgn positions (leaf nodes) not every move like PGN Extract GUI does.

I have Python 3.4 installed and Ferdinand's PGN sorting tool. Can a simple bat file be creating to convert any pgn file to EPD with ending FEN? PGN Extract Gui does not allow switches to be added to the GUI commands.
This comes to mind. Does it help?

http://talkchess.com/forum/viewtopic.ph ... 00&t=55439
This is more complex than what I am seeking. I saw this with the eval and so on.
PaulieD
Posts: 240
Joined: Tue Jun 25, 2013 8:19 pm

Re: Creating EPD from PGN leaf nodes

Post by PaulieD »

Steve Maughan wrote:Sounds like a good task for Python Chess:

https://github.com/niklasf/python-chess

Here's a post which will explain more:

http://www.talkchess.com/forum/viewtopic.php?t=54779

Steve
This is the right idea. I just need a bat file or python script, I do not know how to do that, I only have Python because I needed it to use a tool from Ferdinand.
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Creating EPD from PGN leaf nodes

Post by Dann Corbit »

PaulieD wrote:Looking to simply convert PGN to EPD, but it needs to be the ending pgn positions (leaf nodes) not every move like PGN Extract GUI does.

I have Python 3.4 installed and Ferdinand's PGN sorting tool. Can a simple bat file be creating to convert any pgn file to EPD with ending FEN? PGN Extract Gui does not allow switches to be added to the GUI commands.
The following batch script:
pgn2fen %1.pgn -e -l |sort|uniq|leaf>%1.epd

You supply the batch file with the name of the pgn file (without the pgn extension) and it will create a file of leaf records.

Sample session, running batch against file baracuda.pgn :
Q:\>makeleaf baracuda

Q:\>pgn2fen baracuda.pgn -e -l | sort | uniq | leaf1>baracuda.epd
Error loading PGN: Error: Line 5157: Unexpected End-of-file
{This is a spurious error message and it can safely be ignored}

The -l parameter is a lower case 'L' and not a '1'...
Q:\>type makeleaf.bat
pgn2fen %1.pgn -e -l |sort|uniq|leaf>%1.epd

Here I use tail the display the records at the bottom of the file:

Q:\>tail baracuda.epd
rnbqkb1r/p4p2/2p1pn1p/1p4p1/2pPP3/2N2NB1/PP3PPP/R2QKB1R w KQkq - fmvn 9; hmvc 0;

rnbqkb1r/p4ppp/2p1p3/3nP3/PpBP4/8/NP3PPP/R1BQK1NR w KQkq - fmvn 9; hmvc 1;

rnbqkb1r/pp3pp1/4pn1p/6B1/3N4/2N5/PP2PPPP/R2QKB1R w KQkq - fmvn 9; hmvc 0;

rnbqr1k1/ppp2ppp/3p1n2/4p3/2PPP3/2PB1N2/P4PPP/R1BQK2R w KQ - fmvn 9; hmvc 1;

rnbr2k1/ppp1qppp/4pn2/3p4/2PP4/5NP1/PP1QPPBP/RN3RK1 w - - fmvn 9; hmvc 2;


Q:\>dir baracuda.pgn
Volume in drive Q is File Repository
Volume Serial Number is 5476-3CD2

Directory of Q:\

2014-11-13 03:55 PM 113,246 baracuda.pgn

send me a pm and I will send you a copy of leaf and uniq if you like.
Norm Pollock
Posts: 1077
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: Creating EPD from PGN leaf nodes

Post by Norm Pollock »

To get the last epd record of each game of a pgn file, use pgn-extract in combination with epdFin (within 40H-EPD utility suite, see www below).

"epdFin" is used in combination with the excellent utility tool
"PGN-Extract" by David Barnes. Together they input a "pgn" file and
output an "epd" file containing a user-specified number of records
from the end of each game. The default is 1 record.

Using the default (1 record), the output will be the final "epd"
record of each game.

Example: PGN-Extract -Wepd -s -otemp.epd alpha.pgn

epdFin temp.epd

Afterwards, you can use epdTrim to remove opcodes, and you can delete temp.epd.
PaulieD
Posts: 240
Joined: Tue Jun 25, 2013 8:19 pm

Re: Creating EPD from PGN leaf nodes

Post by PaulieD »

Norm Pollock wrote:To get the last epd record of each game of a pgn file, use pgn-extract in combination with epdFin (within 40H-EPD utility suite, see www below).

"epdFin" is used in combination with the excellent utility tool
"PGN-Extract" by David Barnes. Together they input a "pgn" file and
output an "epd" file containing a user-specified number of records
from the end of each game. The default is 1 record.

Using the default (1 record), the output will be the final "epd"
record of each game.

Example: PGN-Extract -Wepd -s -otemp.epd alpha.pgn

epdFin temp.epd

Afterwards, you can use epdTrim to remove opcodes, and you can delete temp.epd.
Ok,
Here is my EPD.bat file
PGN-Extract -Wepd -s -otemp.epd TopGM_2move.pgn

epdFin temp.epd

How do I use the epdTrim with the outF.epd end product?
Thanks
Norm Pollock
Posts: 1077
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: Creating EPD from PGN leaf nodes

Post by Norm Pollock »

PaulieD wrote:
Norm Pollock wrote:To get the last epd record of each game of a pgn file, use pgn-extract in combination with epdFin (within 40H-EPD utility suite, see www below).

"epdFin" is used in combination with the excellent utility tool
"PGN-Extract" by David Barnes. Together they input a "pgn" file and
output an "epd" file containing a user-specified number of records
from the end of each game. The default is 1 record.

Using the default (1 record), the output will be the final "epd"
record of each game.

Example: PGN-Extract -Wepd -s -otemp.epd alpha.pgn

epdFin temp.epd

Afterwards, you can use epdTrim to remove opcodes, and you can delete temp.epd.
Ok,
Here is my EPD.bat file
PGN-Extract -Wepd -s -otemp.epd TopGM_2move.pgn

epdFin temp.epd

How do I use the epdTrim with the outF.epd end product?
Thanks
epdTrim outF.epd

output file is outT.epd