| 
					
				 | 
			
			
				@@ -4,6 +4,9 @@ use movegen::*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use std::i32; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// type that is returned by the evaluate funcion 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub type PosValue = i32; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub const MIN_VALUE: PosValue = i32::MIN + 1; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,10 +19,10 @@ pub fn mate() -> PosValue { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     mate_in_p1(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * constructs a PosValue that indicates that from a given position mate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * can be achieved in turns-1 moves (not halfmoves) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// constructs a PosValue that indicates that from a given position mate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// can be achieved in turns-1 moves (not halfmoves) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub fn mate_in_p1(turns: i32) -> PosValue { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if turns < 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return -mate_in_p1(-turns); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,13 +32,13 @@ pub fn mate_in_p1(turns: i32) -> PosValue { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * returns Some(turns) if the pos_val indicates that mate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * can be reached in turns-1 moves 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * turns is negative if the moving side is getting mated 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * in turns moves 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// returns Some(turns) if the pos_val indicates that mate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// can be reached in turns-1 moves 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// turns is negative if the moving side is getting mated 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// in turns moves 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub fn is_mate_in_p1(pos_val: PosValue) -> Option<i32> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if pos_val > MATE_CUTOFF && pos_val <= MATE_VALUE { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Some(-pos_val + MATE_VALUE) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -146,6 +149,9 @@ fn king_there(game: &Game, side: Side) -> PosValue { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if game.get_piece(KING, side) != 0 { 10000 } else { 0 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/// The evaluate function of the engine 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+///  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub fn evaluate(game: &Game) -> PosValue { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let sv = side_value(game, game.turn) as PosValue - side_value(game, !game.turn) as PosValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let material_value_us = material_value(game, game.turn); 
			 |