PgnStats

Code, algorithms, languages, construction...
Post Reply
User avatar
IbaiBuR
Posts: 208
Joined: Sun Jul 03, 2022 4:08 pm
Real Name: Ibai Burgos
Location: Madrid, Spain
Contact:

PgnStats

Post by IbaiBuR » Sat Dec 16, 2023 8:17 pm

PgnStats is a simple chess tool which is capable of calculating statistics from commented PGN files, preferably with cutechess-like format. e.g.:

Code: Select all

1. c4 {book} c5 {book} 2. Nc3 {book} Nc6 {book} 3. g3 {book} g6 {book}
4. Bg2 {book} Bg7 {book} 5. e4 {book} a6 {0.00/33 3.1s} 6. a4 {-0.02/30 3.5s}
e5 {+0.02/38 3.0s} 7. Nge2 {0.00/31 2.0s} Nge7 {0.00/52 6.8s}
8. d3 {0.00/28 1.8s} O-O {0.00/33 1.1s} 9. O-O {0.00/32 1.5s} d6 {0.00/30 3.8s}
10. Be3 {0.00/35 1.6s} Bd7 {0.00/32 8.7s} 11. Qd2 {0.00/39 1.6s} ...
As of now it calculates both overall and individual statistics, giving this sample output with my shared 60000+ Eman's learning games:

Code: Select all

Overall statistics
==================

- Basic:
	·Total number of white wins: 5430    (8.58%)
	·Total number of black wins: 826     (1.30%)
	·Total winrate             : 9.88%
	·Total number of draws     : 57062   (90.12%)
	·Total number of games     : 63320  
	·Total number of moves     : 7726357
------------------

- Averages:
	·Average game duration     : 214.03 seconds
	·Average PlyCount          : 122    
	·Average depth per move    : 29     
	·Average time per move     : 1.93 seconds
------------------

- ECO Distribution:
	·ECO A number of games     : 17245   (27.23%)
	·ECO B number of games     : 12979   (20.50%)
	·ECO C number of games     : 15000   (23.69%)
	·ECO D number of games     : 6674    (10.54%)
	·ECO E number of games     : 11422   (18.04%)
==================

Code: Select all

Individual statistics for each player
=====================================

There are exactly 3 players in the PGN file:

- Player: Eman                
	·White wins : 3094    (4.89%)
	·Black wins : 471     (0.74%)
	·Draws      : 57062   (90.12%)
	·Total games: 63318   (100.00%)
	·Total moves: 3863515 (50.00%)
	·Win rate   : 5.63%
	·Avg. Depth : 30     

------------------------------

- Player: ShashChess          
	·White wins : 1104    (3.49%)
	·Black wins : 161     (0.51%)
	·Draws      : 28235   (89.18%)
	·Total games: 31660   (50.00%)
	·Total moves: 1904186 (24.65%)
	·Win rate   : 4.00%
	·Avg. Depth : 26     

------------------------------

- Player: BrainLearn          
	·White wins : 1232    (3.89%)
	·Black wins : 194     (0.61%)
	·Draws      : 28827   (91.06%)
	·Total games: 31658   (50.00%)
	·Total moves: 1958656 (25.35%)
	·Win rate   : 4.50%
	·Avg. Depth : 30     

==============================
Using it is quite straightforward:

- In Windows you have 2 options:

First option: Open the Windows CMD in the folder where PgnStats is located and execute the tool like this:

Code: Select all

PgnStats.exe <name_of_your_pgn_file>.pgn
Second option: Just drag & drop the PGN file into the exe.

- In Linux, just use the terminal in a similar way to Windows (make sure the program has executing permission) :

Code: Select all

./PgnStats <name_of_your_pgn_file>.pgn
After executing the tool, you will see 2 files, "overall_statistics.txt" and "individual_statistics.txt" with the output of the execution.

You can download it and check its source code here:

https://github.com/IbaiBuR/PgnStats

Pre-compiled binaries are also available in the releases tab:

https://github.com/IbaiBuR/PgnStats/releases

Enjoy!

User avatar
OrgZ
Posts: 942
Joined: Thu Feb 16, 2023 2:15 pm

Re: PgnStats

Post by OrgZ » Sun Dec 17, 2023 4:51 am

Interesting tool. Thanks 👍

ZamChess
Posts: 376
Joined: Sun Dec 19, 2021 10:24 am

Re: PgnStats

Post by ZamChess » Sun Dec 17, 2023 8:29 am

Thank you IbaiBuR !

User avatar
IbaiBuR
Posts: 208
Joined: Sun Jul 03, 2022 4:08 pm
Real Name: Ibai Burgos
Location: Madrid, Spain
Contact:

Re: PgnStats

Post by IbaiBuR » Sun Dec 17, 2023 9:21 am

Thanks to both of you for your appreciation!

Hope you like it :)

User avatar
OrgZ
Posts: 942
Joined: Thu Feb 16, 2023 2:15 pm

Re: PgnStats

Post by OrgZ » Sun Dec 17, 2023 2:58 pm

IbaiBuR wrote:
Sun Dec 17, 2023 9:21 am
Thanks to both of you for your appreciation!

Hope you like it :)
been looking for something like this...i used Scid to get pgn info. but yours has some extra stuff. Good job mate, i love it :difus_19

Homayoun
Posts: 1538
Joined: Tue Mar 21, 2023 4:57 pm
Real Name: Homayoun

Re: PgnStats

Post by Homayoun » Mon Dec 18, 2023 5:57 am

Many thanks

User avatar
IbaiBuR
Posts: 208
Joined: Sun Jul 03, 2022 4:08 pm
Real Name: Ibai Burgos
Location: Madrid, Spain
Contact:

Re: PgnStats

Post by IbaiBuR » Mon Dec 18, 2023 10:08 am

You are welcome!

Post Reply