use std::{f32::INFINITY, time::{Duration, Instant}};

use chessnost::board::Board;

fn main() {
    let mut board = Board::new();

    board.print();
    loop {
        let mov = match board.read_move() {
            Ok(m) => m,
            Err(e) => {
                println!("Error: {}", e);
                continue;
            }
        };
        print!("{:?}", mov);
        board.make_move(mov);
        board.print();

        let start = Instant::now();
        let (score, pv) = board.iterative_deepening(10, Duration::from_secs(7));
        println!("Finished in {:?}: score={:?}", start.elapsed(), score);

        let mov = pv[0];
        println!("{:?}", mov);
        board.make_move(mov);
        board.print();
        println!("Score for {:?} is now: {}", board.color(), board.quiscence(-INFINITY, INFINITY));

        // Simple pondering during opponent time
        board.iterative_deepening(5, Duration::from_secs(3));
    }
}