Skip to content

Conversation

@alwey
Copy link
Contributor

@alwey alwey commented Feb 5, 2022

In issue #662 a more readable PGN output has been requested. Usually PGN outputs are listing more than one move per line and the line width limited to 80 characters. This patch provides a method to optionally list one full move per line with aligned columns.

A context menu item "Copy with PGN header" is added to the context menu of the MoveList. The output is copied to the application clipboard.

The patch adds a lambda expression to MoveList::MoveList to copy the game's PGN header and a formatted move list to the clipboard. The move comments are omitted if the are hidden in the MoveList.

An alignment flag is introduced as method parameter to the two PgnGame::write() methods.

Resolves #662

A new menu item "Copy with PGN header" is added to the move list's context menu (right-click).
l4

Example: original PGN format

[Event "?"]
[Site "?"]
[Date "2022.02.05"]
[Round "?"]
[White "aice_0922"]
[Black "k2_v.087_64"]
[Result "0-1"]
[ECO "C25"]
[GameDuration "00:01:14"]
[GameEndTime "2022-02-05T10:55:09.944 CET"]
[GameStartTime "2022-02-05T10:53:55.227 CET"]
[Opening "Vienna game"]
[PlyCount "98"]
[TimeControl "30+0.3"]

1. e4 {+0.33/8 0.52s} e5 {-0.21/11 1.2s} 2. Nc3 {+0.64/7 0.61s}
Bc5 {-0.28/12 3.8s} 3. Nf3 {+0.11/8 1.6s} Nc6 {-0.51/12 3.5s}
4. Nxe5 {+0.45/8 1.0s} Nxe5 {-0.56/11 1.1s} 5. d4 {+0.78/9 0.83s}
Bd6 {-0.29/11 0.94s} 6. dxe5 {+0.64/9 1.2s} Bxe5 {-0.26/11 3.0s}
7. Be3 {+0.60/8 1.6s} Nf6 {-0.19/10 0.77s} 8. Bd4 {+0.30/8 1.5s}
Qe7 {-0.17/10 0.65s} 9. Bc4 {+0.46/8 0.92s} d6 {-0.23/10 0.79s}
10. O-O {+0.43/7 0.79s} O-O {-0.13/10 0.65s} 11. Nd5 {+0.29/8 1.4s}
Nxd5 {+0.04/12 1.2s} 12. Bxd5 {+0.28/9 1.3s} c6 {+0.04/12 1.4s}
13. Bb3 {+0.26/8 0.93s} Qg5 {+0.09/11 1.5s} 14. Bxe5 {+0.24/7 0.67s}
Qxe5 {+0.04/11 0.66s} 15. f3 {+0.23/8 1.2s} Re8 {+0.07/11 0.69s}
16. c3 {+0.27/8 0.62s} Be6 {+0.10/12 0.66s} 17. Rf2 {+0.27/8 1.1s}
Qc5 {+0.10/10 1.1s} 18. Bxe6 {+0.19/9 1.0s} Rxe6 {+0.07/12 0.48s}
19. Qb3 {+0.18/10 1.1s} b6 {+0.08/12 0.94s} 20. Rd1 {+0.29/9 0.93s}
d5 {+0.03/11 0.96s} 21. exd5 {+0.24/9 0.85s} cxd5 {0.00/11 0.42s}
22. g3 {+0.28/8 0.46s} Rae8 {+0.23/10 0.41s} 23. Kg2 {+0.33/8 1.0s}
Re2 {+0.01/11 0.59s} 24. Rd4 {+0.69/7 0.43s} Qe7 {-0.02/11 0.67s}
25. Rd2 {+0.70/9 1.1s} Rxf2+ {-0.10/10 0.44s} 26. Rxf2 {+0.51/9 0.68s}
Qc5 {0.00/12 0.80s} 27. Rd2 {+0.56/9 0.75s} g6 {-0.06/11 0.60s}
28. Qa4 {+0.66/7 0.47s} Re1 {+0.12/12 0.69s} 29. Rf2 {+0.45/7 0.53s}
a5 {+0.17/10 0.37s} 30. a3 {+0.52/7 0.43s} Qe3 {+0.38/10 0.39s}
31. Qb5 {+0.46/8 0.71s} d4 {+0.42/10 0.55s} 32. cxd4 {+0.03/8 0.65s}
Qxd4 {+0.48/11 0.46s} 33. f4 {-0.04/8 0.71s} Kf8 {+0.90/9 0.51s}
34. Re2 {+0.12/7 0.35s} Qg1+ {+1.66/11 0.39s} 35. Kf3 {+0.09/7 0.38s}
Qf1+ {+1.31/11 0.40s} 36. Ke3 {0.00/7 0.33s} f5 {+0.87/11 0.63s}
37. Kd2 {0.00/8 0.33s} Rd1+ {+0.90/12 0.74s} 38. Kc3 {0.00/8 0.31s}
Rc1+ {+1.25/12 0.74s} 39. Kd4 {0.00/8 0.34s} Qg1+ {+1.25/12 0.66s}
40. Kd3 {0.00/9 0.64s} Rc8 {+0.79/12 2.0s} 41. a4 {-0.93/7 0.47s}
Qc1 {+1.51/9 0.30s} 42. Kd4 {-3.83/8 0.57s} Rd8+ {+5.99/10 0.31s}
43. Qd5 {-14.16/7 0.72s} Qc5+ {+M13/11 0.21s} 44. Ke5 {-319.98/8 0.28s}
Qxd5+ {+M11/11 0.076s} 45. Kf6 {-14.17/5 0.021s} h6 {+M9/12 0.13s}
46. Re8+ {-319.99/12 0.31s} Rxe8 {+M7/13 0.059s} 47. Kxg6 {-319.99/18 0.28s}
Re6+ {+M5/16 0.060s} 48. Kh5 {-319.99/41 0.063s} Qd1+ {+M3/81 0.056s}
49. g4 {-319.99/41 0.002s} Qxg4# {+M1/100 0.043s, Black mates} 0-1


