0.20.1 (older version) Thoroughness: High Understanding: High
by niklasf on 2021-10-16
These reviews are from Crev, a distributed system for code reviews. To add your review, set up cargo-crev
.
The current version of Shakmaty is 0.27.2.
0.20.1 (older version) Thoroughness: High Understanding: High
by niklasf on 2021-10-16
0.18.0 (older version) Thoroughness: High Understanding: High
by niklasf on 2021-02-24
Previous review still applies for this new release.
Lib.rs has been able to verify that all files in the crate's tarball are in the crate's repository with a git tag matching the version. Please note that this check is still in beta, and absence of this confirmation does not mean that the files don't match.
Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories, so there is a possibility that published crates have a misleading repository URL, or contain different code from the code in the repository.
To review the actual code of the crate, it's best to use cargo crev open shakmaty
. Alternatively, you can download the tarball of shakmaty v0.27.2 or view the source online.
This is a self-assessment. I am the author of this crate.
Soundness: I am highly confident in soundness. Unfortunately, I could not avoid two kinds of unsafe blocks, without major performance impact. Instead, all preconditions are explained thoroughly in comments and asserted with debug assertions.
(1) The optimizer does not reliably elide bounds checks based on the assumption that u64::trailing_zeros() will never be larger than 63. This is important in many hot loops.
(2) The perfect hash function for attack lookups always stays within bounds. This technique is called Magic Bitboards, widely used and very well understood in the chess community. When selecting magic factors, exactly this assumption is tested for all possible inputs.
Correctness: For move generation in standard chess, confidence is based on a large test suite of randomly generated, as well as historical and tricky positions, so called perft tests. The numbers are shared in the chess community and compared across a wide array of implementations.
I am gradually less confident in other features, especially chess variants, simply because they are less popular and played less often, and Zobrist hashing, a recent feature addition.
The library has been used to parse 1 billion recorded real world games (https://database.lichess.org). Some bugs have been found, but in the source of the data, not this library.
For handling of input formats (FEN, SAN, UCI) I reviewed the code thoroughly and used fuzz testing to ensure absence of DOS/panics.