// Load a file of games and extract those games which contain 5-4 rook endings.
//

use pgn_filter;

pub fn main () {
    // Create a database and add some games
    let mut db = pgn_filter::Games::new();
    db.add_games("examples/twic1356.pgn").unwrap();

    // Display some information
    println!("Database has {} game(s)", db.iter().count());

    // Create a position definition for 5-4 rook endings
    let filter = pgn_filter::Board::must_have()
        .exactly(1, "R")
        .exactly(1, "r")
        .exactly(5, "P")
        .exactly(4, "p");

    // Extract those games which at some point reach 
    let selected = db.search(&filter);
    selected.to_file("rook-endings.pgn").unwrap();

    // Report and save result
    println!("Selected {} out of {} games", selected.iter().count(), db.iter().count());
}

