|  | @@ -31,18 +31,8 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth:
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      let mut moves = generate_legal_moves(game, game.turn);
 | 
	
		
			
				|  |  | -    //info!("mov list: {:?}", moves.iter().map(|x| x.to_string()).collect::<Vec<String>>());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      let mut rng = rand::thread_rng();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    /*moves.shuffle(&mut rng);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    // return random move
 | 
	
		
			
				|  |  | -    if moves.len() >= 1 {
 | 
	
		
			
				|  |  | -        return moves[0];
 | 
	
		
			
				|  |  | -    }*/
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    sort_moves(game, &mut moves);
 | 
	
		
			
				|  |  | +    sort_moves(game, hash, &mut moves);
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      info!("moves: {:?}", moves.iter().map(|mv| mv.to_string()).collect::<Vec<String>>());
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -143,7 +133,6 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      let mut is_corr: PosValue = -1;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      let hash_entry = hash.lookup(game);
 | 
	
		
			
				|  |  |      if let Some(e) = hash_entry {
 | 
	
		
			
				|  |  |          if e.depth >= depth {
 | 
	
	
		
			
				|  | @@ -163,13 +152,11 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    let mut best = MIN_VALUE;
 | 
	
		
			
				|  |  | -    //let mut best_move = Move::default();
 | 
	
		
			
				|  |  | -    //info!(" -> generate_legal_moves");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      if game.get_piece(KING, game.turn) == 0 { return (MIN_VALUE, false); }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    let moves = generate_legal_moves(game, game.turn);
 | 
	
		
			
				|  |  | +    let mut moves = generate_legal_moves(game, game.turn);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    sort_moves(game, hash, &mut moves);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if moves.len() == 0 {
 | 
	
		
			
				|  |  |          if is_check(game, game.turn) {
 | 
	
	
		
			
				|  | @@ -211,11 +198,6 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
	
		
			
				|  |  |              alpha = val;//(val as f64 * 0.95) as _;
 | 
	
		
			
				|  |  |              alpha_is_exact = true;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        //info!(" -> negamaxed {} -> {}", mov.to_string(), depth - 1);
 | 
	
		
			
				|  |  | -        if val > best {
 | 
	
		
			
				|  |  | -            best = val;
 | 
	
		
			
				|  |  | -            //best_move = mov;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          game.undo_move(undo);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -245,7 +227,7 @@ fn quiescence_search(game: &mut Game, sc: &mut SearchControl, mut alpha: PosValu
 | 
	
		
			
				|  |  |          return alpha;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if game.get_piece(KING, game.turn) == 0 { return MIN_VALUE; }
 | 
	
		
			
				|  |  | +    if game.get_piece(KING, game.turn) == 0 { return -mate(); }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      let moves = generate_attacking_moves(game, game.turn);
 | 
	
		
			
				|  |  |  
 |