瀏覽代碼

fixing stack overflow

Nicolas Winkler 2 年之前
父節點
當前提交
ca19d6db66
共有 3 個文件被更改,包括 7 次插入30 次删除
  1. 3 2
      src/engine.rs
  2. 1 24
      src/main.rs
  3. 3 4
      src/search.rs

+ 3 - 2
src/engine.rs

@@ -2,6 +2,7 @@ use bitboard::Bitboard;
 use board::Board;
 use search::*;
 use movegen::*;
+use std::io::BufRead;
 use std::process::exit;
 use std::sync::mpsc::{Sender, self};
 use std::time::Duration;
@@ -96,8 +97,8 @@ impl Engine {
         eng
     }
 
-    pub fn run(&mut self, input: std::io::Stdin) {
-        for line_m in input.lines() {
+    pub fn run(&mut self) {
+        for line_m in std::io::stdin().lock().lines() {
             let line = line_m.unwrap();
 
             //println!("received line: {}", line);

+ 1 - 24
src/main.rs

@@ -19,31 +19,8 @@ use engine::Engine;
 
 
 fn main() {
-    /*let mut builder = Builder::from_default_env();
-    builder
-        .filter(None, LevelFilter::Info)
-        .target(Target::Pipe(Box::new(File::create("debug.log").unwrap())))
-        //.target(Target::Stderr)
-        .init();
-        */
-
-    //let logfile = File::create("C:\\Users\\Nicolas\\debug.log").unwrap();
-    //simplelog::WriteLogger::init(LevelFilter::Info, Config::default(), logfile).unwrap();
-    /*const_assert_eq!(std::mem::size_of::<Move>(), 4);
-
-    let (esend, erecv) = mpsc::channel();
-    let (isend, irecv) = mpsc::channel();
-
-    // spawn engine thread
-    thread::spawn(move || {
-        let mut engine = Engine::new(erecv, isend);
-        engine.run();
-    });
-
-    interface::run(irecv, esend);*/
-
     let mut engine = Engine::new();
-    engine.run(std::io::stdin());
+    engine.run();
 }
 
 

+ 3 - 4
src/search.rs

@@ -667,16 +667,15 @@ impl SearchControl {
 
 
 pub struct CountermoveTable {
-    table: [[[[i16; 12]; 64]; 12]; 64],
+    table: Box<[[[[i16; 12]; 64]; 12]]>,
 }
 
-unsafe impl Send for CountermoveTable { }
-unsafe impl Sync for CountermoveTable { }
 
 impl CountermoveTable {
 
     pub fn new() -> Self {
-        CountermoveTable { table: [[[[0; 12]; 64]; 12]; 64] }
+        //CountermoveTable { table: Box::new([[[[0; 12]; 64]; 12]; 64]) }
+        CountermoveTable { table: vec![[[[0; 12]; 64]; 12]; 64].into_boxed_slice() }
     }
 
     pub fn get_score(&self, side: Side, last_move: Move, this_move: Move) -> i16 {