Pgn2tex - Scripts to convert pgn files to latex document. Useful to build books or pdf from pgn studies

Related tags

Deep Learningpgn2tex
Overview

Pgn2Latex (WIP)

A simple script to make pdf from pgn files and studies. It's still work in progress and I hope to improve it in the future. Please feel to reach out or to contribute by submitting issues and pull requests!

Examples

Some examples can be found in the examples/ directory. At the moment there is a book on the Stafford Gambit based on this study and a book of puzzles.

Requirements

Python

pip install -r requirements.txt

Latex

It uses xskak and skak to draw the chessboards. The latex files should be compiled using xelatex.

Usage

Studies

> python pgn2tex/study.py --help
usage: study.py [-h] [--mode {single,study}] [--players] [--template TEMPLATE] [--front-page FRONT_PAGE] [-o OUTPUT] file

Convert a PGN file to a latex document. It is supposed to be used to create book from a study or a single game analysis.

positional arguments:
  file                  PGN File to parse

options:
  -h, --help            show this help message and exit
  --mode {single,study}, -m {single,study}
                        Wether to treat each game independently or as one single large study with several chapters.
  --players, -p         Add player names
  --template TEMPLATE, -t TEMPLATE
                        Template file to use, if none only the latex content is generated with headers / document class, it can be input later on in any latex document.
  --front-page FRONT_PAGE, -f FRONT_PAGE
                        Path to a pdf frontpage
  -o OUTPUT, --output OUTPUT
> python pgn2tex/study.py examples/lichess_study_stafford-gambit_by_wyggam_2020.10.04.pgn --mode study -o examples/stafford.tex --template pgn2tex/templates/book.tex --front-page pgn2tex/templates/frontpage_stafford.pdf
> cd examples
> xelatex stafford.tex
> xelatex stafford.tex # for table of content and cross refs

Puzzles

You first need to download the lichess puzzle database and the themes description, assuming you are in the root directory of the repo:

mkdir -p data 
cd data 
wget https://database.lichess.org/lichess_db_puzzle.csv.bz2 && bzip2 -d lichess_db_puzzle.csv.bz2 
wget https://raw.githubusercontent.com/lichess-org/lila/master/translation/source/puzzleTheme.xml
cd ..

Usage:

usage: puzzles.py [-h] [--problems PROBLEMS]
                  [--theme {advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} [{advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} ...]]
                  [-m MIN_RATING] [-s STEP_SIZE] [-M MAX_RATING] [--template TEMPLATE] [--front-page FRONT_PAGE] [--output OUTPUT]

Generate latex with chess puzzles from the lichess database

options:
  -h, --help            show this help message and exit
  --problems PROBLEMS, -p PROBLEMS
                        Max number of problems to sample in each theme/rating range.
  --theme {advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} [{advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} ...]
                        Name of the themes to be used.
  -m MIN_RATING, --min-rating MIN_RATING
                        Minimum rating of the problems.
  -s STEP_SIZE, --step-size STEP_SIZE
                        Step size from problem ratings
  -M MAX_RATING, --max-rating MAX_RATING
                        Maximum rating of the problems.
  --template TEMPLATE, -t TEMPLATE
                        Template file to use, if none only the latex content is generated with headers / document class, it can be input later on in any latex document.
  --front-page FRONT_PAGE, -f FRONT_PAGE
                        Path to a pdf frontpage
  --output OUTPUT, -o OUTPUT
                        Output file

Example:

python pgn2tex/puzzles.py --template pgn2tex/templates/book.tex --front-page pgn2tex/templates/frontpage_puzzles.pdf  --output examples/puzzles.tex
cd examples
xelatex puzzles.tex
xelatex puzzles.tex # for table of contents

Code formatting

The code is formatted using Black

This repo contains the implementation of the algorithm proposed in Off-Belief Learning, ICML 2021.

Off-Belief Learning Introduction This repo contains the implementation of the algorithm proposed in Off-Belief Learning, ICML 2021. Environment Setup

Facebook Research 32 Jan 05, 2023
*ObjDetApp* deploys a pytorch model for object detection

*ObjDetApp* deploys a pytorch model for object detection

Will Chao 1 Dec 26, 2021
This tutorial repository is to introduce the functionality of KGTK to first-time users

Welcome to the KGTK notebook tutorial The goal of this tutorial repository is to introduce the functionality of KGTK to first-time users. The Knowledg

USC ISI I2 58 Dec 21, 2022
Özlem Taşkın 0 Feb 23, 2022
HMLLDB is a collection of LLDB commands to assist in the debugging of iOS apps.

HMLLDB is a collection of LLDB commands to assist in the debugging of iOS apps. 中文介绍 Features Non-intrusive. Your iOS project does not need to be modi

mao2020 47 Oct 22, 2022
The official repo of the CVPR2021 oral paper: Representative Batch Normalization with Feature Calibration

Representative Batch Normalization (RBN) with Feature Calibration The official implementation of the CVPR2021 oral paper: Representative Batch Normali

Open source projects of ShangHua-Gao 76 Nov 09, 2022
Simple, but essential Bayesian optimization package

BayesO: A Bayesian optimization framework in Python Simple, but essential Bayesian optimization package. http://bayeso.org Online documentation Instal

Jungtaek Kim 74 Dec 05, 2022
A Pytorch Implementation for Compact Bilinear Pooling.

CompactBilinearPooling-Pytorch A Pytorch Implementation for Compact Bilinear Pooling. Adapted from tensorflow_compact_bilinear_pooling Prerequisites I

169 Dec 23, 2022
PyTorch DepthNet Training on Still Box dataset

DepthNet training on Still Box Project page This code can replicate the results of our paper that was published in UAVg-17. If you use this repo in yo

Clément Pinard 115 Nov 21, 2022
PyTorch implementation for NED. It can be used to manipulate the facial emotions of actors in videos based on emotion labels or reference styles.

Neural Emotion Director (NED) - Official Pytorch Implementation Example video of facial emotion manipulation while retaining the original mouth motion

Foivos Paraperas 89 Dec 23, 2022
Implementation of a protein autoregressive language model, but with autoregressive infilling objective (editing subsequences capability)

Protein GLM (wip) Implementation of a protein autoregressive language model, but with autoregressive infilling objective (editing subsequences capabil

Phil Wang 17 May 06, 2022
Puzzle-CAM: Improved localization via matching partial and full features.

Puzzle-CAM The official implementation of "Puzzle-CAM: Improved localization via matching partial and full features".

Sanghyun Jo 150 Nov 14, 2022
Retinal vessel segmentation based on GT-UNet

Retinal vessel segmentation based on GT-UNet Introduction This project is a retinal blood vessel segmentation code based on UNet-like Group Transforme

Kent0n 27 Dec 18, 2022
Deep Semisupervised Multiview Learning With Increasing Views (IEEE TCYB 2021, PyTorch Code)

Deep Semisupervised Multiview Learning With Increasing Views (ISVN, IEEE TCYB) Peng Hu, Xi Peng, Hongyuan Zhu, Liangli Zhen, Jie Lin, Huaibai Yan, Dez

3 Nov 19, 2022
PySLM Python Library for Selective Laser Melting and Additive Manufacturing

PySLM Python Library for Selective Laser Melting and Additive Manufacturing PySLM is a Python library for supporting development of input files used i

Dr Luke Parry 35 Dec 27, 2022
Official PyTorch implementation of Learning Intra-Batch Connections for Deep Metric Learning (ICML 2021) published at International Conference on Machine Learning

About This repository the official PyTorch implementation of Learning Intra-Batch Connections for Deep Metric Learning. The config files contain the s

Dynamic Vision and Learning Group 41 Dec 10, 2022
Datasets, Transforms and Models specific to Computer Vision

vision Datasets, Transforms and Models specific to Computer Vision Installation First install the nightly version of OneFlow python3 -m pip install on

OneFlow 68 Dec 07, 2022
Public repo for the ICCV2021-CVAMD paper "Is it Time to Replace CNNs with Transformers for Medical Images?"

Is it Time to Replace CNNs with Transformers for Medical Images? Accepted at ICCV-2021: Workshop on Computer Vision for Automated Medical Diagnosis (C

Christos Matsoukas 80 Dec 27, 2022
这是一个yolo3-tf2的源码,可以用于训练自己的模型。

YOLOV3:You Only Look Once目标检测模型在Tensorflow2当中的实现 目录 性能情况 Performance 所需环境 Environment 文件下载 Download 训练步骤 How2train 预测步骤 How2predict 评估步骤 How2eval 参考资料

Bubbliiiing 68 Dec 21, 2022
Gans-in-action - Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks

GANs in Action by Jakub Langr and Vladimir Bok List of available code: Chapter 2: Colab, Notebook Chapter 3: Notebook Chapter 4: Notebook Chapter 6: C

GANs in Action 914 Dec 21, 2022