|
@@ -1,31 +1,35 @@
|
|
use std::io::{self, BufRead};
|
|
use std::io::{self, BufRead};
|
|
|
|
+use std::sync::mpsc::{Receiver, Sender};
|
|
|
|
|
|
|
|
+use engine::{EngineMsg, InterfaceMsg};
|
|
|
|
|
|
-pub fn run() {
|
|
|
|
|
|
+
|
|
|
|
+pub fn run(r: Receiver<InterfaceMsg>, s: Sender<EngineMsg>) {
|
|
let stdin = io::stdin();
|
|
let stdin = io::stdin();
|
|
- println!("id name bishop 1.0");
|
|
|
|
- println!("id author bishop");
|
|
|
|
for line_m in stdin.lock().lines() {
|
|
for line_m in stdin.lock().lines() {
|
|
let line = line_m.unwrap();
|
|
let line = line_m.unwrap();
|
|
let mut split = line.split_whitespace().collect::<Vec<&str>>();
|
|
let mut split = line.split_whitespace().collect::<Vec<&str>>();
|
|
- run_command(split);
|
|
|
|
|
|
+ run_command(split, &r, &s);
|
|
|
|
+ s.send(EngineMsg::Ping);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-fn run_command(mut cmd: Vec<&str>) {
|
|
|
|
|
|
+fn run_command(mut cmd: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
|
|
if cmd.len() > 0 {
|
|
if cmd.len() > 0 {
|
|
let command = cmd[0];
|
|
let command = cmd[0];
|
|
cmd.drain(0..1);
|
|
cmd.drain(0..1);
|
|
match command {
|
|
match command {
|
|
"uci" => cmd_uci(cmd),
|
|
"uci" => cmd_uci(cmd),
|
|
"isready" => cmd_isready(cmd),
|
|
"isready" => cmd_isready(cmd),
|
|
- "register" => cmd_register(cmd),
|
|
|
|
- _ => {}
|
|
|
|
|
|
+ "go" => cmd_go(cmd, r, s),
|
|
|
|
+ cmd => { println!("unknown command: {}", cmd); }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
fn cmd_uci(_args: Vec<&str>) {
|
|
fn cmd_uci(_args: Vec<&str>) {
|
|
|
|
+ println!("id name bishop 1.0");
|
|
|
|
+ println!("id author bishop");
|
|
println!("uciok");
|
|
println!("uciok");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -33,7 +37,8 @@ fn cmd_isready(_args: Vec<&str>) {
|
|
println!("readyok");
|
|
println!("readyok");
|
|
}
|
|
}
|
|
|
|
|
|
-fn cmd_register(_args: Vec<&str>) {
|
|
|
|
|
|
+fn cmd_go(args: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
|
|
|
|
+ println!("searchin' da game!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -41,5 +46,3 @@ fn cmd_register(_args: Vec<&str>) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|