niklasf / python-chess

A chess library for Python, with move generation and validation, PGN parsing and writing, Polyglot opening book reading, Gaviota tablebase probing, Syzygy tablebase probing, and UCI/XBoard engine communication
https://python-chess.readthedocs.io/en/latest/
GNU General Public License v3.0
2.4k stars 521 forks source link

Get captured pieces #231

Closed PedanticHacker closed 6 years ago

PedanticHacker commented 6 years ago

Is there a (simple) way in python-chess to get captured pieces? I want to display an SVG image for each captured piece.

Mk-Chan commented 6 years ago

For every piece type(pawn,knight...queen) just popcount the bitboard(in BaseBoard) and subtract from the maximum number of that piece type.

For variants that modify the number of pieces you'll just have to count how many of each piece.

PedanticHacker commented 6 years ago

Thanks. 😉