chessengine.pgn.parser#

class chessengine.pgn.parser.PGNParser(pgn_files: Optional[list[str]] = None)#

A parser for parsing PGN files and constructing a tree of GameNodes

Parameters:

pgn_files (list[str]) – A list of PGN files passed as strings, path-like objects, or file-like objects

Variables:
  • root_node – The root node of the Game tree that the opening book will start from (always corresponds to a new chess board)

  • games – A list of games parsed by the parser

parse(pgn_file=None)#

Parse the given pgn file if pgn_file is not None. Otherwise, parse all the pgn files in self.pgn_files.

Parameters:

pgn_file – a path to a PGN file as a string, path-like object, or file-like object