fsmosca / Python-Chess-Scripts

Tools to process things using python chess library.
GNU General Public License v3.0
1 stars 1 forks source link

Is it possible to do this? Program takes a game , and adds PGN headers with the computed "Eval" for each player. Preserves a game with the added headers. #13

Open DominoA4 opened 3 years ago

DominoA4 commented 3 years ago

Example: [Event "Blitz"] [Site "St. Louis, MO USA"] [Date "2016.04.29"] [Round "18.1"] [White "Fabiano Caruana"] [Black "Garry Kasparov"] [Result "0-1"] [EventDate "2016.04.28"] [WhiteElo "2795"] [BlackElo "2812"] [PlyCount "74"] [WMaxEval= 0.00] [BMaxEval = 0.00] [WMinEval = 0.00] [BMinEval = 0.00]

fsmosca commented 3 years ago

I will implement it this weekend.

fsmosca commented 3 years ago

eval_swing v0.4.0 has implementation, please try it.

DominoA4 commented 3 years ago

It almost worked out. The error got out:

Traceback (most recent call last): File "eval_swing.py", line 424, in main() File "eval_swing.py", line 420, in main a.run() File "eval_swing.py", line 368, in run df = self.evaluate(game, cnt) File "eval_swing.py", line 344, in evaluate my_game.headers['BlackMaxEval'] = str(max(self.b_max_eval)) TypeError: '>' not supported between instances of 'NoneType' and 'float'

Moves are cut for some reason. Link to the original PGN and the result: https://pixeldrain.com/u/tg8h6E1j

Error with another PGN:

Traceback (most recent call last): File "eval_swing.py", line 424, in main() File "eval_swing.py", line 420, in main a.run() File "eval_swing.py", line 368, in run df = self.evaluate(game, cnt) File "eval_swing.py", line 343, in evaluate my_game.headers['WhiteMaxEval'] = str(max(self.w_max_eval)) TypeError: '>' not supported between instances of 'NoneType' and 'float'

DominoA4 commented 3 years ago

Everything is working! Thank you. The error disappears if you remove the winning games from the PGN.

DominoA4 commented 3 years ago

Eval in out_1.pgn and output.txt files do not match Link: https://pixeldrain.com/u/BdaqVMxT

fsmosca commented 3 years ago

Try the latest v0.5.0, it includes fixing errors in getting WhiteMaxEval etc. for the header.

Process procedure

  1. Your need to convert the games in the pgn file into a long sequence of moves using pgn-extract. This way values are properly read by the parser.

Command line:
pgn-extract -w10000 -oMygames_output.pgn Mygames.pgn

Example:

[Event "Sunday 25 April Rapid, 16m+1s, 17 ROUND"]
[Site "Machines A"]
[Date "2021.04.25"]
[Round "1"]
[White "Pooper Scooper#, SugaR AI Ext"]
[Black "Lynnett, Raubfisch X44_nn_sl"]
[Result "1/2-1/2"]
[WhiteElo "2450"]
[BlackElo "2464"]
[EventDate "2021.04.25"]
[PlyCount "30"]
[EventType "swiss (rapid)"]

1. c4 { [%eval 0,0] [%emt 0:00:00] } 1... e5 { [%eval 0,0] [%emt 0:00:00] } 2. Nc3 { [%eval 0,0] [%emt 0:00:00] } 2... Nf6 { [%eval 0,0] [%emt 0:00:00] } 3. Nf3 { [%eval 0, 0] [%emt 0:00:00] } 3... Nc6 { [%eval 0,0] [%emt 0:00:00] } 4. e3 { [%eval 0,0] [%emt 0: 00:00] } 4... Bb4 { [%eval 0,0] [%emt 0:00:00] } 5. Qc2 { [%eval 0,0] [%emt 0:00:00] } 5... Bxc3 { [%eval 0,0] [%emt 0:00:00] } 6. bxc3 { [%eval 0,0] [%emt 0:00:00] } 6... O-O { [%eval 0,0] [%emt 0:00:00] } 7. Be2 { [%eval 0,0] [%emt 0:00:00] } 7... d6 { [%eval 0,0] [%emt 0:00:00] } 8. e4 { [%eval 0,37] [%emt 0:00:18] } 8... Nh5 { [%eval 0,0] [%emt 0: 00:00] (b6) } 9. d4 { [%eval 0,39] [%emt 0:00:07] } 9... Qf6 { [%eval 0,0] [%emt 0:00: 00] } 10. g3 { [%eval 0,40] [%emt 0:00:10] } 10... exd4 { [%eval 0,49] [%emt 0:00:27] } 11. Nxd4 { [%eval 0,49] [%emt 0:00:00] } 11... Nxd4 { [%eval 0,49] [%emt 0:00:16] } 12. cxd4 { [%eval 0,52] [%emt 0:00:00] } 12... Qxd4 { [%eval 0,48] [%emt 0:00:13] } 13. Bb2 { [%eval 0,52] [%emt 0:00:01] } 13... Qc5 { [%eval 0,50] [%emt 0:00:15] } 14. e5 { [%eval 0,53] [%emt 0:00:05] } 14... g6 { [%eval 0,49] [%emt 0:00:10] } 15. Qd2 { [%eval 0,51] [%emt 0:00:10] } 15... Qc6 { [%eval 0,50] [%emt 0:00:34] } 1/2-1/2
  1. The pgn-extract may output below format.
