use uci::SetOption;
use board::{Board, IllegalBoard};
use moves::{Move, MoveDigest, AddMove};
use depth::*;
use value::*;
use evaluator::Evaluator;
use qsearch::QsearchResult;
pub trait SearchNode: Clone + SetOption + Send + 'static {
type Evaluator: Evaluator;
type QsearchResult: QsearchResult;
fn from_history(fen: &str, moves: &mut Iterator<Item = &str>) -> Result<Self, IllegalBoard>;
fn hash(&self) -> u64;
fn board(&self) -> &Board;
fn halfmove_clock(&self) -> u8;
fn fullmove_number(&self) -> u16;
fn is_check(&self) -> bool;
fn evaluator(&self) -> &Self::Evaluator;
fn evaluate_final(&self) -> Value;
fn evaluate_move(&self, m: Move) -> Value;
fn qsearch(&self,
depth: Depth,
lower_bound: Value,
upper_bound: Value,
static_eval: Value)
-> Self::QsearchResult;
fn generate_moves<T: AddMove>(&self, moves: &mut T);
fn try_move_digest(&self, move_digest: MoveDigest) -> Option<Move>;
fn null_move(&self) -> Move;
fn last_move(&self) -> Move;
fn do_move(&mut self, m: Move) -> bool;
fn undo_last_move(&mut self);
fn legal_moves(&self) -> Vec<Move> {
let mut position = self.clone();
let mut legal_moves = Vec::with_capacity(96);
let mut v = Vec::with_capacity(96);
position.generate_moves(&mut v);
for m in v.iter() {
if position.do_move(*m) {
legal_moves.push(*m);
position.undo_last_move();
}
}
legal_moves
}
}