rodpolako / Chess-PGN-Trainer

Online tool that opens chess PGN files and allows the user to practice the moves. This tool is to help with drilling, as efficiently as possible, a set group of puzzles/games in an appropriately configured PGN file. Once the set is complete, the player sees how many errors they made as well as how long the set took to complete.
MIT License
4 stars 1 forks source link
chess pgn trainer

Chess PGN Trainer

Online tool that opens chess PGN files and allows the user to practice the moves. This tool is to help with drilling, as efficiently as possible, a set group of puzzles/games in an appropriately configured PGN file. Once the set is complete, the player sees how many errors they made as well as how long the set took to complete.

The original design goal was to help with implementing a learning approach where a player repeatedly completes the same series of puzzles, striving to reduce both errors and time needed with each round. The idea for this came from a recommendation by Dan Heisman (https://www.danheisman.com/recommended-books.html) on how to practice tactics puzzles. In the article, Dan strongly recommends the idea of "repeatedly going through the book faster and faster until you can get 85%+ within 10-15 seconds". You can read about my own results following this approach using this tool here.

Since then, the tool has grown and can now be used to:

See the sample PGN files in the /examples folder for more information. The samples include puzzles, openings for both white and black, as well as the immortal game to practice.

A live online copy of tool is available here

screenshot

PGN Files need only three parts:

Here is an example PGN created using the analysis board from chess.com with a really basic endgame that was just saved to a file.

[Event "Example 1"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "1-0"]
[SetUp "1"]
[FEN "7k/8/8/3Q1K2/8/8/8/8 w - - 0 1"]

1. Kf6 Kh7 2. Qf7+ Kh8 3. Qg7# 1-0

The same puzzle created in Lichess via the analysis board generates the following file and also works with this tool.

Note: there is no "Event" tag generated so you would need to add this tag if you want to label the puzzle. Otherwise it works the same.

[Variant "From Position"]
[FEN "7k/8/8/3Q1K2/8/8/8/8 w - - 0 1"]

1. Kf6 Kh7 2. Qf7+ Kh8 3. Qg7#

Use the "Open PGN file" button to open this file and you can practice this puzzle.
screenshot

The PGN file can have any number of puzzles or games so you can work through a set in one shot.

Features

This tool has a couple of other features that you might like:

Once a test group is completed, tool displays the following performance information:

Default settings via PGN Tags

You can set the default options via custom tags in the PGN. For example, if you have a set of puzzles/games that you always want to be in random order, you can add a tag to the top of the PGN and it will automatically check the Randomize box when the file is loaded. Here is the example PGN with the randomize setting turned on.

[PGNTrainerRandomize "1"]
[Event "Example 1"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "1-0"]
[SetUp "1"]
[FEN "7k/8/8/3Q1K2/8/8/8/8 w - - 0 1"]

1. Kf6 Kh7 2. Qf7+ Kh8 3. Qg7# 1-0

Or another use case could be that you want to practice defenses as black and you have a PGN that has the move sequences you want to practice. Ideally you would want to use the "flipped" and "play opposite side" options every time so that you see the board from black's perspective and the computer makes the opening move. You can set that with the [PGNTrainerFlipped "1"] and [PGNTrainerOppositeSide "1"] tags in the PGN and every time you load that PGN going forward, those options will automatically be selected. You can always de-select a setting if you want something different for a particular run.

The available tags are:

The value of the tag has to be 1 in order to activate. Any other value or omission of the tag entirely will be ignored.

You can use any combination of the above tags. Just insert the desired tag(s) at the top of the PGN.

Note The only exception is selecting both "Play both sides" and "Play opposite side" at the same time (which is nonsensical). Any PGN file setting both of these options via the custom tags will have them both ignored. In this situation, update your PGN to remove one of these tags in order to set "Play both sides" OR "Play opposite side".

Known limitations

For example, the following PGN shows a position where the black king has two possible moves recorded after Qe5+:

[Event "?"]
[FEN "r1r1k3/5p2/3K4/2Q5/8/8/8/8 w - - 1 1"]

1. Qe5+ Kf8 (1... Kd8 2. Qe7#) 2. Qh8# 1-0

Loading this PGN as-is will result in the tool indicating that there is only 1 puzzle, the main line. To get the tool to test the main line and the variation, copy the entry and show each variation separately. Like this:

[Event "?"]
[FEN "r1r1k3/5p2/3K4/2Q5/8/8/8/8 w - - 1 1"]

1. Qe5+ Kf8 2. Qh8# 1-0

[Event "?"]
[FEN "r1r1k3/5p2/3K4/2Q5/8/8/8/8 w - - 1 1"]

1. Qe5+ Kd8 2. Qe7# 1-0

In this way, the tool will see that there are two puzzles and test both.

Note: There is an excellent freeware tool called PGN Extract that can take a file with variants and split each variant into a separate game suitable for this app. Here is example usage of this tool to take input.pgn which has variants and save it to a new file called output.pgn with the variants saved as separate games:

pgn-extract input.pgn --output output.pgn --splitvariants

Non-standard PGNs

Some PGNs contain data that the parser does not handle well. Examples include embedded commands (such as {[%evp]}). If you are having difficulty opening a file, remove non-essential components and try again.

Error loading PGN file

If you have an issue opening a specific PGN file the app will display a pop up and indicate the issue that the parser has found. It will also show you how many games/puzzles were successfully loaded prior to the error. For example, if the app tells you that 5 puzzles/games were loaded successfully, then the issue is with the sixth puzzle/game in the PGN. Use the error message to help guide you on fixing the issue with the sixth puzzle/game and then try loading it again.

Setup Instructions

If you just want to use the trainer and and not bother hosting the page yourself, you can just use the live link here. The latest version of the trainer will always be hosted there.

If you want to host a copy on your own environment and/or make changes:

  1. Download & extract the zip into a folder and start a web server from there.
  2. In a browser, point to index.html. On my own setup, the URL is localhost:8000/index.html but may be different for your setup. Refer to your web server for details.

Usage

  1. Click on "Open PGN File"
  2. Navigate to the desired PGN file and then click on OK
  3. Place a checkmark next to any desired features (such as random, flipped, play both sides)
  4. When ready, click on start and the first puzzle in the set will be displayed and you can make your first move.
  5. When the puzzle/game is finished, the next puzzle/game in the set will be automatically loaded
  6. When the set of puzzles/games is complete, your final stats will be displayed.
  7. You can pause any time if you need to step away.
  8. If you get stuck you can get a hint by clicking the hint button.

You can then start a new PGN file by repeating these steps.

References

Built with the help of the following projects:

Possible ideas for improvements/features/roadmap

Visual/UI