Skip to content

Playing around with analyzing games, optimized for lichess.org and chess.com data.

License

Notifications You must be signed in to change notification settings

acviana/chess-analyzer

Repository files navigation

chess-analyzer

Build Status Documentation Status codecov

A small chess analysis library optimized for chess.com and Lichess.org data.

This package has two main functionalities. First, it uses the API endpoints to download and save any users games as PNG files. The second is to parse the game files into game play metrics. The metrics are calculated using a pandas data frame that can also be used as a data object for further analysis such as in a Jupyter notebook.

Example Jupyter Notebook Usage

The core Pandas object from the analysis functionality can be loaded directly into a Jupyter notebook for additional analysis. The following script uses the Seaborn library to generate three histograms of the distribution of a player's ELO spread vs their opponents broken out by total games, wins, and losses.

import pandas as pd
import seaborn as sns
from chess_analyzer.analysis import analysis_main

df = analysis_main(src="data/*.pgn", username="acviana")

sns.distplot(df.elo_spread)
sns.distplot(df[df.is_win].elo_spread)
sns.distplot(df[~df.is_win].elo_spread)

example analysis histogram

Example CLI Usage

The CLI module allows you to either download games as PGN files or run a basic analysis on a set of PGN files. All commands contain a --help flag with additional information.

Download png game files from Lichess.org API.

chess-analyzer download acviana lichess 2020-01 2020-09 --output-dir data/
Downloaded 127 games from Lichess.org

Run a basic report against a set of PNG game files.

$ chess-analyzer analyze acviana
260 games found in data/*.pgn
Total Games: 260
Total Game Time: 12:28:43
Total Wins: 126 (48%)
Total Losses: 134 (52%)
Latest ELO: 793 (2020.04.12)
Best Win: -126 - supersnorre (773) vs acviana (647) 0-1
Total Opponents: 247
Repeat Opponents: 12


By time control:


Time Control: 60s
Total Games: 220
Total Game Time: 6:57:29
Total Wins: 110 (50%)
Total Losses: 110 (50%)
Latest ELO: 558 (2020.04.12)
Best Win: -101 - Zendinih (696) vs acviana (595) 0-1


Time Control: 600s
Total Games: 17
Total Game Time: 3:24:53
Total Wins: 10 (59%)
Total Losses: 7 (41%)
Latest ELO: 1114 (2019.04.14)
Best Win: -37 - ShabanAli (1151) vs acviana (1114) 0-1


Time Control: 180s
Total Games: 15
Total Game Time: 1:13:20
Total Wins: 4 (27%)
Total Losses: 11 (73%)
Latest ELO: 793 (2020.04.12)
Best Win: 1 - acviana (866) vs Pharells (865) 1-0

...

About

Playing around with analyzing games, optimized for lichess.org and chess.com data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published