Welcome to our stockfish chess analyser, created by Emilia Salvesen Kozarevic and Victor Norris! In this project, you'll find a variety of functionality for analyzing chess games, such as importing/exporting games, performing statistics on these, generating plots, opening trees and much more.
- To test the functionalities provided, refer to the guide in main.py.
- For a visual overview of the results, check out Figures.pdf.
- If you have any questions about the code or encounter any issues running it, don't hessitate to contact me at vic@norris.no
- To run the full project, you will need the packages in dependencies
- Game: Handles chess game functionality. Includes getters and setters.
- Games: Offers advanced functionality for a database (list) of chess games.
- Manager: Manages a database of games.
- TreeNode: Implements tree node functionality. Contains getters, setters, and relevant game information.
- Tree: Constructs a tree by connecting tree nodes recursively.
- The folder "images" contains images of plots and tables.
- Data structure of games: Game class in
game.py
file provides the data structure for the Game object, as well as move management. - Import game from text file:
saveHandler.py
file contains the function for reading a game from a .pgn file. It returns a list of Game objects using regular expressions. - Export game to text file:
saveHandler.py
also includes the function for exporting a single Game object to a .pgn file. - Database:
saveHandler.py
has a function for exporting multiple games to a .pgn file, saving a list of Game objects. - Excel management:
excelReader.py
file offers functionality for reading and writing games from/to Excel. Checkwritten.xlsx
for the result. - Create LaTeX document:
documentManager.py
file is responsible for generating a LaTeX document with a title, sections, subsections, paragraphs, tables, and figures. - Stockfish game results:
plotters.py
file extracts wins, draws, and losses for Stockfish, which are found instockFish.png
and the final PDF. The relevant function ispltStatistics4Stockfish()
. - Proportion of ongoing games:
activeGamesLine.png
shows the proportion of games still ongoing after n moves. The line plot is generated by thelinePlot()
function inplotters.py
. Additionally,getStats()
in the same file produces a table of mean moves and standard deviation for black and white pieces. - Data structure of tree: The Tree class (
tree.py
) contains TreeNode objects (node.py
). Each TreeNode holds a list of Game objects sharing the same opening moves up to that node. - Database loading to a tree: To load a database into a Tree, load it into a Games object and then use the
startTree()
function, adding the games from the Games object. - Opening tree at a given depth:
printOpeningTree()
function inplotters.py
displays an opening tree based on the specified number of moves and opening. - Openings played more than n times:
extractPopularOpenings()
function inplotters.py
creates a table (normalOpenings.png
) showing openings played more than n times, given the number of moves and a database.
To run this project, you'll need the following Python libraries installed:
- graphviz
- matplotlib
- numpy
- pandas
- openpyxl
- pylatex
To install the required packages, follow these steps:
- Install
graphviz
,openpyxl
, andpylatex
using pip:
pip install graphviz openpyxl pylatex
- Install Graphviz, which is a separate software package that
graphviz
library relies on. You can download Graphviz from the official website, or you can install it using a package manager:
-
On macOS with Homebrew:
brew install graphviz
-
On Windows with Chocolatey:
choco install graphviz
To install conda, follow the instructions on the official Anaconda website to download and install the Anaconda distribution, which includes conda and many other useful packages.
Alternatively, you can install Miniconda, which is a smaller distribution that only includes conda and Python:
-
Download Miniconda from the official Miniconda website for your operating system.
-
Follow the installation instructions provided on the website for your operating system.
Once conda is installed, you can create a new environment and install the required packages using the commands mentioned earlier in this guide.