-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi,
I am a former contributor to https://github.com/notnil/chess and just recently discovered that you've taken over the library. I am working on porting over the 4 outstanding pull requests that I had sent. 3 of the 4 were trivial and I've posted those PRs. The 4th is non-trivial due to what looks like a heavy refactor of scanner.go. For reference my original PR is here: notnil/chess#127 which added a scanner option to expand variations within a single game. e.g. For a .pgn containing:
[Event "opening prep"]
[Result "*"]
[Variant "Standard"]
[ECO "C10"]
[Opening "French Defense: Paulsen Variation"]
[UTCDate "2025.07.10"]
[UTCTime "19:53:02"]
1. e4 e6 2. d4 d5 3. Nc3 { Paulsen French } (3. e5 { Advance French }) (3. exd5 { Exchange French }) *
Scanner today will treat that as a single game. My PR added a flag which allow the consumers of Scanner to specify that Scanner() should instead return 3 games. Before proceeding with rewriting the feature I wanted some feedback first. My thought was to extend Scanner.nextGame into a slice (https://github.com/CorentinGS/chess/blob/main/scanner.go#L75) and then have ScanGame() (https://github.com/CorentinGS/chess/blob/main/scanner.go#L102) check for the option. when the option is set, re-parse s.scanner.Text() and split into multiple GameScanned. In this way the only performance penalty for the default Scanner is the test for the option; otherwise all of the performance tax is borne by users who want to expand variations. There are certainly alternative approaches though and thought I should solicit feedback before proceeding.