use std::env;
use std::error::Error;
use std::path::Path;
use connect_four_ai::OpeningBookGenerator;
fn main() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
let depth = args.get(1)
.and_then(|arg| arg.parse().ok())
.expect("Please specify a depth as the first command line argument.");
let path = Path::new(args.get(2)
.map_or("book.bin", |s| s));
println!("Generating opening book to depth {depth}...");
let book = OpeningBookGenerator::generate(depth);
println!("Saving book with {} positions to {:?}...", book.map.len(), path);
book.save(path).expect("Failed to save opening book.");
println!("Successfully saved opening book.");
Ok(())
}