Open PikaCat-OuO opened 5 months ago
感谢!您提出的问题,我来改改~
对于您提到的三兵进一、三兵平六等走法报错,是因为我代码里的解析规则采用了“旧的记谱方式”,可见维基百科 - 象棋 - 记谱方法中第2点第三小点的说明,按此记谱法,原谱中的“三兵进一”、“三兵平六”,应改为“前七进一”、“前七平六”。如有额外的解析需求,等我后面空了再看看怎么添加。
应该不难,可以把这个 https://github.com/windshadow233/python-chinese-chess/blob/5a59068df50059bb5d18c648e8ca3a3b41b974de/cchess/__init__.py#L2246-L2247 改成这个看看,同时兼容新旧两种记法
if multi_pawns_col_number > 1 and pawn_column is None:
# 可能是新的兵(卒)记法
count = ['一', '二', '三', '四', '五'].index(rank_notation)
for i, num in enumerate(reversed(pawn_nums) if color else pawn_nums):
if num >= 2:
if count >= num:
count -= num
else:
pawn_column = 8 - i if color else i
rank_notation = (['前', '后'] if num == 2 else ['前', '中', '后'])[count]
break
else:
raise ValueError("旧记法:记号存在歧义(未指明兵(卒)所在列) 或 新记法:记号中兵(卒)的数量超出实际兵(卒)的数量")
太感谢了!我最近也是忙得很 没啥时间细看以前写的屎山代码。过会我看看更新一下您提供的代码在 2024年2月3日,15:55,PikaCat @.***> 写道: 应该不难,可以把这个 https://github.com/windshadow233/python-chinese-chess/blob/5a59068df50059bb5d18c648e8ca3a3b41b974de/cchess/__init__.py#L2246-L2247 改成这个看看,同时兼容新旧两种记法 if multi_pawns_col_number > 1 and pawn_column is None:
if multi_pawns_col_number == 2:
count = ['一', '二', '三', '四', '五'].index(rank_notation)
for i, num in enumerate(reversed(pawn_nums) if color else pawn_nums):
if num >= 2:
if count >= num:
count -= num
else:
pawn_column = 8 - i if color else i
rank_notation = (['前', '后'] if num == 2 else ['前', '中', '后'])[count]
break
else:
raise ValueError("记号存在歧义(未指明兵(卒)所在列)")
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
甚是有理!
2024年2月4日 21:02,PikaCat @.***> 写道:
我觉得,你还需要修改: https://github.com/windshadow233/python-chinese-chess/blob/8cc3651939e0ee72710affd3999321dd88463025/cchess/__init__.py#L2189 https://github.com/windshadow233/python-chinese-chess/blob/8cc3651939e0ee72710affd3999321dd88463025/cchess/__init__.py#L2189 https://github.com/windshadow233/python-chinese-chess/blob/8cc3651939e0ee72710affd3999321dd88463025/cchess/__init__.py#L1955 https://github.com/windshadow233/python-chinese-chess/blob/8cc3651939e0ee72710affd3999321dd88463025/cchess/__init__.py#L1955 以识别”一兵平x“的notation
— Reply to this email directly, view it on GitHub https://github.com/windshadow233/python-chinese-chess/issues/3#issuecomment-1925741698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMCSSQAX4XTOM7DONJIF5WLYR6BG3AVCNFSM6AAAAABCXU6WA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVG42DCNRZHA. You are receiving this because you commented.
https://github.com/windshadow233/python-chinese-chess/blob/5a59068df50059bb5d18c648e8ca3a3b41b974de/cchess/__init__.py#L391
这里的90应该是 < 而不是 <=
此外,对于以下pgn,无法解析: test.zip
对于诸如”三兵平x“,貌似无法解析: https://www.xqbase.com/protocol/cchess_move.htm
会抛出下面这个异常 https://github.com/windshadow233/python-chinese-chess/blob/5a59068df50059bb5d18c648e8ca3a3b41b974de/cchess/__init__.py#L2247