[Event "Sunday 25 April Rapid, 16m+1s, 17 ROUND"]
[Site "Machines A"]
[Date "2021.04.25"]
[Round "6"]
[White "N~/= 1, SugaR AI 200421 sse"]
[Black "Fulcrum2000, Stockfish dev"]
[Result "1/2-1/2"]
[WhiteElo "2463"]
[BlackElo "2458"]
[EventDate "2021.04.25"]
[PlyCount "140"]
[EventType "swiss (rapid)"]

{ White restart ok. Black restart ok. }

1. e4 { [%eval 24,43] [%emt 0:00:04] } 1... e5 { [%eval 0,0] } 2. Nf3 { [%eval 24,41] } 2... Nc6 { [%eval 0,0] [%emt 0:00:00] } 3. Bb5 { [%eval 25,38] [%emt 0:00:00] } 3... Nf6 { [%eval 0,0] [%emt 0:00:00] } 4. O-O { [%eval 20,39] } 4... Nxe4 { [%eval 0,0] [%emt 0:00:00] } 5. Re1 { [%eval 17,38] } 5... Nd6 { [%eval 0, 0] } 6. Nxe5 { [%eval 19,38] } 6... Be7 { [%eval 0,0] } 7. Bf1 { [%eval 17,39] } 7... Nxe5 { [%eval 0,0] } 8. Rxe5 { [%eval 14,39] } 8... O-O { [%eval 0,0] } 9. d4 { [%eval 11,41] } 9... Bf6 { [%eval 0,0] } 10. Re1 { [%eval 15,41] } 10... Re8 { [%eval 0,0] [%emt 0:00:00] } 11. c3 { [%eval 11,44] } 11... Rxe1 { [%eval 0,0] } 12. Qxe1 { [%eval 14,36] } 12... Nf5 { [%eval 0,0] } 13. Bf4 { [%eval 24,33] } 13... d6 { [%eval 0,0] [%emt 0:00:00] } 14. Bd3 { [%eval 18, 33] } 14... Be6 { [%eval 0,0] } 15. Nd2 { [%eval 20,31] } 15... g6 { [%eval 0,0] } 16. Qe2 { [%eval 16,40] } 16... Ng7 { [%eval 13,40] [%emt 0:00:38] } 17. Qf3 { [%eval 16,25] [%emt 0:00:00] (Ne4) } 17... c6 { [%eval 6,41] [%emt 0:00:17] } 18. Re1 { [%eval 8,38] [%emt 0: 00:39] } 18... Bd5 { [%eval 13,42] [%emt 0:00:35] (d5) } 19. Qd1 { [%eval 17,41] [%emt 0: 00:41] } 19... Bg5 { [%eval 0,50] [%emt 0:00:00] } 20. Be3 { [%eval 13,40] [%emt 0:00:26] (Bxg5) } 20... Bxe3 { [%eval 0,49] [%emt 0:00:16] } 21. fxe3 { [%eval 0,46] [%emt 0:00: 10] } 21... Qb6 { [%eval 0,53] [%emt 0:00:10] } 22. c4 { [%eval 0,53] [%emt 0:00:13] } 22... Be6 { [%eval 0,54] [%emt 0:00:04] } 23. Qb3 { [%eval 0,54] [%emt 0:00:13] } 23... d5 { [%eval 0,52] [%emt 0:00:08] } 24. Qxb6 { [%eval 0,51] [%emt 0:00:09] } 24... axb6 { [%eval 0,58] [%emt 0:00:16] } 25. a3 { [%eval 0,56] [%emt 0:00:33] } 25... f5 { [%eval 0, 59] [%emt 0:00:00] } 26. cxd5 { [%eval 0,55] [%emt 0:00:11] } 26... Bxd5 { [%eval 0,62] [%emt 0:00:07] } 27. e4 { [%eval 0,55] [%emt 0:00:09] } 27... fxe4 { [%eval 0,61] [%emt 0:00:45] } 28. Bxe4 { [%eval 0,57] [%emt 0:00:01] (Nxe4) } 28... Bxe4 { [%eval 0,57] [%emt 0:00:23] } 29. Rxe4 { [%eval 0,53] [%emt 0:00:15] } 29... Kf7 { [%eval 0,57] [%emt 0:00:02] } 30. Nf3 { [%eval 0,60] [%emt 0:00:31] } 30... Nf5 { [%eval 0,59] [%emt 0:00: 00] } 31. g4 { [%eval 0,58] [%emt 0:00:51] (Ng5+) } 31... Nd6 { [%eval 0,65] [%emt 0:00: 17] } 32. Ng5+ { [%eval 0,63] [%emt 0:00:00] } 32... Kg7 { [%eval 0,65] [%emt 0:00:23] } 33. Re6 { [%eval 0,66] [%emt 0:00:00] (Re7+) } 33... Rd8 { [%eval 0,62] [%emt 0:00:18] } 34. Nf3 { [%eval 0,60] [%emt 0:00:18] } 34... Kf8 { [%eval 0,59] [%emt 0:00:00] } 35. a4 { [%eval 0,66] [%emt 0:00:22] } 35... Ne8 { [%eval 0,64] [%emt 0:00:00] } 36. Kf2 { [%eval 0,63] [%emt 0:00:14] (Re5) } 36... Nc7 { [%eval 0,67] [%emt 0:00:28] } 37. Re5 { [%eval 0,63] [%emt 0:00:00] } 37... Ra8 { [%eval 0,68] [%emt 0:00:22] } 38. b3 { [%eval 0,65] [%emt 0:00:00] } 38... b5 { [%eval 0,71] [%emt 0:00:21] } 39. axb5 { [%eval 0,62] [%emt 0:00:20] } 39... Nxb5 { [%eval 0,71] [%emt 0:00:00] (Ta2+) } 40. d5 { [%eval 0,70] [%emt 0:00:14] } 40... Nc3 { [%eval 0,71] [%emt 0:00:03] (Ta2+) } 41. dxc6 { [%eval 0,59] [%emt 0:00:23] } 41... bxc6 { [%eval 0,73] [%emt 0:00:00] } 42. Re6 { [%eval 0,56] [%emt 0:00:17] (Ke3) } 42... Rb8 { [%eval 0,66] [%emt 0:00:17] (Ta2+) } 43. Rxc6 { [%eval 0,62] [%emt 0:00:57] (Rf6+) } 43... Rxb3 { [%eval 0,78] [%emt 0:00:16] } 44. h4 { [%eval 0,67] [%emt 0:00:00] (Rc8+) } 44... Ke7 { [%eval 0,69] [%emt 0:00:16] (Tb2+) } 45. h5 { [%eval 0,65] [%emt 0:00:20] (Rc7+) } 45... gxh5 { [%eval 0,89] [%emt 0:00:16] (Se4+) } 46. gxh5 { [%eval 0,93] [%emt 0:00:13] } 46... h6 { [%eval 0,92] [%emt 0:00:02] (Se4+) } 47. Rxh6 { [%eval 0,83] [%emt 0:00:12] (Rc8) } 47... Ne4+ { [%eval 0,38] [%emt 0:00:43] (Tb2+) } 48. Ke1 { [%eval 0,102] [%emt 0:00:15] (Kg2) } 48... Rxf3 { [%eval 0,51] [%emt 0:00:14] (Tb1+) } 49. Rh8 { [%emt 0:00:00] (Ra6) } 49... Re3+ { [%eval -28000,0] [%emt 0: 00:00] } 50. Kd1 { [%emt 0:00:00] } 50... Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 51. Kc1 { [%emt 0:00:00] } 51... Rc3+ { [%eval -28000,0] [%emt 0:00:00] } 52. Kb2 { [%emt 0:00:00] } 52... Rd3 { [%eval -28000,0] [%emt 0:00:00] } 53. h6 { [%emt 0:00:00] } 53... Rd2+ { [%eval -28000,0] [%emt 0:00:00] } 54. Ka3 { [%emt 0:00:00] } 54... Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 55. Kb2 { [%emt 0:00:00] } 55... Rd2+ { [%eval -28000,0] [%emt 0:00:00] } 56. Ka3 Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 57. Kb4 Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 58. Kb5 { [%emt 0:00:00] } 58... Nd6+ { [%eval -28000,0] [%emt 0:00:00] } 59. Kb6 { [%emt 0:00:00] } 59... Nf7 { [%eval -28000,0] [%emt 0:00:00] } 60. Rh7 { [%emt 0:00:00] } 60... Rh4 { [%eval -28000,0] [%emt 0:00:00] } 61. Kb5 { [%emt 0:00:00] } 61... Kf6 { [%eval -28000,0] [%emt 0:00:00] } 62. Kc5 { [%emt 0:00:00] } 62... Nxh6 { [%eval -28000,0] [%emt 0:00:00] } 63. Rh8 { [%emt 0:00:00] } 63... Kg5 { [%eval -28000,0] [%emt 0:00:00] } 64. Kd5 { [%emt 0:00:00] } 64... Rg4 { [%eval -28000,0] [%emt 0:00:00] } 65. Ke6 { [%emt 0:00:00] } 65... Rf4 { [%eval -28000,0] [%emt 0:00:00] } 66. Re8 { [%emt 0:00: 00] } 66... Re4+ { [%eval -28000,0] [%emt 0:00:00] } 67. Kd7 { [%eval 0,1] } 67... Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 68. Ke6 { [%emt 0:00:00] } 68... Re4+ { [%eval -28000, 0] [%emt 0:00:00] } 69. Kd7 { [%eval 0,1] } 69... Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 70. Ke6 Re4+ { [%eval -28000,0] [%emt 0:00:00] } 1/2-1/2

