use search::apply_move; use bitboard::Bitboard; use game::Game; use search::*; use std::io::Write; use movegen::*; use log::{info}; use std::sync::mpsc::{Receiver, Sender}; pub enum EngineMsg { SetBoard(Game), SetPiece(Bitboard), Search(i32), Ping, Stop, NewGame, GetState, GetInfo, } pub enum EngineState { Idle, Searching } pub enum InterfaceMsg { BestMove(Move), State(EngineState) } pub fn run_engine(r: Receiver, s: Sender) { let mut game = Game::default(); for msg in r { //game.pieces[0] = 0x00ff_0000_0000_0100; //game.pieces[QUEEN as usize] = 0x0000_0000_0000_0080; //game.pieces[10] = 0x4000_0000_0000_0000; match msg { EngineMsg::SetBoard(g) => { //println!("SetBoard"); game = g; }, EngineMsg::SetPiece(_) => { println!("SetPiece") }, EngineMsg::Search(depth) => { //info!("searching in pos\n {}", game.beautiful_print()); //println!("Search {}", depth); let best_move = search(&game, depth); println!("bestmove {}", best_move.to_string()); info!("bestmove {}", best_move.to_string()); }, EngineMsg::Ping => { println!("Ping") }, EngineMsg::Stop => { println!("Stop") }, EngineMsg::NewGame => { //println!("NewGame") }, EngineMsg::GetState => { println!("GetState") }, EngineMsg::GetInfo => { println!("GetInfo") }, } //println!("{}", game.beautiful_print()); //let moves = generate_moves(&game, WHITE); } }