|  | @@ -155,13 +155,11 @@ impl Engine {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    #[allow(dead_code)]
 | 
	
		
			
				|  |  | -    fn reconstruct_pv(&self) -> Vec<Move> {
 | 
	
		
			
				|  |  | +    fn reconstruct_pv(game: &Game, hash: &Cache) -> Vec<Move> {
 | 
	
		
			
				|  |  |          let mut pv: Vec<Move> = Vec::new();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        let mut g = self.game.clone();
 | 
	
		
			
				|  |  | +        let mut g = game.clone();
 | 
	
		
			
				|  |  |          loop {
 | 
	
		
			
				|  |  | -            let mce = self.hash.lookup(&g);
 | 
	
		
			
				|  |  | +            let mce = hash.lookup(&g);
 | 
	
		
			
				|  |  |              if let Some(ce) = mce {
 | 
	
		
			
				|  |  |                  pv.push(ce.mov);
 | 
	
		
			
				|  |  |                  g.apply(ce.mov);
 | 
	
	
		
			
				|  | @@ -245,27 +243,39 @@ impl Engine {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          let mut alpha = crate::evaluate::MIN_VALUE;
 | 
	
		
			
				|  |  |          let mut beta = crate::evaluate::MAX_VALUE;
 | 
	
		
			
				|  |  | -        //let window_size = 100;
 | 
	
		
			
				|  |  | +        let window_size = 10;
 | 
	
		
			
				|  |  | +        let mut is_windowed = false;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          loop {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              sc.set_depth(depth);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              let search_result = search(&mut self.game, &mut sc, &mut self.hash, alpha, beta, depth as i32);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            if let SearchResult::Invalid = search_result {
 | 
	
		
			
				|  |  | +                if is_windowed {
 | 
	
		
			
				|  |  | +                    alpha = crate::evaluate::MIN_VALUE;
 | 
	
		
			
				|  |  | +                    beta = crate::evaluate::MAX_VALUE;
 | 
	
		
			
				|  |  | +                    is_windowed = false;
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if let SearchResult::Finished(bm, bv) = search_result {
 | 
	
		
			
				|  |  |                  info!("depth: {} bm: {}, bv: {}", depth, bm.to_string(), bv);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if bv >= beta || bv <= alpha {
 | 
	
		
			
				|  |  |                      alpha = crate::evaluate::MIN_VALUE;
 | 
	
		
			
				|  |  |                      beta = crate::evaluate::MAX_VALUE;
 | 
	
		
			
				|  |  | -                    //println!("repeat");
 | 
	
		
			
				|  |  | +                    is_windowed = false;
 | 
	
		
			
				|  |  |                      continue;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  else {
 | 
	
		
			
				|  |  | -                    alpha = crate::evaluate::MIN_VALUE;
 | 
	
		
			
				|  |  | -                    beta = crate::evaluate::MAX_VALUE;
 | 
	
		
			
				|  |  | -                    //alpha = bv - window_size;
 | 
	
		
			
				|  |  | -                    //beta = bv + window_size;
 | 
	
		
			
				|  |  | +                    //alpha = crate::evaluate::MIN_VALUE;
 | 
	
		
			
				|  |  | +                    //beta = crate::evaluate::MAX_VALUE;
 | 
	
		
			
				|  |  | +                    is_windowed = true;
 | 
	
		
			
				|  |  | +                    alpha = bv - window_size;
 | 
	
		
			
				|  |  | +                    beta = bv + window_size;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  best_move = bm;
 | 
	
	
		
			
				|  | @@ -275,25 +285,21 @@ impl Engine {
 | 
	
		
			
				|  |  |                  let nodes = sc.nodes;
 | 
	
		
			
				|  |  |                  let nps = (nodes as f64 / elapsed.as_nanos() as f64 * 1000000000.0) as i64;
 | 
	
		
			
				|  |  |                  let cp = best_val as i64;
 | 
	
		
			
				|  |  | +                let hashfull = self.hash.fullness_permill();
 | 
	
		
			
				|  |  |                  
 | 
	
		
			
				|  |  | -                //let pv_array = self.reconstruct_pv();
 | 
	
		
			
				|  |  | -                let pv = &sc.pv.iter().filter(|&m| !m.is_null()).map(|m| m.to_string()).fold(String::new(), |a, b| a + " " + &b)[0..];
 | 
	
		
			
				|  |  | +                let pv_array = Self::reconstruct_pv(&self.game, &self.hash);
 | 
	
		
			
				|  |  | +                let pv = &pv_array.iter().filter(|&m| !m.is_null()).map(|m| m.to_string()).fold(String::new(), |a, b| a + " " + &b)[0..];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if let Some(plies) = crate::evaluate::is_mate_in_p1(bv) {
 | 
	
		
			
				|  |  |                      let turns = plies / 2;
 | 
	
		
			
				|  |  | -                    println!("info depth {} score mate {} time {} nodes {} nps {} pv{}", depth, turns, elapsed.as_millis(), nodes, nps, pv);
 | 
	
		
			
				|  |  | -                    info!("info depth {} score mate {} time {} nodes {} nps {} pv{}", depth, turns, elapsed.as_millis(), nodes, nps, pv);
 | 
	
		
			
				|  |  | -                    
 | 
	
		
			
				|  |  | -                    /*if depth > 3 {
 | 
	
		
			
				|  |  | -                        break;
 | 
	
		
			
				|  |  | -                    }*/
 | 
	
		
			
				|  |  | -                    /*if plies.abs() * 3 < depth {
 | 
	
		
			
				|  |  | -                        break;
 | 
	
		
			
				|  |  | -                    }*/
 | 
	
		
			
				|  |  | +                    let infostring = format!("info depth {} score mate {} time {} nodes {} nps {} hashfull {} pv{}", depth, turns, elapsed.as_millis(), nodes, nps, hashfull, pv);
 | 
	
		
			
				|  |  | +                    println!("{}", infostring);
 | 
	
		
			
				|  |  | +                    info!("{}", infostring);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  else {
 | 
	
		
			
				|  |  | -                    println!("info depth {} score cp {} time {} nodes {} nps {} pv{}", depth, cp, elapsed.as_millis(), nodes, nps, pv);
 | 
	
		
			
				|  |  | -                    info!("info depth {} score cp {} time {} nodes {} nps {} pv{}", depth, cp, elapsed.as_millis(), nodes, nps, pv);
 | 
	
		
			
				|  |  | +                    let infostring = format!("info depth {} score cp {} time {} nodes {} nps {} hashfull {} pv{}", depth, cp, elapsed.as_millis(), nodes, nps, hashfull, pv);
 | 
	
		
			
				|  |  | +                    println!("{}", infostring);
 | 
	
		
			
				|  |  | +                    info!("{}", infostring);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  depth += 1;
 | 
	
		
			
				|  |  |              }
 |