#read #stockfish #reader #set #file #binpacks #bmi2

bin+lib sfbinpack

Library to read Stockfish Binpacks

7 releases

0.3.3 Dec 31, 2024
0.3.2 Dec 31, 2024
0.2.1 Dec 30, 2024
0.1.0 Dec 30, 2024

#127 in Compression

Download history 299/week @ 2024-12-24 400/week @ 2024-12-31 109/week @ 2025-01-07

808 downloads per month

GPL-3.0 license

105KB
3K SLoC

Stockfish Binpack

Rust port of the Stockfish binpack reader from the C++ version.

Compile

If your machine has the fast BMI2 instruction set (Zen 3+), you should enable the feature flag

cargo build --release --features bmi2;

or define it in your Cargo.toml file (change version).

[dependencies]
binpack = { version = "0.1.0", features = ["bmi2"] }

Usage

Run the following Cargo command in your project directory:

cargo add sfbinpack
use sfbinpack::CompressedTrainingDataEntryReader;

fn main() {
    let mut reader = CompressedTrainingDataEntryReader::new(
        "test60-2019-2tb7p.min.high-simple-eval-1k.min-v2.binpack", // path to file
    )
    .unwrap();

    while reader.has_next() {
        let entry = reader.next();

        println!("entry:");
        println!("fen {}", entry.pos.fen());
        println!("uci {:?}", entry.mv.as_uci());
        println!("score {}", entry.score);
        println!("ply {}", entry.ply);
        println!("result {}", entry.result);
        println!("\n");

        // progress percentage
        // let percentage = reader.read_bytes() as f64 / reader.file_size() as f64 * 100.0;
    }
}

If you are doing some counting keep in mind to use a u64 type for the counter.

Performance Comparison

Slightly faster when compiled with bmi2 because of _pdep_u64 trick which is missing in the upstream version.

License

GNU General Public License v3.0

https://www.gnu.org/licenses/gpl-3.0.html

Dependencies

~255–710KB
~16K SLoC