Browse Source

small tweaks

Nicolas Winkler 3 years ago
parent
commit
de71355202
2 changed files with 20 additions and 5 deletions
  1. 11 0
      src/engine.rs
  2. 9 5
      src/interface.rs

+ 11 - 0
src/engine.rs

@@ -12,6 +12,7 @@ pub enum EngineMsg {
     Search(i32),
     Search(i32),
     Ping,
     Ping,
     Stop,
     Stop,
+    NewGame,
     GetState,
     GetState,
     GetInfo,
     GetInfo,
 }
 }
@@ -36,6 +37,16 @@ pub fn run_engine(r: Receiver<EngineMsg>, s: Sender<InterfaceMsg>) {
         //game.pieces[QUEEN as usize] = 0x0000_0000_0000_0080;
         //game.pieces[QUEEN as usize] = 0x0000_0000_0000_0080;
         //game.pieces[10] = 0x4000_0000_0000_0000;
         //game.pieces[10] = 0x4000_0000_0000_0000;
 
 
+        match msg {
+            EngineMsg::SetBoard(_) => { println!("SetBoard") },
+            EngineMsg::SetPiece(_) => { println!("SetPiece") },
+            EngineMsg::Search(depth) => { println!("Search {}", depth) },
+            EngineMsg::Ping => { println!("Ping") },
+            EngineMsg::Stop => { println!("Stop") },
+            EngineMsg::GetState => { println!("GetState") },
+            EngineMsg::GetInfo => { println!("GetInfo") },
+        }
+
         println!("{}", game.beautiful_print());
         println!("{}", game.beautiful_print());
 
 
         //let moves = generate_moves(&game, WHITE);
         //let moves = generate_moves(&game, WHITE);

+ 9 - 5
src/interface.rs

@@ -10,9 +10,8 @@ pub fn run(r: Receiver<InterfaceMsg>, s: Sender<EngineMsg>) {
     let stdin = io::stdin();
     let stdin = io::stdin();
     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 split = line.split_whitespace().collect::<Vec<&str>>();
         run_command(split, &r, &s);
         run_command(split, &r, &s);
-        s.send(EngineMsg::Ping);
     }
     }
 }
 }
 
 
@@ -24,6 +23,7 @@ fn run_command(mut cmd: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<Engine
             "uci" => cmd_uci(cmd),
             "uci" => cmd_uci(cmd),
             "isready" => cmd_isready(cmd),
             "isready" => cmd_isready(cmd),
             "go" => cmd_go(cmd, r, s),
             "go" => cmd_go(cmd, r, s),
+            "ucinewgame" => cmd_newgame(cmd, r, s),
             "quit" | "exit" => cmd_quit(cmd, r, s),
             "quit" | "exit" => cmd_quit(cmd, r, s),
             cmd => { println!("unknown command: {}", cmd); }
             cmd => { println!("unknown command: {}", cmd); }
         }
         }
@@ -40,11 +40,15 @@ fn cmd_isready(_args: Vec<&str>) {
     println!("readyok");
     println!("readyok");
 }
 }
 
 
-fn cmd_go(args: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
-    println!("searchin' da game!");
+fn cmd_go(_args: Vec<&str>, _r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
+    s.send(EngineMsg::Search(3)).unwrap();
 }
 }
 
 
-fn cmd_quit(args: Vec<&str>, r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
+fn cmd_newgame(_args: Vec<&str>, _r: &Receiver<InterfaceMsg>, s: &Sender<EngineMsg>) {
+    s.send(EngineMsg::NewGame).unwrap();
+}
+
+fn cmd_quit(_args: Vec<&str>, _r: &Receiver<InterfaceMsg>, _s: &Sender<EngineMsg>) {
     exit(0);
     exit(0);
 }
 }