Add skeleton for options
This commit is contained in:
parent
c0ce3b7bff
commit
a46ff43db4
|
@ -5,6 +5,7 @@ pub mod uci_command;
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use std::io::*;
|
use std::io::*;
|
||||||
|
use std::time::Duration;
|
||||||
use crate::uci_command::*;
|
use crate::uci_command::*;
|
||||||
|
|
||||||
use chess::{Game, Board, ChessMove};
|
use chess::{Game, Board, ChessMove};
|
||||||
|
@ -38,6 +39,26 @@ pub struct UciEngine<Fi: Read, Fo: Write> {
|
||||||
id: Id,
|
id: Id,
|
||||||
initial: Board,
|
initial: Board,
|
||||||
game: Game,
|
game: Game,
|
||||||
|
/// white (total, incr), black (total, incr)
|
||||||
|
time: ((Option<Duration>, Option<Duration>), (Option<Duration>, Option<Duration>)),
|
||||||
|
/// white, black
|
||||||
|
player: (Player, Player)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum UciOption {
|
||||||
|
Ponder{value: bool},
|
||||||
|
UCIElo{value: Option<u32>},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum Player{Human{elo: Option<u32>}, Machine{elo: Option<u32>}}
|
||||||
|
pub enum GameOption {
|
||||||
|
WhiteTotalTime{value: Option<Duration>},
|
||||||
|
BlackTotalTime{value: Option<Duration>},
|
||||||
|
WhiteIncrement{value: Option<Duration>},
|
||||||
|
BlackIncrement{value: Option<Duration>},
|
||||||
|
WhitePlayer{value: Player},
|
||||||
|
BlackPlayer{value: Player},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Fi: Read, Fo: Write> UciEngine<Fi, Fo> {
|
impl<Fi: Read, Fo: Write> UciEngine<Fi, Fo> {
|
||||||
|
@ -52,10 +73,32 @@ impl<Fi: Read, Fo: Write> UciEngine<Fi, Fo> {
|
||||||
id: Id::new(),
|
id: Id::new(),
|
||||||
uciok: false,
|
uciok: false,
|
||||||
initial: Board::default(),
|
initial: Board::default(),
|
||||||
game: Game::new()
|
game: Game::new(),
|
||||||
|
time: ((None, None), (None, None)),
|
||||||
|
player: (Player::Human{elo: None}, Player::Human{elo: None}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn game_option(&mut self, option: GameOption) -> GameOption {
|
||||||
|
let old_value: GameOption;
|
||||||
|
match option {
|
||||||
|
GameOption::WhiteTotalTime{value} => {old_value = GameOption::WhiteTotalTime { value: self.time.0.0 };
|
||||||
|
self.time.0.0 = value},
|
||||||
|
GameOption::BlackTotalTime{value} => {old_value = GameOption::BlackTotalTime { value: self.time.1.0 };
|
||||||
|
self.time.1.0 = value},
|
||||||
|
GameOption::WhiteIncrement{value} => {old_value = GameOption::WhiteIncrement { value: self.time.0.1 };
|
||||||
|
self.time.0.1 = value},
|
||||||
|
GameOption::BlackIncrement{value} => {old_value = GameOption::BlackIncrement { value: self.time.1.1 };
|
||||||
|
self.time.1.1 = value},
|
||||||
|
GameOption::WhitePlayer{value} => {old_value = GameOption::WhitePlayer { value: self.player.0 };
|
||||||
|
self.player.0 = value},
|
||||||
|
GameOption::BlackPlayer{value} => {old_value = GameOption::WhitePlayer { value: self.player.1 };
|
||||||
|
self.player.1 = value},
|
||||||
|
}
|
||||||
|
|
||||||
|
old_value
|
||||||
|
}
|
||||||
|
|
||||||
/// Launch uci engine initialisation
|
/// Launch uci engine initialisation
|
||||||
///
|
///
|
||||||
/// Retrieve data from uci engine (until uciok command from engine)
|
/// Retrieve data from uci engine (until uciok command from engine)
|
||||||
|
|
Loading…
Reference in New Issue