Update engine.py#11
Conversation
the old one is for chess, not for xiangqi
There was a problem hiding this comment.
Pull Request Overview
This PR updates the UCI (Universal Chess Interface) regex pattern to support Xiangqi (Chinese chess) instead of standard chess. The change modifies the coordinate system and piece notation to match Xiangqi's 9x10 board layout and piece set.
- Updates regex pattern from chess coordinates (a-h, 1-8) to Xiangqi coordinates (a-i, 0-9)
- Changes piece notation from chess pieces (pnbrqk/PNBRQK) to Xiangqi pieces (pnbrack/PNBRACK)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
|
|
||
| UCI_REGEX = re.compile(r"^[a-h][1-8][a-h][1-8][pnbrqk]?|[PNBRQK]@[a-h][1-8]|0000\Z") | ||
| UCI_REGEX = re.compile(r"^[a-i][0-9][a-i][0-9][pnbrack]?|[PNBRACK]@[a-i][0-9]|0000\Z") |
There was a problem hiding this comment.
The regex pattern [0-9] matches any single digit (0-9), but Xiangqi uses a 10x9 board with ranks 0-9. This means rank 10 would require two digits and won't be matched by this single digit pattern. Consider using a more specific pattern like [0-9]|10 or (?:[0-9]|10) to properly handle rank 10.
| UCI_REGEX = re.compile(r"^[a-i][0-9][a-i][0-9][pnbrack]?|[PNBRACK]@[a-i][0-9]|0000\Z") | |
| UCI_REGEX = re.compile(r"^[a-i](?:[0-9]|10)[a-i](?:[0-9]|10)[pnbrack]?|[PNBRACK]@[a-i](?:[0-9]|10)|0000\Z") |
|
Thanks for your contribution!😊 |
the old one is for chess, not for xiangqi