AttackingOrDefending / pydraughts

A draughts (checkers) library for Python with move generation, PDN reading and writing, engine communication and balloted openings
MIT License
13 stars 5 forks source link

hub move format: parsing might fail if captures aren't ordered #23

Closed colette-b closed 2 years ago

colette-b commented 2 years ago

Parsing moves in hub format might fail, if the move has the captures unordered. I use this definition of the hub protocol, which says the captures can be ordered arbitrarily: https://github.com/rhalbersma/scan/blob/master/protocol.txt In the example below, first move is parsed correctly and the second one raises an error.

import draughts

g2 = draughts.Game(variant='brazilian', fen='Bbbbbebbbbbwbeeeewweeweeewwewwwww')
move_ok = draughts.Move(board=g2, hub_move='8x13x11x17x18')
move_bad = draughts.Move(board=g2, hub_move='8x13x11x18x17')
AttackingOrDefending commented 2 years ago

I also used this definition of the Hub protocol but I can't find the part that it says that captures can be ordered arbitrarily. Hub engines return the captures in order. I have created a PR with a fix for this.

colette-b commented 2 years ago

The linked file says: "For captures, all the captured pieces (but not the pivots) are included in any order like this: from x to x captured x captured ... without any spaces." Anyway, I checked the pull request and it fixes the issue for me. Thank you very much! :+1:

AttackingOrDefending commented 2 years ago

I had missed this. Thanks.