Skip to content

iterative_parallel_mvv_lva panic #162

@brandonros

Description

@brandonros
use pleco::{bots::IterativeSearcher, tools::Searcher, Board};

fn main() {
    let mut clipboard = arboard::Clipboard::new().unwrap();
    let mut last_clipboard_text = "".to_string();
    loop {
        let current_clipboard_text = clipboard.get_text().unwrap();
        if current_clipboard_text.starts_with("FEN: ") {
            if current_clipboard_text != last_clipboard_text {
                let fen = current_clipboard_text[5..].trim();
                let board = Board::from_fen(&fen).unwrap();
                let depth = 10;
                println!("Searching depth {depth} for FEN: {fen}");
                let best_move = IterativeSearcher::best_move(board, depth);
                println!("FEN: {fen} Best move: {}", best_move);
                last_clipboard_text = current_clipboard_text.clone();
            }
        }
        std::thread::sleep(std::time::Duration::from_millis(100));
    }
}
 $ cargo run
   Compiling chess_bot v0.1.0 (/Users/brandon/Desktop/chess_bot)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
     Running `/Users/brandon/.cargo/target/debug/chess_bot`
Searching depth 10 for FEN: 1k6/R7/8/7B/7P/8/5Q2/B3K2R w K - 11 47
thread 'main' panicked at /Users/brandon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pleco-0.5.0/src/bots/iterative_parallel_mvv_lva.rs:39:64:
index out of bounds: the len is 10 but the index is 10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions