Looking for pgn format converter tool

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

Moderator: Ras

Ferdy
Posts: 4852
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Looking for pgn format converter tool

Post by Ferdy »

tpetzke wrote:
Since you are designing a gui, would suggest to separate the eval and the depth to make it more readable like, [%eval 50][%depth 18], and not [%eval 50,18]
I actually replace it into { +0.50/18 0.14s }

This is the format cutechess-cli outputs, I think Arena does it too in this form. And my future GUI will also write it in this form. I want to get rid of those %tag and not just replace it with something else.

I have written a small parser for this format a while back and it is actually not so difficult to parse.
When your gui receives a pgn with [%command embedded in comments, it is indeed very good to convert it to something like { +0.50/18 0.14s }. But for a human that is new to pgn formatting, I begin to like the presentation of say,

Code: Select all

1. e4 { [%evalcp 4][%depth 16][%emt 0:00:48] } e5 
emt = elapsed move time in h:mm:ss.

For engines it could be,

Code: Select all

1. e4 { [%scorecp 4][%depth 16][%time 48000][%nodes 20000][%pv "e2e4 e7e5 g1f3 g8f6"] } e5 
when following the uci standard a bit.

In another situation where you conduct an engine tournament in your gui, it would be nice to make an option to make the gui capable of exporting the pgn in a format similar to the pgn specs and guide supplement. So you have this [%clk, [%emt and other commands for live transmission info and others perhaps.

http://www.enpassant.dk/chess/palview/enhancedpgn.htm

Looking on that guide, I wonder how they are going to show if the move time is 100 millisec, where it is only limited to h:mm:ss. So perhaps,
[%emt 0:00:01] would be enough.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Looking for pgn format converter tool

Post by tpetzke »

When your gui receives a pgn with [%command embedded in comments, it is indeed very good to convert it to something like { +0.50/18 0.14s }. But for a human that is new to pgn formatting, I begin to like the presentation of say, 1. e4 { [%evalcp 4][%depth 16][%emt 0:00:48] } e5
It is even worse. According to the standard I think it should be then

1. e4 { [%evalcp 4][%depth 16][%emt 0:00:48] } 1... e5

I think it is a matter of taste. The pgn format was intended to be human readable otherwise one would use just LAN instead of SAN notation (which really is a pain for a programmer). %evalcp looks like something meant for machines. When I first saw a pgn produced by ChessGUI I thought they sent a debug file.
http://www6.chessclub.com/help/PGN-spec:
A black move element has a preceding move number indication only in two cases: first, if there is intervening annotation or commentary between the black move and the previous white move; and second, if there is no previous white move in the special case where a game starts from a position where Black is the active player.
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
Ferdy
Posts: 4852
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Looking for pgn format converter tool.

Post by Ferdy »

stegemma wrote:It seems that there's not a standard for mate values. I will change somehow my preprocessor. Just for reference, here's the relevant part of the code:
Initially the purpose is to convert only the games from Frank's pgn file.
Now I learn more about the pgn standard :) .
Ferdy
Posts: 4852
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Looking for pgn format converter tool

Post by Ferdy »

hgm wrote:You should beware that there is no general formula for the M-nnn nonsense. It is not part of the [%eval] format, but a situation-dependent error in it. It arises from having defined a wrong mating score in the WB2UCI adapter, i.e. with a value smaller than what the engine is actually using. So it is not even reproducible with the same engine; when you run Crafty in another situation (with other WB2UCI settings) the conversion to real mating scores would have to be completely different.
I was only referring to the pgn file from Frank's tournament. I tried to understand why there is this -M, or +M and showed to Stefano the idea and the bloody general formula :).
Ferdy
Posts: 4852
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Looking for pgn format converter tool

Post by Ferdy »

Here is the pgn from Graham's Division 2 tournament using ChessGUI gui. The good here is there are no +M and -M, but the POV is side, so there is no need to invert the score of black.

Does anyone know of what is (Kd7) in the ff.

Code: Select all

80. Ne2 {(Ne2) [%eval -85,26] [%emt 0:00:37]} Ne3 {(Kd7) [%eval 0,43] [%emt 0:00:17]}
I plan to create a script to convert this. But would be better if you can incorporate this to your existing tool. Perhaps some switches for shredder output and ChessGUI output. This is not urgent. Thanks.

Sample game.

Code: Select all

[Event "50th Amateur D2"]
[Site "ChessGUI2"]
[Date "2014.11.24"]
[Round "1.6"]
[White "iCE 2.0 64-bit"]
[Black "Deuterium 14.3.34.130 64-bit"]
[Result "1/2-1/2"]
[ECO "D35"]
[PlyCount "165"]
[EventDate "2014.??.??"]
[TimeControl "40/1500:40/1500:40/1500"]

{Intel i5 Quad} 1. d4 {[%eval 0,1] [%emt 0:00:00]} d5 {
[%eval 0,1] [%emt 0:00:00]} 2. c4 {[%eval 0,1] [%emt 0:00:00]} e6 {
[%eval 0,1] [%emt 0:00:00]} 3. Nc3 {[%eval 0,1] [%emt 0:00:00]} Nf6 {
[%eval 0,1] [%emt 0:00:00]} 4. cxd5 {[%eval 0,1] [%emt 0:00:00]} exd5 {
[%eval 0,1] [%emt 0:00:00]} 5. Bg5 {[%eval 0,1] [%emt 0:00:00]} c6 {
[%eval 0,1] [%emt 0:00:00]} 6. e3 {[%eval 0,1] [%emt 0:00:00]} Be7 {
[%eval 0,1] [%emt 0:00:00]} 7. Bd3 {[%eval 0,1] [%emt 0:00:00]} O-O {
[%eval 0,1] [%emt 0:00:00]} 8. Qc2 {[%eval 0,1] [%emt 0:00:00]} h6 {
[%eval 0,1] [%emt 0:00:00]} 9. Bh4 {[%eval 27,20] [%emt 0:00:48]} Be6 {
(Na6) [%eval -14,21] [%emt 0:00:59]} 10. Nge2 {
(Nf3) [%eval 74,19] [%emt 0:00:46]} Nh5 {(c5) [%eval -17,22] [%emt 0:01:52]}
11. Bxe7 {(Bxe7) [%eval 71,20] [%emt 0:00:43]} Qxe7 {
(Qxe7) [%eval -13,20] [%emt 0:00:31]} 12. O-O {
(O-O) [%eval 69,19] [%emt 0:00:44]} Nd7 {(Re8) [%eval -14,19] [%emt 0:00:44]}
13. f3 {(Na4) [%eval 68,18] [%emt 0:00:46]} Nb6 {
(Rfe8) [%eval -18,19] [%emt 0:00:28]} 14. e4 {(e4) [%eval 84,17] [%emt 0:00:43]
} dxe4 {(dxe4) [%eval 0,22] [%emt 0:00:45]} 15. fxe4 {
(fxe4) [%eval 68,18] [%emt 0:00:47]} c5 {(Qg5) [%eval 0,23] [%emt 0:01:24]} 16.
d5 {(d5) [%eval 24,19] [%emt 0:00:50]} c4 {(c4) [%eval 0,22] [%emt 0:00:30]}
17. dxe6 {(dxe6) [%eval 10,20] [%emt 0:00:42]} fxe6 {
(fxe6) [%eval 0,21] [%emt 0:00:38]} 18. Nc1 {(Nc1) [%eval 0,20] [%emt 0:01:05]}
cxd3 {(cxd3) [%eval 0,24] [%emt 0:00:32]} 19. Nxd3 {
(Nxd3) [%eval 0,20] [%emt 0:00:46]} Rad8 {(Rad8) [%eval 0,22] [%emt 0:00:39]}
20. Rae1 {(Rxf8) [%eval -6,20] [%emt 0:00:58]} Rxf1+ {
(Rxf1) [%eval 0,22] [%emt 0:00:40]} 21. Rxf1 {
(Rxf1) [%eval -23,21] [%emt 0:00:45]} Nc4 {(Qd6) [%eval 16,24] [%emt 0:01:07]}
22. Nd1 {(Nd1) [%eval -40,20] [%emt 0:00:45]} Rd4 {
(Rd4) [%eval 13,22] [%emt 0:00:44]} 23. Rf3 {
(Qc3) [%eval -38,21] [%emt 0:00:53]} Nf6 {(Nf6) [%eval 28,22] [%emt 0:00:42]}
24. N1f2 {(N1f2) [%eval -28,21] [%emt 0:00:49]} Qd6 {
(e5) [%eval 28,23] [%emt 0:00:54]} 25. b3 {(b3) [%eval -58,21] [%emt 0:01:04]}
Ne5 {(Ne5) [%eval 22,23] [%emt 0:00:43]} 26. Nxe5 {
(Nxe5) [%eval -46,21] [%emt 0:00:38]} Qxe5 {(Qxe5) [%eval 28,20] [%emt 0:00:43]
} 27. Re3 {(Qc8) [%eval -47,20] [%emt 0:01:19]} Rd7 {
(Rd7) [%eval 36,20] [%emt 0:00:22]} 28. Rc3 {
(Rc3) [%eval -50,20] [%emt 0:00:41]} Qd4 {(Nd5) [%eval 18,22] [%emt 0:00:33]}
29. g3 {(g3) [%eval -53,20] [%emt 0:00:57]} b6 {
(Ng4) [%eval 11,22] [%emt 0:00:55]} 30. Rc8+ {(Rc4) [%eval 0,20] [%emt 0:00:40]
} Kf7 {(Kf7) [%eval 0,24] [%emt 0:00:26]} 31. Qe2 {
(Qe2) [%eval -22,20] [%emt 0:01:31]} Qd2 {(Qa1) [%eval 0,23] [%emt 0:00:47]}
32. Kf1 {(Kf1) [%eval 0,21] [%emt 0:00:34]} e5 {
(e5) [%eval 0,24] [%emt 0:00:31]} 33. Qxd2 {(Qc4) [%eval 0,20] [%emt 0:00:47]}
Rxd2 {(Rxd2) [%eval 0,28] [%emt 0:00:28]} 34. Rc7+ {
(Rc7) [%eval 0,21] [%emt 0:00:32]} Rd7 {(Rd7) [%eval 0,29] [%emt 0:00:52]} 35.
Rc6 {(Rc6) [%eval 0,22] [%emt 0:00:33]} Ke7 {(Rd2) [%eval 0,29] [%emt 0:00:43]}
36. Ke2 {(Ke2) [%eval 0,21] [%emt 0:00:35]} Rd4 {
(Rd6) [%eval 0,28] [%emt 0:00:54]} 37. Rc7+ {(Rc7) [%eval 0,20] [%emt 0:00:31]}
Rd7 {(Rd7) [%eval 0,34] [%emt 0:00:31]} 38. Rc8 {
(Rc6) [%eval 0,21] [%emt 0:00:23]} Kd6 {(Kd6) [%eval 0,25] [%emt 0:00:34]} 39.
h3 {(Ke3) [%eval 0,20] [%emt 0:00:17]} Rc7 {(Rc7) [%eval 3,26] [%emt 0:00:44]}
40. Rxc7 {(Rxc7) [%eval 0,22] [%emt 0:00:53]} Kxc7 {
(Kxc7) [%eval 0,28] [%emt 0:00:40]} 41. Kf3 {(Kf3) [%eval 0,21] [%emt 0:00:34]}
Kd6 {(Kd6) [%eval 0,27] [%emt 0:00:21]} 42. Nd3 {
(Nd3) [%eval 0,20] [%emt 0:00:46]} a5 {(a5) [%eval 0,28] [%emt 0:00:24]} 43.
Ke3 {(b4) [%eval 0,21] [%emt 0:00:48]} g5 {(g5) [%eval 0,26] [%emt 0:00:26]}
44. a3 {(b4) [%eval 0,21] [%emt 0:00:45]} g4 {(g4) [%eval 9,32] [%emt 0:00:28]}
45. h4 {(h4) [%eval 0,22] [%emt 0:00:49]} h5 {(Nh5) [%eval 6,33] [%emt 0:00:34]
} 46. b4 {(Nb2) [%eval 0,22] [%emt 0:00:36]} a4 {
(axb4) [%eval 45,38] [%emt 0:00:34]} 47. Nb2 {
(Nb2) [%eval -12,25] [%emt 0:00:54]} b5 {(b5) [%eval 37,40] [%emt 0:00:29]} 48.
Nd1 {(Nd1) [%eval -11,26] [%emt 0:00:52]} Kc6 {
(Kc6) [%eval 34,42] [%emt 0:00:31]} 49. Nf2 {
(Nc3) [%eval -12,25] [%emt 0:00:30]} Nd7 {(Nd7) [%eval 79,40] [%emt 0:00:30]}
50. Nd3 {(Nd3) [%eval -57,25] [%emt 0:00:35]} Kd6 {
(Kd6) [%eval 70,39] [%emt 0:00:27]} 51. Ke2 {
(Nb2) [%eval -86,26] [%emt 0:00:35]} Nb6 {(Nb6) [%eval 70,41] [%emt 0:01:24]}
52. Nb2 {(Nb2) [%eval -80,27] [%emt 0:01:17]} Ke7 {
(Ke7) [%eval 60,41] [%emt 0:01:59]} 53. Ke3 {
(Ke3) [%eval -87,26] [%emt 0:00:26]} Kf6 {(Ke8) [%eval 67,45] [%emt 0:01:47]}
54. Ke2 {(Kd3) [%eval -87,27] [%emt 0:00:55]} Nc8 {
(Kf7) [%eval 48,44] [%emt 0:01:25]} 55. Nd1 {
(Kd3) [%eval -85,26] [%emt 0:00:33]} Nd6 {(Nd6) [%eval 77,43] [%emt 0:01:23]}
56. Nc3 {(Nc3) [%eval -88,25] [%emt 0:00:32]} Ke6 {
(Ke7) [%eval 69,40] [%emt 0:00:33]} 57. Kd1 {
(Kd3) [%eval -87,25] [%emt 0:00:29]} Ke7 {(Kd7) [%eval 65,40] [%emt 0:00:55]}
58. Kc1 {(Kc1) [%eval -87,25] [%emt 0:00:33]} Kd8 {
(Kd7) [%eval 76,40] [%emt 0:00:27]} 59. Kb2 {
(Kb1) [%eval -85,26] [%emt 0:00:50]} Kc8 {(Kc7) [%eval 69,40] [%emt 0:00:34]}
60. Kc2 {(Ka2) [%eval -85,26] [%emt 0:00:32]} Kd7 {
(Kd7) [%eval 60,39] [%emt 0:00:23]} 61. Kb2 {
(Kb2) [%eval -85,26] [%emt 0:01:09]} Nc4+ {(Kc7) [%eval 64,37] [%emt 0:00:16]}
62. Ka2 {(Ka2) [%eval -85,26] [%emt 0:00:46]} Nd2 {
(Nd2) [%eval 64,37] [%emt 0:00:20]} 63. Ka1 {
(Ka1) [%eval -85,26] [%emt 0:01:27]} Nf1 {(Nf1) [%eval 67,37] [%emt 0:00:16]}
64. Ne2 {(Ne2) [%eval -85,26] [%emt 0:00:29]} Ke8 {
(Kc6) [%eval 56,35] [%emt 0:00:17]} 65. Ka2 {
(Kb2) [%eval -85,26] [%emt 0:00:30]} Ke7 {(Kd8) [%eval 43,37] [%emt 0:00:26]}
66. Kb2 {(Kb2) [%eval -85,26] [%emt 0:00:22]} Kd8 {
(Kd6) [%eval 56,37] [%emt 0:00:35]} 67. Kc3 {
(Kc2) [%eval -85,25] [%emt 0:00:30]} Kd7 {(Kc7) [%eval 42,38] [%emt 0:00:31]}
68. Kd3 {(Kb2) [%eval -85,25] [%emt 0:00:26]} Kc6 {
(Kc6) [%eval 49,38] [%emt 0:00:45]} 69. Kc3 {
(Kc2) [%eval -85,25] [%emt 0:00:44]} Ne3 {(Kc7) [%eval 36,37] [%emt 0:00:32]}
70. Kb2 {(Kb2) [%eval -85,24] [%emt 0:00:21]} Nc4+ {
(Nc4) [%eval 38,38] [%emt 0:00:34]} 71. Ka2 {
(Ka2) [%eval -85,25] [%emt 0:00:36]} Nd2 {(Nd2) [%eval 48,37] [%emt 0:00:19]}
72. Nc3 {(Nc3) [%eval -85,25] [%emt 0:00:21]} Nf1 {
(Nf1) [%eval 46,37] [%emt 0:00:25]} 73. Ne2 {
(Ne2) [%eval -85,26] [%emt 0:00:25]} Kb7 {(Kc7) [%eval 46,39] [%emt 0:00:22]}
74. Kb2 {(Ka1) [%eval -85,25] [%emt 0:00:23]} Kc7 {
(Kc7) [%eval 22,38] [%emt 0:00:30]} 75. Kc3 {
(Kc1) [%eval -85,25] [%emt 0:00:23]} Ne3 {(Ne3) [%eval 32,35] [%emt 0:00:23]}
76. Kb2 {(Kb2) [%eval -85,25] [%emt 0:00:29]} Nc4+ {
(Nc4) [%eval 25,37] [%emt 0:00:22]} 77. Ka2 {
(Ka2) [%eval -85,26] [%emt 0:00:22]} Kc6 {(Nd6) [%eval 18,39] [%emt 0:00:50]}
78. Nc3 {(Nc3) [%eval -85,25] [%emt 0:00:16]} Nd2 {
(Ne3) [%eval 0,40] [%emt 0:00:50]} 79. Ka1 {(Kb2) [%eval -85,25] [%emt 0:00:12]
} Nf1 {(Nf1) [%eval 0,42] [%emt 0:00:50]} 80. Ne2 {
(Ne2) [%eval -85,26] [%emt 0:00:37]} Ne3 {(Kd7) [%eval 0,43] [%emt 0:00:17]}
81. Kb2 {(Kb2) [%eval 0,27] [%emt 0:00:55]} Ng2 {
(hashfull) [%eval 0,41] [%emt 0:00:38]} 82. Kc3 {
(Nc3) [%eval 0,27] [%emt 0:00:53]} Ne3 {(Ne3) [%eval 0,57] [%emt 0:00:23]} 83.
Kb2 {[%eval 0,27] [%emt 0:01:16]} 1/2-1/2
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Looking for pgn format converter tool

Post by tpetzke »

Does anyone know of what is (Kd7) in the ff.
Just a guess, it might be the previously reported ponder move, so the move the other engine thought will be played.
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Looking for pgn format converter tool

Post by stegemma »

I should write a complete pgn translator, to handle any case. It would be not the best choice, to add other exceptions to the pre-compiler... it would becomes very unreadable ;)