is there a program to translate epd file to diagrams?

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

Moderators: hgm, Rebel, chrisw

User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: is there a program to translate epd file to diagrams?

Post by Guenther »

Uri Blass wrote: Mon Jan 14, 2019 8:36 am Thanks for the replies.

Not sure what I am supposed to do exactly.

Do I need to copy the programs in python first to my computer?
searching in my computer I see that I have python2.7.3 in my computer but I never used it and never wrote code in it.

step by step instruction what to do can be productive because I do not want to guess what to do.

Edit:I wonder if it works on the following epd file that I created based on positions from one game in the world blitz women championship
when in all the positions there is a move that is significantly better than other moves.

r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - 0 6 bm cxd5(not Nxd5) easy positional problem
r2qk2r/1p1n1pp1/p2bpn1p/3p1b2/8/1PNP1NP1/PB2PPBP/R2Q1RK1 w kq - 0 11 bm e4
r2qk2r/1p1n1pp1/p2bpn1p/3p4/4P1b1/1PNP1NP1/PB3PBP/R2Q1RK1 w kq - 1 12 bm exd5
r2q1k1r/1p1n1pp1/p2b1n1p/3p4/6b1/1PNP1NPP/PB3PB1/R2QR1K1 b - - 0 14 bm Bh5
r2q2kr/1p1n1pp1/p2b1n1p/3p3b/6P1/1P1P1N1P/PB2NPB1/R2QR1K1 b - - 0 16 bm Bg6 easy
r2q3r/1p1n1ppk/p4nNp/3p4/1b1N2P1/1P1P3P/PB3PB1/R2QR1K1 b - - 0 19 bm fxg6 easy positional problem
r2q3r/1p1n2pk/p3Rnpp/3p4/1b1N2P1/1P1P3P/PB3PB1/R2Q2K1 b - - 1 20 bm Re8 positional problem
2rqr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPbP1Q1P/1B3PB1/R5K1 w - - 1 23 bm Bxc3
2rqr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPBP1Q1P/5PB1/R5K1 b - - 0 23 bm Rxc3(easy tactical)
3qr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPrP1Q1P/5PB1/R5K1 w - - 0 24 bm Rae1
3q4/1p1n2pk/p3rnpp/3p4/3N2P1/PPrP1Q1P/5PB1/4R1K1 w - - 0 25 bm Nxe6(Rxe6 lose a pawn)
8/1p1n2pk/pq2Nnpp/3p4/6P1/PPrP1Q1P/5PB1/4R1K1 w - - 1 26 bm g5
You first have to change it to valid epd.
https://www.chessprogramming.org/Extend ... escription
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: is there a program to translate epd file to diagrams?

Post by Guenther »