Remove the space after "{ White restart ok. Black restart ok. }"

and it will become,

[Event "Sunday 25 April Rapid, 16m+1s, 17 ROUND"]
[Site "Machines A"]
[Date "2021.04.25"]
[Round "6"]
[White "N~/= 1, SugaR AI 200421 sse"]
[Black "Fulcrum2000, Stockfish dev"]
[Result "1/2-1/2"]
[WhiteElo "2463"]
[BlackElo "2458"]
[EventDate "2021.04.25"]
[PlyCount "140"]
[EventType "swiss (rapid)"]

{ White restart ok. Black restart ok. }
1. e4 { [%eval 24,43] [%emt 0:00:04] } 1... e5 { [%eval 0,0] } 2. Nf3 { [%eval 24,41] } 2... Nc6 { [%eval 0,0] [%emt 0:00:00] } 3. Bb5 { [%eval 25,38] [%emt 0:00:00] } 3... Nf6 { [%eval 0,0] [%emt 0:00:00] } 4. O-O { [%eval 20,39] } 4... Nxe4 { [%eval 0,0] [%emt 0:00:00] } 5. Re1 { [%eval 17,38] } 5... Nd6 { [%eval 0, 0] } 6. Nxe5 { [%eval 19,38] } 6... Be7 { [%eval 0,0] } 7. Bf1 { [%eval 17,39] } 7... Nxe5 { [%eval 0,0] } 8. Rxe5 { [%eval 14,39] } 8... O-O { [%eval 0,0] } 9. d4 { [%eval 11,41] } 9... Bf6 { [%eval 0,0] } 10. Re1 { [%eval 15,41] } 10... Re8 { [%eval 0,0] [%emt 0:00:00] } 11. c3 { [%eval 11,44] } 11... Rxe1 { [%eval 0,0] } 12. Qxe1 { [%eval 14,36] } 12... Nf5 { [%eval 0,0] } 13. Bf4 { [%eval 24,33] } 13... d6 { [%eval 0,0] [%emt 0:00:00] } 14. Bd3 { [%eval 18, 33] } 14... Be6 { [%eval 0,0] } 15. Nd2 { [%eval 20,31] } 15... g6 { [%eval 0,0] } 16. Qe2 { [%eval 16,40] } 16... Ng7 { [%eval 13,40] [%emt 0:00:38] } 17. Qf3 { [%eval 16,25] [%emt 0:00:00] (Ne4) } 17... c6 { [%eval 6,41] [%emt 0:00:17] } 18. Re1 { [%eval 8,38] [%emt 0: 00:39] } 18... Bd5 { [%eval 13,42] [%emt 0:00:35] (d5) } 19. Qd1 { [%eval 17,41] [%emt 0: 00:41] } 19... Bg5 { [%eval 0,50] [%emt 0:00:00] } 20. Be3 { [%eval 13,40] [%emt 0:00:26] (Bxg5) } 20... Bxe3 { [%eval 0,49] [%emt 0:00:16] } 21. fxe3 { [%eval 0,46] [%emt 0:00: 10] } 21... Qb6 { [%eval 0,53] [%emt 0:00:10] } 22. c4 { [%eval 0,53] [%emt 0:00:13] } 22... Be6 { [%eval 0,54] [%emt 0:00:04] } 23. Qb3 { [%eval 0,54] [%emt 0:00:13] } 23... d5 { [%eval 0,52] [%emt 0:00:08] } 24. Qxb6 { [%eval 0,51] [%emt 0:00:09] } 24... axb6 { [%eval 0,58] [%emt 0:00:16] } 25. a3 { [%eval 0,56] [%emt 0:00:33] } 25... f5 { [%eval 0, 59] [%emt 0:00:00] } 26. cxd5 { [%eval 0,55] [%emt 0:00:11] } 26... Bxd5 { [%eval 0,62] [%emt 0:00:07] } 27. e4 { [%eval 0,55] [%emt 0:00:09] } 27... fxe4 { [%eval 0,61] [%emt 0:00:45] } 28. Bxe4 { [%eval 0,57] [%emt 0:00:01] (Nxe4) } 28... Bxe4 { [%eval 0,57] [%emt 0:00:23] } 29. Rxe4 { [%eval 0,53] [%emt 0:00:15] } 29... Kf7 { [%eval 0,57] [%emt 0:00:02] } 30. Nf3 { [%eval 0,60] [%emt 0:00:31] } 30... Nf5 { [%eval 0,59] [%emt 0:00: 00] } 31. g4 { [%eval 0,58] [%emt 0:00:51] (Ng5+) } 31... Nd6 { [%eval 0,65] [%emt 0:00: 17] } 32. Ng5+ { [%eval 0,63] [%emt 0:00:00] } 32... Kg7 { [%eval 0,65] [%emt 0:00:23] } 33. Re6 { [%eval 0,66] [%emt 0:00:00] (Re7+) } 33... Rd8 { [%eval 0,62] [%emt 0:00:18] } 34. Nf3 { [%eval 0,60] [%emt 0:00:18] } 34... Kf8 { [%eval 0,59] [%emt 0:00:00] } 35. a4 { [%eval 0,66] [%emt 0:00:22] } 35... Ne8 { [%eval 0,64] [%emt 0:00:00] } 36. Kf2 { [%eval 0,63] [%emt 0:00:14] (Re5) } 36... Nc7 { [%eval 0,67] [%emt 0:00:28] } 37. Re5 { [%eval 0,63] [%emt 0:00:00] } 37... Ra8 { [%eval 0,68] [%emt 0:00:22] } 38. b3 { [%eval 0,65] [%emt 0:00:00] } 38... b5 { [%eval 0,71] [%emt 0:00:21] } 39. axb5 { [%eval 0,62] [%emt 0:00:20] } 39... Nxb5 { [%eval 0,71] [%emt 0:00:00] (Ta2+) } 40. d5 { [%eval 0,70] [%emt 0:00:14] } 40... Nc3 { [%eval 0,71] [%emt 0:00:03] (Ta2+) } 41. dxc6 { [%eval 0,59] [%emt 0:00:23] } 41... bxc6 { [%eval 0,73] [%emt 0:00:00] } 42. Re6 { [%eval 0,56] [%emt 0:00:17] (Ke3) } 42... Rb8 { [%eval 0,66] [%emt 0:00:17] (Ta2+) } 43. Rxc6 { [%eval 0,62] [%emt 0:00:57] (Rf6+) } 43... Rxb3 { [%eval 0,78] [%emt 0:00:16] } 44. h4 { [%eval 0,67] [%emt 0:00:00] (Rc8+) } 44... Ke7 { [%eval 0,69] [%emt 0:00:16] (Tb2+) } 45. h5 { [%eval 0,65] [%emt 0:00:20] (Rc7+) } 45... gxh5 { [%eval 0,89] [%emt 0:00:16] (Se4+) } 46. gxh5 { [%eval 0,93] [%emt 0:00:13] } 46... h6 { [%eval 0,92] [%emt 0:00:02] (Se4+) } 47. Rxh6 { [%eval 0,83] [%emt 0:00:12] (Rc8) } 47... Ne4+ { [%eval 0,38] [%emt 0:00:43] (Tb2+) } 48. Ke1 { [%eval 0,102] [%emt 0:00:15] (Kg2) } 48... Rxf3 { [%eval 0,51] [%emt 0:00:14] (Tb1+) } 49. Rh8 { [%emt 0:00:00] (Ra6) } 49... Re3+ { [%eval -28000,0] [%emt 0: 00:00] } 50. Kd1 { [%emt 0:00:00] } 50... Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 51. Kc1 { [%emt 0:00:00] } 51... Rc3+ { [%eval -28000,0] [%emt 0:00:00] } 52. Kb2 { [%emt 0:00:00] } 52... Rd3 { [%eval -28000,0] [%emt 0:00:00] } 53. h6 { [%emt 0:00:00] } 53... Rd2+ { [%eval -28000,0] [%emt 0:00:00] } 54. Ka3 { [%emt 0:00:00] } 54... Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 55. Kb2 { [%emt 0:00:00] } 55... Rd2+ { [%eval -28000,0] [%emt 0:00:00] } 56. Ka3 Rd3+ { [%eval -28000,0] [%emt 0:00:00] } 57. Kb4 Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 58. Kb5 { [%emt 0:00:00] } 58... Nd6+ { [%eval -28000,0] [%emt 0:00:00] } 59. Kb6 { [%emt 0:00:00] } 59... Nf7 { [%eval -28000,0] [%emt 0:00:00] } 60. Rh7 { [%emt 0:00:00] } 60... Rh4 { [%eval -28000,0] [%emt 0:00:00] } 61. Kb5 { [%emt 0:00:00] } 61... Kf6 { [%eval -28000,0] [%emt 0:00:00] } 62. Kc5 { [%emt 0:00:00] } 62... Nxh6 { [%eval -28000,0] [%emt 0:00:00] } 63. Rh8 { [%emt 0:00:00] } 63... Kg5 { [%eval -28000,0] [%emt 0:00:00] } 64. Kd5 { [%emt 0:00:00] } 64... Rg4 { [%eval -28000,0] [%emt 0:00:00] } 65. Ke6 { [%emt 0:00:00] } 65... Rf4 { [%eval -28000,0] [%emt 0:00:00] } 66. Re8 { [%emt 0:00: 00] } 66... Re4+ { [%eval -28000,0] [%emt 0:00:00] } 67. Kd7 { [%eval 0,1] } 67... Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 68. Ke6 { [%emt 0:00:00] } 68... Re4+ { [%eval -28000, 0] [%emt 0:00:00] } 69. Kd7 { [%eval 0,1] } 69... Rd4+ { [%eval -28000,0] [%emt 0:00:00] } 70. Ke6 Re4+ { [%eval -28000,0] [%emt 0:00:00] } 1/2-1/2
  1. You can then run the script.

