gunyarakun / python-shogi

A pure Python shogi library with move generation and validation and handling of common formats.
GNU General Public License v3.0
181 stars 43 forks source link

KIF parsing of non-promotion 不成 #54

Closed ianfab closed 2 years ago

ianfab commented 2 years ago

I encountered a kifu where a silver move refraining from promotion seems to explicitly contain this information using the suffix 不成.

100 7七銀不成(68) (00:00/00:00:00)

As a quick workaround I simply normalize this suffix away. If you consider this a sufficient fix I can also raise a PR, otherwise I guess you might want to adjust the regex for parsing.

gunyarakun commented 2 years ago

At first, sorry for my late response, @ianfab san.

In the formal document of KIF file, they say 不成の場合は、「不成」を表記しない。 (If not promoted, don't put 不成). http://kakinoki.o.oo7.jp/kif_format.html So the KIF file is invalid originally.

To handle such kind of invalid KIF files, just replacing 不成 to `` as you did is a good solution.

ianfab commented 2 years ago

Thanks for your feedback. Just created a corresponding PR.