Guenther wrote: Mon Jan 14, 2019 9:12 am You first have to change it to valid epd.
https://www.chessprogramming.org/Extend ... escription
I only added an id to the epds with your description (I am also not very familiar with all op codes and it seems there is none for
plain description, thus I added your descriptions to ids, the other missing ids are done automatically by Ferdys script, since
his latest version.

Code: Select all

python epd2svg.py uri.epd uri.html 2 random 8 400 coor
pause
For the result I let it select randomly 8 of your 12 epd records.

Code: Select all

r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - 0;fmvn 6;bm cxd5;am Nxd5;id "easy positional problem 01"
r2qk2r/1p1n1pp1/p2bpn1p/3p1b2/8/1PNP1NP1/PB2PPBP/R2Q1RK1 w kq - 0;fmvn 11;bm e4
r2qk2r/1p1n1pp1/p2bpn1p/3p4/4P1b1/1PNP1NP1/PB3PBP/R2Q1RK1 w kq - 1;fmvn 12;bm exd5
r2q1k1r/1p1n1pp1/p2b1n1p/3p4/6b1/1PNP1NPP/PB3PB1/R2QR1K1 b - - 0;fmvn 14;bm Bh5
r2q2kr/1p1n1pp1/p2b1n1p/3p3b/6P1/1P1P1N1P/PB2NPB1/R2QR1K1 b - - 0;fmvn 16;bm Bg6;id "easy 01"
r2q3r/1p1n1ppk/p4nNp/3p4/1b1N2P1/1P1P3P/PB3PB1/R2QR1K1 b - - 0;fmvn 19;bm fxg6;id "easy positional problem 02"
r2q3r/1p1n2pk/p3Rnpp/3p4/1b1N2P1/1P1P3P/PB3PB1/R2Q2K1 b - - 1;fmvn 20;fmvn;bm Re8;id "positional problem 01"
2rqr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPbP1Q1P/1B3PB1/R5K1 w - - 1;fmvn 23;bm Bxc3
2rqr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPBP1Q1P/5PB1/R5K1 b - - 0;fmvn 23;bm Rxc3;id "easy tactical 01"
3qr3/1p1n2pk/p3Rnpp/3p4/3N2P1/PPrP1Q1P/5PB1/R5K1 w - - 0;fmvn 24;bm Rae1
3q4/1p1n2pk/p3rnpp/3p4/3N2P1/PPrP1Q1P/5PB1/4R1K1 w - - 0;fmvn 25;bm Nxe6;am Rxe6
8/1p1n2pk/pq2Nnpp/3p4/6P1/PPrP1Q1P/5PB1/4R1K1 w - - 1;fmvn 26;bm g5
Result html:
http://rwbc-chess.de/clip/uri.html

Transformed to pdf (by me):
http://rwbc-chess.de/clip/uri.pdf
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: is there a program to translate epd file to diagrams?

Post by Guenther »

Uri Blass wrote: Mon Jan 14, 2019 8:36 am
Not sure what I am supposed to do exactly.

Do I need to copy the programs in python first to my computer?
searching in my computer I see that I have python2.7.3 in my computer but I never used it and never wrote code in it.

step by step instruction what to do can be productive because I do not want to guess what to do.
1. If you never used it and don't intend to use it (for older programs which require python2) uninstall 2.7.3.
2. Then install Python 3 standard for Win
https://www.python.org/downloads/
3. In a real cmd window (probably with admin rights) give the command: "pip install python-chess"
4. This installs the required python-chess library
5. Copy Ferdinands latest py code into an empty text file with the py extension, e.g. "epd2svg.py"
(beware that you hopefully have set your Win to show file extensions, otherwise it might be possible
your OS adds an invisible ".txt" extension to it)
6. Easiest way now is to create a batch file to run the python script and modify it as you like.
The script and your epd should be in the same folder best
7. good advice is also to save Ferdinands instructions as readme in the same folder
e.g.:

Code: Select all

usage:
python b.py <epd filename> <html filename> <html num_column> <[random | seq]> <num_pos> <image_size> <[coor | nocoor]>

example:
command line:
python b.py arasan20.epd arasan_test.html 4 seq 50 250 coor

You need python 3 and python-chess installed.
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: is there a program to translate epd file to diagrams?

Post by Ferdy »

Uri Blass wrote: Mon Jan 14, 2019 8:36 am Do I need to copy the programs in python first to my computer?
Yes copy the text posted on b.py and save it as b.py, this is the script that will be run by python, or download the b.py https://drive.google.com/file/d/148IkCC ... sp=sharing

Also download the wacnew.epd https://drive.google.com/file/d/11-t1oy ... sp=sharing

And the batch file to run b.py and wacnew.epd https://drive.google.com/file/d/1Sw8BcU ... sp=sharing

The entry in epd2diag.bat (or batch file) is

Code: Select all

python b.py wacnew.epd wac_test.html 2 random 20 300 coor
pause
2 = number of columns in html
random = the epd will be randomly selected
20 = number of positions
300 the image size in pixels
coor = to enable coordinates in diag

usage:

Code: Select all

python b.py <epd filename> <html filename> <html num_column> <[random | seq]> <num_pos> <image_size> <[coor | nocoor]>
Uri Blass wrote: Mon Jan 14, 2019 8:36 amsearching in my computer I see that I have python2.7.3 in my computer but I never used it and never wrote code in it.
Since you did not use it, uninstall that python 2.7.3. Then install python 3.7.2 from https://www.python.org/downloads/
Uri Blass wrote: Mon Jan 14, 2019 8:36 amEdit:I wonder if it works on the following epd file that I created based on positions from one game in the world blitz women championship
when in all the positions there is a move that is significantly better than other moves.
This one
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - 0 6 bm cxd5(not Nxd5) easy positional problem
is not a valid EPD

To make it a valid epd remove the "0 6 bm cxd5(not Nxd5) easy positional problem"
0 = hmvc = halfmove clock (for fifty move rule)
6 = fmvn = fullmove number
bm = bestmove

So the minimal valid epd is
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq -
It only consist of 4 fields
Field 1: r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R
Field 2: b
Field 3: KQkq
Field 4: -

Field1: Piece types and locations
Field 2: side to move
Field 3: castling rights
Field 4: en passant square
An example epd with en passant square is
rnbqkbnr/ppp3pp/4p3/3pPp2/3P4/8/PPP2PPP/RNBQKBNR w KQkq f6
f6 is the en passant square

You can add the halfmove clock info specially if it is close to fifty move or 100 ply, if it is 0, you can ignore it.
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0;

You can add the fullmove number
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0; fmvn 6;

You can add bm
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0; fmvn 6; bm cxd5;

You can add am or avoid move
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0; fmvn 6; bm cxd5; am Nxd5;

You can add comment, enclose it in double quotes.
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0; fmvn 6; bm cxd5; am Nxd5; c0 "(not Nxd5) easy positional problem";

You can add another comment.
r2qkb1r/pp1npppp/2p2n2/3P1b2/8/1P3NP1/PB1PPP1P/RN1QKB1R b KQkq - hmvc 0; fmvn 6; bm cxd5; am Nxd5; c0 "easy positional problem"; c1 "Women's Championships";

hmvc, fmvn, bm am and c0 are called opcodes. https://www.chessprogramming.org/Extend ... escription

After the installation of python 3.7.2, install the python-chess lib from https://github.com/niklasf/python-chess
How to install python-chess in windows?
Open your cmd shell perhaps run as administrator to be sure then type
pip install python-chess

Image

The program pip is supposed to be included in python 3.7.2, this is why install first the python 3.7.2.

Once python 3.7.2 and python-chess are installed, you can run the epd2diag.bat by double-clicking it. You can then open the html file. You can modify the batch file to use other epd file or adjust the html columns, image size and others.

Place the b.py, wacnew.epd and epd2diag.bat in a directory, example c:\epd2diag2html.