fsmosca / Python-Chess-Scripts

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

Plotting only pre-selected games [pgn_graph] (enhancement) #10

Closed rwbc closed 3 years ago

rwbc commented 3 years ago

Would it be possible to just plot pre-selected graphs, may be by passing an array of numbers (= game number in pgn file)? This would be a nice enhancement, of course plotting all games should remain default option. It is crucial though that the pre-selected graphs are numbered after the given game number in the total pgn file.

I fiddled around with more testing of the eval_swing and found more things I had to correct in the FCPT 2021 pgn file. After I removed all other strange things, I imported the result into a GoogleSheet and did a first filtering for the most interesting and strange results and had the idea this could be used for just plotting a first selection of graphs.

https://docs.google.com/spreadsheets/d/1FoSw0MH6ahhX4jsLNzKIAR322mKD99HhgUuvYxs7jRE/edit#gid=1639412648 The resulting game numbers in Sheet3 would be the first to plot.

So if the pgn-graph could read a text file with an array of numbers, which is equivalent to the game to plot, e.g. {x y z...), that would be nice. Just an idea. What do you think?

fsmosca commented 3 years ago

I can implement that.

python pgngraph.py --plot-file gameplot.txt

where:
gameplot.txt must be located in the same folder as pgngraph.py and can contain the following:

1
3
4 
8
15

Those numbers are the game number that needs to be plotted. The game number in the pgn is just the sequential number where the first game that appears is game number 1. plot-file can be any name i.e gamestoplot.txt etc.

If --plot-file option is not specified then all games in the pgn will be plotted. This is the default behaviour.

If this is ok with you I will add it.

Later I will add it in command line like you want to plot game 4 and 17.
python pgngraph.py --plot-game-number "[4, 17]" --input mygames.pgn ...

rwbc commented 3 years ago

That's quite exactly how I imagined it :)

One last thing I noticed would be handy. The sequential number (game number) should best also appear in the 2nd line below the game header in the plots. If there is already a 'number' tag available in the pgn it should take this, otherwise print it to the 2nd line. I think best would be after the 'round' tag.

May be also optional because sometimes the round tag == game number, but often it is different. My suggestion would be sth like this:

TCEC Season 19 - Superfinal, 2020.10.01, Round: 10.1, (24), 1/2-1/2

I think this is might be my last suggestion and I will only report unforseen bugs (if I find any) in the future. Thanks for all the work done!

fsmosca commented 3 years ago

Updated pgn_graph.py to v0.25.0.

python pgn_graph.py --input mygame.pgn --plot-file gamestoplot.txt

Sample output:

This only considers game number sequence.

rwbc commented 3 years ago

I have tested now the selected plotting on CCCC1 games, which also have a lot of strange things to convert first and all worked like a charm!

Just now I realize how good the eval_swing tool is also for finding buggy output from either engines or GUIs.

Nemorino 5.00 at has at least 4 games with a sudden extreme completely illogical eval change in this pgn file. I checked two of the positions with analysing it and Nemorino just outputs '0.00 only legal move'. The saved eval though in the pgn was very far from 0.00 and as this first CCCC tournament was with ponder on, I suspect the GUI just saved the ponder eval for the opponent move instead!

122     Laser 1.6       Nemorino 5.00   1-0     -       NaN     2       0.16    40      5.32    -       NaN
275     Komodo 2118.00  Nemorino 5.00   1-0     -       NaN     9       0.21    59      4.76    -       NaN

And BTW for your useful table in: https://github.com/fsmosca/Python-Chess-Scripts/issues/9#issuecomment-757485549 CCCC uses spov at least in the first edition.

Edit:

Just now I see this also happened once with Senpai (ponder eval of opponent), but here it was at depth 1. I think we should discard all depth 1 evals in eval_swing output. IIRC we do this already in the pgn_graph. At least I thought so? But the graph of 426 shows otherwise. I really cannot remember now...

cccc1_games_mod_426

[Event "CCCC 1: Rapid Rumble (15|5) Stage 1"] [Site "Chess.com"] [Date "2018.09.13"] [Round "426"] [White "Fire 7.1"] [Black "Senpai 2.0"] [Result "1-0"] ...

  1. Bg5 {+3.95/24 19} Qd7 {-0.59/14 0}
  2. Qh5+ {+4.53/21 34} Kg8 {-0.82/18 0}
  3. Ng6 {+4.34/22 5} Rb8 {0.00/12 24}
  4. Rfe1 {+5.84/22 29} bxc3 {0.00/9 18}
  5. Bd1 {+6.66/25 4} cxb2 {+5.29/1 5}
  6. Qh8+ {+M4/49 0} Kf7
  7. Bh5 {+M3/49 0} bxa1=Q {-M2/64 0}
  8. Nxf8+ {+M3/49 0} g6 {-M1/64 0}
  9. Bxg6# {+M3/49 0} 1-0
fsmosca commented 3 years ago

If this
--plot-file gameplot.txt worked can we just close this issue. If you have other issues just create new one.

rwbc commented 3 years ago

You are right I should have issued it in another thread. The plotting by selective number works.