...

The same game with aligned PGN output obtained from clipboard after clicking the new menu item:

[Event "?"]
[Site "?"]
[Date "2022.02.05"]
[Round "?"]
[White "aice_0922"]
[Black "k2_v.087_64"]
[Result "0-1"]
[ECO "C25"]
[GameDuration "00:01:14"]
[GameEndTime "2022-02-05T10:55:09.944 CET"]
[GameStartTime "2022-02-05T10:53:55.227 CET"]
[Opening "Vienna game"]
[PlyCount "98"]
[TimeControl "30+0.3"]

1. e4        {+0.33/8 0.52s}         e5           {-0.21/11 1.2s}
2. Nc3       {+0.64/7 0.61s}         Bc5          {-0.28/12 3.8s}
3. Nf3       {+0.11/8 1.6s}          Nc6          {-0.51/12 3.5s}
4. Nxe5      {+0.45/8 1.0s}          Nxe5         {-0.56/11 1.1s}
5. d4        {+0.78/9 0.83s}         Bd6          {-0.29/11 0.94s}
6. dxe5      {+0.64/9 1.2s}          Bxe5         {-0.26/11 3.0s}
7. Be3       {+0.60/8 1.6s}          Nf6          {-0.19/10 0.77s}
8. Bd4       {+0.30/8 1.5s}          Qe7          {-0.17/10 0.65s}
9. Bc4       {+0.46/8 0.92s}         d6           {-0.23/10 0.79s}
10. O-O      {+0.43/7 0.79s}         O-O          {-0.13/10 0.65s}
11. Nd5      {+0.29/8 1.4s}          Nxd5         {+0.04/12 1.2s}
12. Bxd5     {+0.28/9 1.3s}          c6           {+0.04/12 1.4s}
13. Bb3      {+0.26/8 0.93s}         Qg5          {+0.09/11 1.5s}
14. Bxe5     {+0.24/7 0.67s}         Qxe5         {+0.04/11 0.66s}
15. f3       {+0.23/8 1.2s}          Re8          {+0.07/11 0.69s}
16. c3       {+0.27/8 0.62s}         Be6          {+0.10/12 0.66s}
17. Rf2      {+0.27/8 1.1s}          Qc5          {+0.10/10 1.1s}
18. Bxe6     {+0.19/9 1.0s}          Rxe6         {+0.07/12 0.48s}
19. Qb3      {+0.18/10 1.1s}         b6           {+0.08/12 0.94s}
20. Rd1      {+0.29/9 0.93s}         d5           {+0.03/11 0.96s}
21. exd5     {+0.24/9 0.85s}         cxd5         {0.00/11 0.42s}
22. g3       {+0.28/8 0.46s}         Rae8         {+0.23/10 0.41s}
23. Kg2      {+0.33/8 1.0s}          Re2          {+0.01/11 0.59s}
24. Rd4      {+0.69/7 0.43s}         Qe7          {-0.02/11 0.67s}
25. Rd2      {+0.70/9 1.1s}          Rxf2+        {-0.10/10 0.44s}
26. Rxf2     {+0.51/9 0.68s}         Qc5          {0.00/12 0.80s}
27. Rd2      {+0.56/9 0.75s}         g6           {-0.06/11 0.60s}
28. Qa4      {+0.66/7 0.47s}         Re1          {+0.12/12 0.69s}
29. Rf2      {+0.45/7 0.53s}         a5           {+0.17/10 0.37s}
30. a3       {+0.52/7 0.43s}         Qe3          {+0.38/10 0.39s}
31. Qb5      {+0.46/8 0.71s}         d4           {+0.42/10 0.55s}
32. cxd4     {+0.03/8 0.65s}         Qxd4         {+0.48/11 0.46s}
33. f4       {-0.04/8 0.71s}         Kf8          {+0.90/9 0.51s}
34. Re2      {+0.12/7 0.35s}         Qg1+         {+1.66/11 0.39s}
35. Kf3      {+0.09/7 0.38s}         Qf1+         {+1.31/11 0.40s}
36. Ke3      {0.00/7 0.33s}          f5           {+0.87/11 0.63s}
37. Kd2      {0.00/8 0.33s}          Rd1+         {+0.90/12 0.74s}
38. Kc3      {0.00/8 0.31s}          Rc1+         {+1.25/12 0.74s}
39. Kd4      {0.00/8 0.34s}          Qg1+         {+1.25/12 0.66s}
40. Kd3      {0.00/9 0.64s}          Rc8          {+0.79/12 2.0s}
41. a4       {-0.93/7 0.47s}         Qc1          {+1.51/9 0.30s}
42. Kd4      {-3.83/8 0.57s}         Rd8+         {+5.99/10 0.31s}
43. Qd5      {-14.16/7 0.72s}        Qc5+         {+M13/11 0.21s}
44. Ke5      {-319.98/8 0.28s}       Qxd5+        {+M11/11 0.076s}
45. Kf6      {-14.17/5 0.021s}       h6           {+M9/12 0.13s}
46. Re8+     {-319.99/12 0.31s}      Rxe8         {+M7/13 0.059s}
47. Kxg6     {-319.99/18 0.28s}      Re6+         {+M5/16 0.060s}
48. Kh5      {-319.99/41 0.063s}     Qd1+         {+M3/81 0.056s}
49. g4       {-319.99/41 0.002s}     Qxg4#        {+M1/100 0.043s, Black mates}
0-1


