Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from IPython.display import SVG, display
- import chess.svg
- import chess
- import chess.pgn
- import io
- filepath = 'Downloads/lichess_camille4711_2018-07-17.pgn'
- filepath = 'Downloads/db.pgn'
- game = ""
- with open(filepath) as fp:
- line = fp.readline()
- cnt = 1
- while line:
- game += line
- if line.count("=Q")>=6:
- pgn = io.StringIO(game)
- g = chess.pgn.read_game(pgn)
- b = g.board()
- for move in g.main_line(): b.push(move)
- if len(b.pieces(chess.QUEEN,chess.BLACK)) > 6 or len(b.pieces(chess.QUEEN,chess.WHITE)) > 6:
- print(game)
- if line.startswith("1."):
- game = ""
- line = fp.readline()
- cnt += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement