Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dignissimus/pgn-filter
A small program to query for games inside PGN documents
https://github.com/dignissimus/pgn-filter
chess pgn
Last synced: 3 days ago
JSON representation
A small program to query for games inside PGN documents
- Host: GitHub
- URL: https://github.com/dignissimus/pgn-filter
- Owner: dignissimus
- License: mit
- Created: 2023-03-08T14:48:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-09T21:12:16.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T06:37:49.873Z (3 months ago)
- Topics: chess, pgn
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pgn-filter
A small program to query for games inside PGN documents.
You can supply basic queries using command line arguments
and you can write more advanced queries using python scripts.# Installation
```bash
pip install pgn-filter
```# Example queries
## Games starting with d4
```python
from chess import Movedef query(game):
first_move = list(game.mainline_moves())
if first_move[0] == Move.from_uci("d2d4"):
return True
return False
```
## Games with no castling moves
```python
from chess import Boarddef query(game):
board = Board()
for move in game.mainline_moves():
if board.is_castling(move):
return False
return True
```# Program usage
```
usage: pgn-filter [-h] [-f FILE] [-i] [-q QUERY] [-m rating] [-M rating] [-a rating] [-F] [-S]A small program to query for games inside PGN documents
options:
-h, --help show this help message and exit
-f FILE, --file FILE The PGN file to search through
-i, --stdin Read from STDIN
-q QUERY, --query QUERY
The Python file containing the query to use
-m rating, --minimum-rating rating
The minimum rating of games to consider
-M rating, --maximum-rating rating
The maximum rating of games to consider
-a rating, --average-rating rating
The rating range to consider
-F, --fast Only consider bullet games
-S, --slow Only consider blitz games and slowerEvery month I look through some ten thousand games ~ Vladimir Kramnik
```