In the end, I decided to optimize the existing implementation. Initially I tried to reuse an exising fast parser from other open-source projects, but realized after some time that this would essentially result in a complete rewrite of Jerry, due to very different underlying data-structures and game representations. That’s the first line in the table above. I benchmarked this by reading each game from a subset of the KingBaseLite database and constructing the full underlying game tree for each game. Split the line into tokens (like a move token, annotations, comments etc.)Įxtract the target file and piece type (and row/line disambiguity markers)įind the unique move among all legal moves of that piece type and The algorithm was like this: read each line in the PGN file When I originally implemented PGN parsing, I took a look at python-chess – really excellent, easy to read code. New Parser, compute only pseudo-legal movesĪbove plus no pseudo-legal move generation if only once pieceĪbove plus no QString uci as class member of Move Even though Jerry is not primarily database program, such basic functionality should be present. Nevertheless, PGN is here to stay, and so my goal is to quickly parse huge PGN files in order to be able to search for arbitrary positions. For a human it’s easy to spot the source-field, but for a computer it means that the program has to know the chess-rules to figure out which move is executed (there are shortcuts, as described below). The main difficulty in parsing PGN files – aside from a lot of ambiguities – is SAN notation, i.e. The odd thing here is that PGN files are rarely created manually, almost everyone uses a chess program to enter or edit moves, and then save the game afterwards. At a cost, namely that it’s difficult to parse it with computers. PGN is designed to make it easy for humans to read PGN files, and edit or write them manually with a text editor. Apparently, it’s not just me who thinks so. Unfortunately, PGN is somewhat misdesigned. PGN is the de-facto standard for chess games, especially when it comes to interoperability.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |