<commit_before>//! Represents the state of the engine.

#![allow(dead_code)]

use std::time::Duration;

use game::{Position, Color, Move, NumMoves, NumPlies};
use types::NumNodes;

pub use self::TimeData::{TimeLeft, ExactTime};

pub struct State {
    pub is_debug: bool,
    pub my_side: Color,
    pub pos: Position,
    pub start_search: u64,
    pub search_param: SearchParam,
    pub time_data: TimeData,
}
impl State {
    pub fn is_my_turn(&self) -> bool {
        self.my_side == self.pos.side_to_move()
    }
}

pub struct SearchParam {
    pub search_moves: Option<Vec<Move>>,
    pub depth: Option<NumPlies>,
    pub nodes: Option<NumNodes>,
    pub mate: Option<NumMoves>,
}

#[deriving(Copy, Clone)]
pub enum TimeData {
    TimeLeft(TimeLeftData),
    ExactTime(Duration),
}

#[deriving(Copy, Clone)]
pub struct TimeLeftData {
    pub w_time: Duration,
    pub b_time: Duration,
    pub w_inc: Duration,
    pub b_inc: Duration,
    pub moves_to_go: NumMoves,
}<commit_msg>Edit state module.<commit_after>//! Represents the state of the engine.

#![allow(dead_code)]

use std::time::Duration;

use game::{Position, Color, Move, NumMoves, NumPlies};
use types::NumNodes;

pub use self::TimeData::{TimeLeft, ExactTime};

#[deriving(Clone)]
pub struct State {
    pub is_debug: bool,
    pub pos: Position,
    pub start_search: u64,
    pub search_param: SearchParam,
    pub time_data: TimeData,
}

#[deriving(Clone)]
pub struct SearchParam {
    pub ponder: Option<(Position, Move)>,
    pub search_moves: Option<Vec<Move>>,
    pub depth: Option<NumPlies>,
    pub nodes: Option<NumNodes>,
    pub mate: Option<NumMoves>,
}

#[deriving(Copy, Clone)]
pub enum TimeData {
    TimeLeft(TimeLeftData),
    ExactTime(Duration),
}

#[deriving(Copy, Clone)]
pub struct TimeLeftData {
    pub w_time: Duration,
    pub b_time: Duration,
    pub w_inc: Duration,
    pub b_inc: Duration,
    pub moves_to_go: NumMoves,
}
impl TimeLeftData {
    pub fn time(&self, c: Color) -> Duration {
        match c {
            Color::White => self.w_time,
            Color::Black => self.b_time,
        }
    }
    pub fn set_time(&mut self, c: Color, val: Duration) {
        match c {
            Color::White => self.w_time = val,
            Color::Black => self.b_time = val,
        }
    }
    pub fn inc(&self, c: Color) -> Duration {
        match c {
            Color::White => self.w_inc,
            Color::Black => self.b_inc,
        }
    }
    pub fn set_inc(&mut self, c: Color, val: Duration) {
        match c {
            Color::White => self.w_inc = val,
            Color::Black => self.b_inc = val,
        }
    }
}
{'fraction_non_alphanumeric': 0.12807881773399016, 'fraction_numerical': 0.0015157256536566881, 'mean_word_length': 2.911111111111111, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4286405', 'n_tokens_mistral': 910, 'n_tokens_neox': 903, 'n_words': 241}