Sample output:

[Event "Sunday 25 April Rapid, 16m+1s, 17 ROUND"]
[Site "Machines A"]
[Date "2021.04.25"]
[Round "2"]
[White "Fulcrum2000, Stockfish dev"]
[Black "Felix 2, Stockfish 240421"]
[Result "1/2-1/2"]
[BlackElo "2472"]
[BlackMaxEval "0.0"]
[BlackMinEval "-0.54"]
[EventDate "2021.04.25"]
[EventType "swiss (rapid)"]
[PlyCount "86"]
[WhiteElo "2457"]
[WhiteMaxEval "0.65"]
[WhiteMinEval "0.0"]

1. e4 { [%eval 0,0] [%emt 0:00:00] } 1... e5 { [%eval 0,0] [%emt 0:00:01] } 2. Nf3 { [%eval 0,0] } 2... Nc6 { [%eval 0,0] [%emt 0:00:00] } 3. Bc4 { [%eval 0,0] } 3... d6 { [%eval 0,0] [%emt 0:00:00] } 4. d4 { [%eval 56,39] [%emt 0:00:31] } 4... exd4 { [%eval 37,41] [%emt 0:01:04] } 5. Nxd4 { [%eval 46,43] [%emt 0:00:00] } 5... Nf6 { [%eval 0,0] [%emt 0:00:00] (Be7) } 6. Nc3 { [%eval 65,41] [%emt 0:00:21] } 6... Be7 { [%eval 37,39] [%emt 0:00:11] } 7. O-O { [%eval 51,43] [%emt 0:00:52] } 7... O-O { [%eval 54,40] [%emt 0:00: 40] } 8. a4 { [%eval 35,42] [%emt 0:00:00] } 8... Bg4 { [%eval 54,38] [%emt 0:00:42] (Nxd4) } 9. f3 { [%eval 40,38] [%emt 0:00:13] } 9... Nxd4 { [%eval 47,39] [%emt 0:00:00] } 10. Qxd4 { [%eval 41,42] [%emt 0:00:55] } 10... Be6 { [%eval 45,41] [%emt 0:00:11] } 11. Rd1 { [%eval 50,37] [%emt 0:00:00] } 11... Bxc4 { [%eval 41,38] [%emt 0:00:13] } 12. Qxc4 { [%eval 46,38] [%emt 0:00:08] } 12... c6 { [%eval 41,37] [%emt 0:00:08] } 13. Be3 { [%eval 38,40] [%emt 0:00:46] } 13... Re8 { [%eval 29,34] [%emt 0:00:13] } 14. a5 { [%eval 28,38] [%emt 0:00:22] } 14... h6 { [%eval 41,38] [%emt 0:00:33] } 15. Bf2 { [%eval 36,39] [%emt 0:00:20] } 15... Qc8 { [%eval 20,36] [%emt 0:00:01] } 16. h3 { [%eval 22,40] [%emt 0:00:54] } 16... Bf8 { [%eval 27,44] [%emt 0:00:00] } 17. Kf1 { [%eval 28,42] [%emt 0:00:36] } 17... Nd7 { [%eval 27,44] [%emt 0:00:00] } 18. Ne2 { [%eval 24,39] [%emt 0:00:10] } 18... b5 { [%eval 18,40] [%emt 0:00:07] } 19. axb6 { [%eval 32,40] [%emt 0:00:05] } 19... axb6 { [%eval 25,41] [%emt 0:00:11] } 20. Rxa8 { [%eval 30,41] [%emt 0:00:05] } 20... Qxa8 { [%eval 25,40] [%emt 0:00:11] } 21. b3 { [%eval 18,40] [%emt 0:00:13] } 21... Ne5 { [%eval 24,41] [%emt 0:00:03] (b5) } 22. Qc3 { [%eval 20,42] [%emt 0:00:43] } 22... b5 { [%eval 17,43] [%emt 0:00:00] } 23. Ra1 { [%eval 15,40] [%emt 0:00:12] } 23... Qc8 { [%eval 17,41] [%emt 0:00:18] } 24. Bg3 { [%eval 17,42] [%emt 0:00:18] } 24... Qd7 { [%eval 16,44] [%emt 0:00:10] } 25. Bf2 { [%eval 15,43] [%emt 0:00:20] } 25... Qc8 { [%eval 24,44] [%emt 0:00:00] } 26. Rd1 { [%eval 17,43] [%emt 0:00:26] } 26... Qa6 { [%eval 17,41] [%emt 0:00:43] (Qd7) } 27. Qd2 { [%eval 18,41] [%emt 0:00:07] } 27... Ng6 { [%eval 14,39] [%emt 0:00:15] (Qc8) } 28. Bg3 { [%eval 17,42] [%emt 0:00:43] } 28... Rd8 { [%eval 7,43] [%emt 0:00:13] } 29. f4 { [%eval 6,44] [%emt 0:00:28] } 29... Be7 { [%eval 7,43] [%emt 0:00:00] (Ra8) } 30. Qd3 { [%eval 3,44] [%emt 0:00:29] } 30... Nf8 { [%eval 0,49] [%emt 0:00:00] } 31. Nd4 { [%eval 6,41] [%emt 0:00:08] } 31... Ne6 { [%eval 0,49] [%emt 0:00:05] } 32. Nxe6 { [%eval 0,43] [%emt 0:00:03] } 32... fxe6 { [%eval 0,55] [%emt 0:00:09] } 33. Qe2 { [%eval 0,45] [%emt 0:00:04] } 33... Qc8 { [%eval 0,58] [%emt 0:00:09] } 34. Bf2 { [%eval 0,50] [%emt 0:00:00] } 34... e5 { [%eval 0,58] [%emt 0:00:12] } 35. fxe5 { [%eval 0,56] [%emt 0:00:00] } 35... dxe5 { [%eval 0,59] [%emt 0:00:17] } 36. Rxd8+ { [%eval 0,59] [%emt 0:00:00] } 36... Qxd8 { [%eval 0,64] [%emt 0:00:19] } 37. Qg4 { [%eval 0,58] [%emt 0:00:00] } 37... Bb4 { [%eval 0,60] [%emt 0:00:13] } 38. Be3 { [%eval 0,59] [%emt 0:00:00] } 38... Bd2 { [%eval 0,56] [%emt 0:00:15] } 39. Qe6+ { [%eval 0,60] [%emt 0:00:00] } 39... Kh7 { [%eval 0,62] [%emt 0:00:12] } 40. Qf5+ { [%eval 0,54] [%emt 0:00:05] } 40... Kg8 { [%eval 0,57] [%emt 0:00:19] } 41. Qe6+ { [%eval 0,61] [%emt 0:00:31] } 41... Kh7 { [%eval 0,66] [%emt 0:00:00] } 42. Qf5+ { [%eval 0,66] [%emt 0:00:29] } 42... Kg8 { [%eval 0,66] [%emt 0:00:00] } 43. Bxd2 { [%eval 0,73] [%emt 0:01:55] } 43... Qxd2 { [%eval 0,71] [%emt 0:00:00] } 1/2-1/2
DominoA4 commented 3 years ago

