|
|
|
@ -4,6 +4,7 @@ use chess::{Board, MoveGen, EMPTY};
|
|
|
|
|
use config::INFO;
|
|
|
|
|
use rand::seq::IteratorRandom;
|
|
|
|
|
use std::io::{self, BufRead};
|
|
|
|
|
use std::process;
|
|
|
|
|
use std::str::FromStr;
|
|
|
|
|
use vampirc_uci::parse_one;
|
|
|
|
|
use vampirc_uci::{
|
|
|
|
@ -35,11 +36,16 @@ fn main() {
|
|
|
|
|
}
|
|
|
|
|
UciMessage::UciNewGame => board = Some(Board::default()),
|
|
|
|
|
UciMessage::Position {
|
|
|
|
|
startpos: _,
|
|
|
|
|
startpos,
|
|
|
|
|
fen,
|
|
|
|
|
moves,
|
|
|
|
|
} => {
|
|
|
|
|
// NOTE: we can ignore startpos because UciNewGame already sets it to the default boardstate
|
|
|
|
|
if startpos {
|
|
|
|
|
board = Some(
|
|
|
|
|
Board::from_str("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
|
|
|
|
|
.unwrap(),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
if let Some(fen) = fen {
|
|
|
|
|
board = Some(Board::from_str(fen.as_str()).expect("Invalid FEN board"))
|
|
|
|
|
}
|
|
|
|
@ -84,9 +90,12 @@ fn main() {
|
|
|
|
|
if let Some(board) = board {
|
|
|
|
|
let iter = MoveGen::new_legal(&board).into_iter();
|
|
|
|
|
|
|
|
|
|
println!("bestmove {}", iter.choose(&mut rng).unwrap())
|
|
|
|
|
println!("bestmove {}", iter.choose(&mut rng).unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UciMessage::Quit => {
|
|
|
|
|
process::exit(0);
|
|
|
|
|
}
|
|
|
|
|
_ => {
|
|
|
|
|
todo!()
|
|
|
|
|
}
|
|
|
|
|