Skip to content

cwithers2/ankichess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anki Chess

Generate Anki packages from chess PGN files.

What is Anki?

Anki is a free flashcard program. It uses a spaced repetition system (SRS) to improve flashcard memorization. Similar flashcards are stored in a 'deck', and one or more decks are stored in a 'package'.

This program successfully creates a package containing one deck where each flashcard represents a move in a game of chess. It does so by reading an inputted PGN file...

What is a PGN file?

To start generating packages, all that is needed is a portable game notation (PGN) file. A PGN file is a plain-text file-type with a well defined format used to notate chess games.

Many chess websites include options to export specific games as a PGN file. Additionally, many sites offer analysis boards, where games can be constructed to study one or more move variations. This is typically helpful when studying different openings and how to respond to different moves. The PGN file format also supports these variations. The generated PGN for those games will encode a branching hierarchy of all the moves studied. The PGN file format is created from plain-text, so it's easy to create or edit by hand if ever needed, too.

NOTE: It's also worth mentioning that a PGN file can contain more than a single game.

Example PGN Files

Three PGN files are included in pgn/. They include The Opera Game, Fool's Mate and Scholar's Mate, and an Italian Game. These files are intended for testing purposes.

For more information about PGN files, visit this Wikipedia page.

More about this program

ankichess.py is the single program file in this project. It is written in Python 3 and is called from the commandline. It generates a package containing one deck. The deck represents an inputted PGN file. There are many commandline options to modify how the deck is generated. For example, there is an option to generate flashcards in 'blindfold' mode. In this mode, no pictures are generated, only text describing the moves.

Visual Example

Visual Example

Left: Question/Front of card, Right: Answer/Back of card

Blindfold Example

Blindfold Example

Left: Question/Front of card, Right: Answer/Back of card
Note: Generated text is PGN format

Usage

ankichess.py [-h] [--mainline] [--blindfold] [--game NUM] PGN_FILE OUT_FILE TITLE

argument positional optional description
PGN_FILE x A PGN file to generate an Anki package from
OUT_FILE x The file name of the Anki package to generate (typically ending in .apkg)
TITLE x The title to give the generated deck as seen in the Anki GUI
--mainline x Only generate cards for the mainline moves
--blindfold x Generate text notation only, no images (Implies --mainline)
--game NUM x Select the Nth game from the PGN file (Default is 1)
--flip x Generate images from black's perspective (Does nothing if --blindfold)

example: ankichess.py pgn/opera_game.pgn opera_game.apkg "The Opera Game"

Generated packages can be imported into the desktop version of Anki using the Import File GUI.

Install

Currently there is no install tool. You can manually add ankichess.py to your path or call it from its project directory.

Installing Dependencies

  • pip3 install genanki
  • pip3 install chess

About

Generate Anki packages from chess PGN files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages