|
@@ -1,16 +1,8 @@
|
|
|
-use std::io::{self, BufRead};
|
|
|
use std::collections::BTreeMap;
|
|
|
-use std::sync::mpsc::{Receiver, Sender};
|
|
|
-
|
|
|
-use std::process::exit;
|
|
|
|
|
|
use engine::{Command, SearchInfo};
|
|
|
use board::Board;
|
|
|
|
|
|
-use log::info;
|
|
|
-
|
|
|
-use crate::evaluate::PosValue;
|
|
|
-
|
|
|
|
|
|
pub fn parse_command(command: &str) -> Result<Command, String> {
|
|
|
let parts = command.split_whitespace().collect::<Vec<&str>>();
|
|
@@ -32,7 +24,8 @@ pub fn parse_command(command: &str) -> Result<Command, String> {
|
|
|
"ucinewgame" => cmd_newgame(cmd, r, s),
|
|
|
//"setoption" => cmd_setoption(cmd, r, s),
|
|
|
"quit" | "exit" => cmd_quit(cmd, r, s),*/
|
|
|
- cmd => { Err("unknown command".to_owned()) }
|
|
|
+ "" => Ok(Command::Ping),
|
|
|
+ _cmd => { Err("unknown command".to_owned()) }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -81,65 +74,6 @@ fn parse_position(args: &Vec<&str>) -> Result<Command, String> {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/*fn run_command(mut cmd: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<Command>) {
|
|
|
- if cmd.len() > 0 {
|
|
|
- let command = cmd[0];
|
|
|
- cmd.drain(0..1);
|
|
|
- match command {
|
|
|
- "uci" => cmd_uci(cmd),
|
|
|
- "isready" => cmd_isready(cmd, r, s),
|
|
|
- "position" => cmd_position(cmd, r, s),
|
|
|
- "print" => cmd_print(cmd, r, s),
|
|
|
- "go" => cmd_go(cmd, r, s),
|
|
|
- "stop" => cmd_stop(cmd, r, s),
|
|
|
- "ucinewgame" => cmd_newgame(cmd, r, s),
|
|
|
- //"setoption" => cmd_setoption(cmd, r, s),
|
|
|
- "quit" | "exit" => cmd_quit(cmd, r, s),
|
|
|
- cmd => { println!("unknown command: {}", cmd); }
|
|
|
- }
|
|
|
- }
|
|
|
-}*/
|
|
|
-
|
|
|
-/*fn cmd_isready(_args: Vec<&str>, _r: &Receiver<InterfaceMsg>, s: &Sender<Command>) {
|
|
|
- s.send(Command::IsReady).unwrap();
|
|
|
-}
|
|
|
-
|
|
|
-fn cmd_position(mut args: Vec<&str>, _r: &Receiver<InterfaceMsg>, s: &Sender<Command>) {
|
|
|
- let position = args[0];
|
|
|
- args.drain(0..1);
|
|
|
-
|
|
|
- let mut game = Board::default();
|
|
|
-
|
|
|
- if position == "startpos" {
|
|
|
- }
|
|
|
- else if position == "fen" {
|
|
|
- let fen_parts: Vec<&str> = Vec::from(&args[0..6]).into_iter().collect::<Vec<&str>>();
|
|
|
- game = Board::from_fen(fen_parts.as_slice()).unwrap_or_else(|| {
|
|
|
- info!("invalid fen");
|
|
|
- println!("invalid fen");
|
|
|
- Board::default()
|
|
|
- });
|
|
|
- args.drain(0..6);
|
|
|
- }
|
|
|
- let moves =
|
|
|
- if args.len() > 0 {
|
|
|
- if args[0] != "moves" {
|
|
|
- info!("unexpected {}", args[6]);
|
|
|
- println!("unexpected {}", args[6]);
|
|
|
- }
|
|
|
- args.drain(0..1);
|
|
|
-
|
|
|
-
|
|
|
- args.into_iter().map(|m| String::from(m)).collect::<Vec<String>>()
|
|
|
- }
|
|
|
- else {
|
|
|
- Vec::new()
|
|
|
- };
|
|
|
-
|
|
|
- s.send(Command::Position{ pos: game, moves }).unwrap();
|
|
|
-}*/
|
|
|
-
|
|
|
-
|
|
|
pub fn parse_go(args: &Vec<&str>) -> Result<Command, String> {
|
|
|
let mut options: BTreeMap<String, String> = BTreeMap::new();
|
|
|
let mut opt_name: Option<&str> = None;
|