...

Aligned output obtained after the move comments have been hidden in the move list window. The minimal output format and headers are used. The moves are listed with exactly one full move per line

[Event "?"]
[Site "?"]
[Date "2022.02.05"]
[Round "?"]
[White "aice_0922"]
[Black "k2_v.087_64"]
[Result "0-1"]

1. e4        e5
2. Nc3       Bc5
3. Nf3       Nc6
4. Nxe5      Nxe5
5. d4        Bd6
6. dxe5      Bxe5
7. Be3       Nf6
8. Bd4       Qe7
9. Bc4       d6
10. O-O      O-O
11. Nd5      Nxd5
12. Bxd5     c6
13. Bb3      Qg5
14. Bxe5     Qxe5
15. f3       Re8
16. c3       Be6
17. Rf2      Qc5
18. Bxe6     Rxe6
19. Qb3      b6
20. Rd1      d5
21. exd5     cxd5
22. g3       Rae8
23. Kg2      Re2
24. Rd4      Qe7
25. Rd2      Rxf2+
26. Rxf2     Qc5
27. Rd2      g6
28. Qa4      Re1
29. Rf2      a5
30. a3       Qe3
31. Qb5      d4
32. cxd4     Qxd4
33. f4       Kf8
34. Re2      Qg1+
35. Kf3      Qf1+
36. Ke3      f5
37. Kd2      Rd1+
38. Kc3      Rc1+
39. Kd4      Qg1+
40. Kd3      Rc8
41. a4       Qc1
42. Kd4      Rd8+
43. Qd5      Qc5+
44. Ke5      Qxd5+
45. Kf6      h6
46. Re8+     Rxe8
47. Kxg6     Re6+
48. Kh5      Qd1+
49. g4       Qxg4# 0-1

…board.

The move comments are omitted if not shown in the MoveList.

Introduce an alignment flag to the two PgnGame::write() methods.

Resolves cutechess#662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

readable game output

1 participant