I did everything as you say. the error came out:

C:\Users\Elena>cd C:\Work folder\evalswing

C:\Work folder\evalswing>python eval_swing.py --input 1.pgn --save-game --chessb ase > output.txt Traceback (most recent call last): File "eval_swing.py", line 424, in main() File "eval_swing.py", line 420, in main a.run() File "eval_swing.py", line 368, in run df = self.evaluate(game, cnt) File "eval_swing.py", line 343, in evaluate my_game.headers['WhiteMaxEval'] = str(max([i for i in w_eval if i is not Non e])) ValueError: max() arg is an empty sequence

C:\Work folder\evalswing>

file.zip

fsmosca commented 3 years ago

That particular game has no eval.

[Event "Thursday 22 April Blitz, 5+0, 19 ROUNDS"]
[Site "Machines A"]
[Date "2021.04.22"]
[Round "1"]
[White "Trasno, Stockfish"]
[Black "Toth Barnabas, CF EXT 040121 x64 S"]
[Result "1/2-1/2"]
[WhiteElo "2766"]
[BlackElo "2727"]
[EventDate "2021.04.22"]
[PlyCount "138"]
[EventType "swiss (blitz)"]

1. e4 { [%emt 0:00:00] } 1... e5 { [%emt 0:00:00] } 2. Nf3 { [%emt 0:00:00] } 2... Nc6 { [%emt 0:00:00] } 3. Bb5 { [%emt 0:00:00] }

Perhaps I just skip this game and not save it in the output or just add ? like, [WhiteMaxEval "?"]

DominoA4 commented 3 years ago

It will be convenient for me to save games without "eval" with the title: [WhiteMaxEval "?"]. So that I can see such games. I'll analyze them later.

DominoA4 commented 3 years ago

Hello! I am successfully using the script eval_swing.py (chessbase). Thanks. Is it possible to make a pgn file processing function with Infinitychess games? Pgn example: https://pixeldrain.com/u/TQ4iXhZq Infinity.zip