What's the average piece density? In a position, the piece density is equal to the total number of pieces on the board (Whites pieces + Black pieces) divided by the total number of squares (64).

At the beginning of every game, the piece density is equal to 32/64=0.5, and at any point of the game the piece density is always smaller or equal to 0.5

The piece density can only decrease during a game. It decreases by 1/64=0.015625 at each capture.

I would like to know what's the average piece density.

I'd need a decent precision on the result, so you can't just use a small sample of 5 games. You'll need to take a large sample of at least 500 games, the more the better.

It should be fairly easy. To make the program that will calculate this average piece density, use the facts that at the beginning of each game the piece density is equal to 0.5, then at each capture it decreases by 0.015625, and the program will be able to detect each capture easily since captures are indicated by a "x" symbol in the PGN. So the program won't have to represent every positions of every games, it will be able to quickly calculate the average piece density just by scanning the PGN.

But take only OTB games, played at a classical (long) time control of at least 2 hours per player, and where both players were at least 2000 Elo. No correspondence games, no engines games, no internet games, no rapid games, no blitz games.
First of all, I think this is a bad question (similar to StackOverflow "Give me the code" questions).

That being said, the subject itself seemed interesting, so I threw a quick and dirty (and inefficient - feel free to optimise) script together to do this. I ran it on PGN file of world championship games between 1895 and 1985 from this page (this should fit OPs requirements). The results:

The overall average value for the data points in the World Championships PGN is roughly 0.35 (0.349341653669).

EDIT:
Results on much bigger PGN sample (~275.000 games) - chess db grandmaster collection (although most likely includes games with non-classical time control).


I am making the script available, so that you can run it on PGN of your choice. It depends on the python pgn parsing package.