From: Dr. David Kirkby on
Further to my previous message on processing PGN files, I have another
problem. I want to get my own chess rating (it uses a system called
Elo) from a list of my own games in PGN format.

The user name of the players is given by the two fields White and
Black:

[White "black-river"]
[Black "g8wrb"]

and the rating by two fields WhiteElo and BlackElo.

[WhiteElo "1507"]
[BlackElo "1606"]

(the latter two are not part of the PGN standard, but they exist on
the games I have).

Since my username is g8wrb, and g8wrb was black, I need to extract the
BlackElo, which is 1606. Conversely, if I'm white, I want to extract
the WhiteElo. So in the two games below, my rating was 1606 on the
first, and 1594 on the second. Any suggestions how I might print the
BlackElo if g8wrb is black, but print the WhiteElo if g8wrb is white?



[Event "ICC 60 0 (standard)"]
[Site "Internet Chess Club"]
[Date "2010.04.09"]
[Round "-"]
[White "black-river"]
[Black "g8wrb"]
[Result "0-1"]
[WhiteElo "1507"]
[BlackElo "1606"]
[ECO "A02"]
[NIC "VO.07"]
[Opening "Bird: From gambit"]
[TimeControl "3600+0"]
[Time "19:17:13"]
[ICCResult "White resigns"]

1. f4 e5 2. fxe5 d5 3. d4 c5 4. e3 Nc6 5. Nf3 Bg4 6. Bb5 Qh4+ 7. g3
Bxf3 8.
Qxf3 Qh6 9. e4 Qxc1+ 10. Ke2 Qxc2+ 11. Nd2 dxe4 { White resigns } 0-1

[Event "ICC 20 20 (standard)"]
[Site "Internet Chess Club"]
[Date "2010.04.09"]
[Round "-"]
[White "Green-Pigeon"]
[Black "g8wrb"]
[Result "1-0"]
[WhiteElo "1713"]
[BlackElo "1594"]
[ECO "A28"]
[NIC "EO.07"]
[Opening "English: four knights, Capablanca variation"]
[TimeControl "1200+20"]
[Time "20:07:11"]
[ICCResult "Black resigns"]

1. Nf3 Nf6 2. c4 Nc6 3. Nc3 e5 4. d3 Bc5 5. g3 Ng4 6. e3 O-O 7. Bg2 d6
8.
O-O Bf5 9. Na4 Re8 10. Nxc5 dxc5 11. e4 Be6 12. h3 Nf6 13. Be3 Nd4 14.
Nxd4
cxd4 15. Bg5 h6 16. Bd2 Qd7 17. Kh2 b6 18. f4 Qd6 19. fxe5 Qxe5 20.
Bf4 Qc5
21. e5 Nd7 22. Bxa8 Rxa8 23. Qf3 Rb8 24. a3 Nxe5 25. Bxe5 Qxe5 26.
Rae1 Qd6
27. b4 Qd7 28. h4 c5 29. b5 Bg4 30. Qe4 Be6 31. a4 Re8 32. Qg2 Kf8 33.
Qe4
Kg8 34. Rf2 Qc7 35. Qg2 Rf8 36. Qf1 Qe7 37. Qg2 Qd7 38. Ref1 Qe7 39.
Qe4
Qd7 40. Rf4 Qe7 41. R1f2 Qd7 42. g4 Qe7 43. Kg3 Qc7 44. Kf3 Qe7 45.
Rh2 Qd7
46. g5 h5 47. Kg3 Qc7 48. Rf2 Qe7 49. Qe5 Qd7 50. g6 f5 51. Re2 Rf6
52. Kh2
Rxg6 53. Re1 Qb7 54. Qe2 Qc7 55. Rf1 Qd6 56. Qxh5 Rh6 57. Qg5 Qc7 58.
Rg1
Kh7 59. Kh3 Qe5 60. h5 Qe3+ 61. Rg3 Qe5 62. Kh4 Qf6 63. Qxf6 Rxf6 64.
Rg1
Kh6 65. Rf2 Bf7 66. Rfg2 Bxh5 67. Rxg7 Rf7 68. Rg8 Bg4 69. Re1 Kh7 70.
Rge8
Kg7 71. Kg5 Kh7 72. R8e7 Kg7 73. R1e6 Kf8 74. Re8+ Kg7 75. a5 bxa5 76.
Ra6
Rb7 77. Rxa5 Kf7 78. Re1 Rd7 79. Re5 Rc7 80. Ra6 Kg7 81. Rc6 Rxc6 82.
bxc6
Bh3 83. c7 f4 84. Kxf4 a5 85. Rxc5 a4 86. c8=Q Bxc8 87. Rxc8 Kf7 88.
Ra8 {
Black resigns } 1-0
From: Chris F.A. Johnson on
On 2010-04-13, Dr. David Kirkby wrote:
> Further to my previous message on processing PGN files, I have another
> problem. I want to get my own chess rating (it uses a system called
> Elo) from a list of my own games in PGN format.
>
> The user name of the players is given by the two fields White and
> Black:
>
> [White "black-river"]
> [Black "g8wrb"]
>
> and the rating by two fields WhiteElo and BlackElo.
>
> [WhiteElo "1507"]
> [BlackElo "1606"]
>
> (the latter two are not part of the PGN standard, but they exist on
> the games I have).
>
> Since my username is g8wrb, and g8wrb was black, I need to extract the
> BlackElo, which is 1606. Conversely, if I'm white, I want to extract
> the WhiteElo. So in the two games below, my rating was 1606 on the
> first, and 1594 on the second. Any suggestions how I might print the
> BlackElo if g8wrb is black, but print the WhiteElo if g8wrb is white?

Take a look at the awk script I use:
<http://cfaj/cfajohnson.com/shell/scripts/fics-stats.awk>


--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====