yo35 / kokopu

A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.
https://www.npmjs.com/package/kokopu
GNU Lesser General Public License v3.0
27 stars 5 forks source link

add isInsufficientMaterial method #35

Closed vladmandic closed 2 years ago

vladmandic commented 2 years ago

adds method to detect insufficient material to end game in checkmate under both FIDE and USCF rules.
further notes in previous version of the pr #34

yo35 commented 2 years ago

For information, I've added some unit tests (see in particular in file /test/resources/positions.csv, rows Low material *), and I had to modify your implementation of isDead() to make them work, especially in situations with several same-colored bishops (e.g. king + 2 same-colored bishops vs king is a dead position).

Public API is unchanged compared to the PR.