Is there a way to figure out the average number of moves of a game? Looking at games on record, it is 40 or so. OK, but what about in pure chess sense? For instance, I was looking at game in which one player won Queen for Rook in the middle game. After a few moves the weaker side resigned. Fair enough. But playing the game out to the final result took seventy or so more moves! The number of moves on record does not reflect the actual logical number of moves of which a game should consist.
-
2So, should we ever solve chess, the "logical number of moves of which a game should consist" will be zero, right? :)– AakashMCommented May 24, 2022 at 15:45
-
@AakashM: Exactly. In the improbable case White wins the starting position, we could give the longest variant until mate, though, so a number would make sense.– Hauke ReddmannCommented May 24, 2022 at 17:03
-
2It took seventy or more moves presumably with an engine playing both sides close-to-perfectly (or more precisely an endgame table). That doesn't mean the two players would have taken 70 moves to mate if they continued playing, the player in losing position would most likely make more suboptimal moves than the other player and shorten the mating process significantly. I mean, look at the marathon Carlsen/Nepo game (chess.com/analysis/game/pgn/5H2V3LF8r2), there were long stretches where it was a dead draw by the engine. Is the logical end of that game the first time that happens?– llamaCommented May 24, 2022 at 18:39
-
2Is this a purely game theoretic question asking about what happens in the case of optimal play? Or is this asking about actual real games played by human players who make mistakes?– ShufflepantsCommented May 24, 2022 at 20:16
-
@comic4relief It's absolutely crucial to answer Shufflepants' question. Are you asking (a) consider the resignation point of human games, then calculate the game-theoretic distance to mate in those positions (i.e. the fewest moves within which the winning-eval side can theoretically force mate) - this is the way Hauke Redmann has taken the question (and also my first impression); or, (b) how long would the human games last if resignation were not an allowed part of the game and the two humans played their sides out to checkmate (as Brian Towers and user21820 have taken it in their answers).– Mobeus ZoomCommented May 24, 2022 at 20:54
4 Answers
Is there a way to figure out the average number of moves of a game?
The best way is to run a program which goes through a large database of games and calculates the average number of moves per game.
The number of moves on record does not reflect the actual logical number of moves of which a game should consist.
Games of chess are played between players of many different strengths. The "logical number of moves" a game should last after a particular position, even one where one player has lost queen for rook, will depend on the strengths of the two players and what mistakes they make on the way to finishing the game. That means that there is no "logical number of moves of which a game should consist". There is only the actual number of moves of the game.
-
2Well, in theory you could expand out the entire game tree and exhaustively count up how deep every single branch is, then take some sort of average. But to the best of my understanding, there is no efficient way to do it, and the brute force method is obviously wildly impossible.– KevinCommented May 24, 2022 at 21:55
-
Seeing as the Shannon number is ~10^40 greater than the number of atoms in the observable universe, I would have to agree that brute force is not even worth a glance for this type of problem.– GOATNineCommented May 25, 2022 at 17:45
-
You could input all the recorded tournament games, up until one player resigns, and feed that position into Stockfish or whatever and see how many more moves it would've taken to actually mate, then calculate those averages. Not sure what the value of that exercise would be though. Doing every possible game is absurd, because the vast majority of possible games would never happen in reality if both players are actually trying to, you know, win... Commented May 25, 2022 at 19:12
Since actual games are almost always imperfect play, there is no logical number of moves from a given position, since the actual players would generally not play perfectly if forced to continue the game to the end. However, you can probably estimate the number of moves it would take a given pair of human players P1,P2 to finish a game past a resignation, by calibrating computer players C1,C2 to play similarly to each of them, and then using C1,C2 to finish the game! From this you can then obtain an estimate of the average number of moves that P1,P2 would take per chess game that they played but stopped upon resignation.
The question then is, how can we calibrate computer players? A crude first-order approximation is as follows: Measure the centipawn loss distribution f of the human player over the opening and the middle-game and the end-game, according to an engine like StockFish. Then construct a smoothed version F of the cumulative function for f. Now make the computer player choose each move such that the smoothed cumulative function for the centipawn loss distribution for the chosen move is as close as possible to F!
Better approximations are of course not hard to achieve. Just like Lichess can tailor puzzles to your weaknesses, which are all automatically computed, so also you can have different loss distributions for different types of moves (treating each position as a puzzle). It doesn't matter if the categories are humanly crafted (e.g. forks, pins, skewers, ...), because the goal is just to get a better result and not necessarily converge to a perfect simulation.
-
1This is a good answer with a bunch of interesting stuff regarding mimicking human play, but in this one particular case it's probably not sufficient, because we simply don't have data regarding how P1,P2 will play past resignation point, as they don't tend to play these positions (that's the rub: they've resigned by then!). Commented May 24, 2022 at 21:08
-
@MobeusZoom: True, but we have to make simplifying assumptions if we want to get anything at all. Suppose that we want to know what happens if the world chess federation changes the rules to forbid resignation, just before a tournament. Then how would P1,P2 play in that tournament? Suppose that this does not affect their play up to the point where P1 would want to resign in the original world. Suppose further that the stakes are high, so P1 won't just concede defeat by making a silly move. Then our best estimate is to categorize each subsequent position so as to guess how P1,P2 would play. Commented May 24, 2022 at 21:27
-
@user2180 Agreed. My only point is that the error bars are likely to be very large, because the same positions we are trying to make predictions about here are the very positions we don't have data about because resignation has occurred before them by definition. If the rules were changed as you suggest, we could start collecting that data and I guess considerably shorten the error bars quite quickly. Commented May 24, 2022 at 21:41
Here are the results based from the games at TC 10minutes + 6s inc. The games are not adjudicated. You can download the games at http://www.fastgm.de/10min.html.
These games have PlyCount tag, we can use this to get the approximate average number of moves on the games. You can use python chess modules to do this.
pgn file: Top10-10min.pgn
average ply: 198
approximate average number of moves: 99
Python code
import chess
import chess.pgn
import statistics
fn = 'Top10-10min.pgn'
data = []
with open(fn, 'r') as f:
while True:
game = chess.pgn.read_game(f)
if game is None:
break
plycnt = int(game.headers['PlyCount'])
data.append(plycnt)
print(f'average ply: {statistics.mean(data)}, approximate average number of moves: {statistics.mean(data)//2}')
Other stats on ply numbers.
file: Top10-10min.pgn
src: http://www.fastgm.de/10min.html
Game Ply Stats
Average: 198.0
Minimum: 25
Maximum: 909
Stdev: 96.0
Average plies by ECO
eco opening ave_plies
D80 Gruenfeld 225.0
E45 Nimzo-Indian 222.0
A17 English 221.0
E20 Nimzo-Indian 218.0
E11 Bogo-Indian defense, Gruenfeld Variation 216.0
E22 Nimzo-Indian 215.0
C07 French 214.0
D30 Queen's gambit declined 214.0
B17 Caro-Kann 213.0
C70 Ruy Lopez 213.0
A11 English 211.0
A13 English Opening 211.0
B32 Sicilian defense 211.0
D51 QGD 211.0
E15 Queen's Indian 211.0
A49 King's Indian 209.0
C05 French 208.0
D90 Gruenfeld 208.0
B50 Sicilian 207.0
E60 King's Indian defense 207.0
A25 English 205.0
C55 Two knights defense (Modern Bishop's Opening) 205.0
D82 Gruenfeld 205.0
B10 Caro-Kann 204.0
B20 Sicilian 204.0
C08 French 204.0
C60 Ruy Lopez 204.0
E14 Queen's Indian 204.0
A16 English Opening 203.0
A20 English Opening 203.0
C43 Petrov 203.0
E10 Queen's pawn game 203.0
A57 Benko gambit 202.0
D10 QGD Slav defense, Alekhine Variation 202.0
A30 English 200.0
A15 English Opening 199.0
C57 Two knights defense 199.0
D03 Torre attack (Tartakower Variation ) 199.0
E30 Nimzo-Indian 199.0
B30 Sicilian 198.0
A46 Queen's pawn game 197.0
A48 King's Indian 197.0
B22 Sicilian 197.0
C53 Giuoco Piano 197.0
E24 Nimzo-Indian 197.0
C00 French 196.0
D21 QGA 196.0
C15 French 195.0
A34 English 194.0
C24 Bishop's Opening 194.0
E61 King's Indian defense, 3.Nc3 194.0
A45 Trompovsky attack (Ruth, Opovcensky Opening) 193.0
B90 Sicilian 193.0
D31 QGD 193.0
D85 Gruenfeld 192.0
C42 Petrov Three knights game 191.0
C64 Ruy Lopez 190.0
C65 Ruy Lopez 190.0
B23 Sicilian 189.0
E70 King's Indian 189.0
A56 Benoni defense 188.0
A21 English, Kramnik-Shirov counterattack 187.0
D02 Queen's Bishop game 187.0
B27 Sicilian 185.0
B40 Sicilian defense 184.0
E00 Catalan Opening 184.0
E32 Nimzo-Indian 183.0
A27 English 180.0
C10 French 179.0
A18 English 178.0
C11 French 178.0
C50 Giuoco Piano 178.0
D70 Neo-Gruenfeld defense 176.0
D20 QGA 174.0
A19 English 173.0
C03 French 168.0
C16 French 168.0
E12 Queen's Indian 165.0
C69 Ruy Lopez 163.0
python source
"""
game src: http://www.fastgm.de/10min.html
Dependencies:
pip install chess
pip install pandas
"""
import chess.pgn
import pandas as pd
fn = 'Top10-10min.pgn'
data = []
with open(fn, 'r') as f:
while True:
game = chess.pgn.read_game(f)
if game is None:
break
plycnt = int(game.headers['PlyCount'])
eco = game.headers['ECO']
opening = game.headers['Opening']
data.append([eco, opening, plycnt])
df = pd.DataFrame(data)
df.columns = ['eco', 'opening', 'plies']
df.to_csv('plies.csv', index=False)
print(f'file: {fn}')
print('src: http://www.fastgm.de/10min.html')
print('Game Ply Stats')
print(f'Average: {df["plies"].mean().round()}')
print(f'Minimum: {df["plies"].min()}')
print(f'Maximum: {df["plies"].max()}')
print(f'Stdev: {df["plies"].std().round()}')
df1 = df.groupby('eco', as_index=False, sort=False).agg({'plies': 'mean', 'eco': 'first', 'opening': 'first'})
df1.plies = df1.plies.round()
df1 = df1.rename(columns={'plies': 'ave_plies'})
df1 = df1[['eco', 'opening', 'ave_plies']]
print(f'Average plies by ECO')
df1 = df1.sort_values(by=['ave_plies', 'eco'], ascending=[False, True])
print(df1.to_string(index=False))
In a pure sense, you would have to play out (virtually simulate) all possible games and then take the average number of moves across all of them.
You could start with the Shannon Number as an idea of roughly how much computing power you would need (hint: it's more than is available in our universe) but since it's based on estimating the average game length it wouldn't work for determining that length itself without enumerating all of possible games.
What is more interesting is to look at the number of possible moves after each number of plies as well as the number of checkmates (or more generally, any end of the game). For the first 9 plies one in 6095 games has ended in checkmate, but comparing to 1 in 8628 for the first 8 plies, 1 in 8334 for the first 7 plies, and 1 in 10996 for the first 6 plies (as well as a little common sense) it's obvious that the percentage of checkmates after a given ply, while not always increasing, is tending in that direction. If you plotted this curve of percentage of games ended by the nth ply you might (assuming the path isn't too chaotic) start to estimate how the curve might continue past the limits of your computations and get a rough guess as to the average length.
Best case with some smoothing you might find some kind of bell-like curve where most games end in the middle, with a few obvious truncation artifacts from things like the 50 move rule preventing a long tail.
You could also try a Monte Carlo simulation of games randomly chosen from legal moves. While most paths on the game tree consist of lots of moves that make no strategic or tactical sense, this might give you a "truer" picture of the actual average length of the whole game tree. Or if you are only interested in certain types of games you could create games played between computers of various strengths.