[core] Export Score::CENTIPAWNS_PER_POINT to the crate
This constant is a conversion factor of points to the internal fixed point unit of centipawns. Points are more familiar to people because pawns are worth 1 pt. Calculate the scores of the various piece shapes with this constant.
This commit is contained in:
		
							parent
							
								
									7d3fd4b20a
								
							
						
					
					
						commit
						f658903b54
					
				
					 2 changed files with 10 additions and 7 deletions
				
			
		|  | @ -31,7 +31,7 @@ impl Score { | |||
|     /// The maximum possible value of a score.
 | ||||
|     pub const MAX: Score = Score(Value::MAX); | ||||
| 
 | ||||
|     const CENTIPAWNS_PER_POINT: f32 = 100.0; | ||||
|     pub(crate) const CENTIPAWNS_PER_POINT: f32 = 100.0; | ||||
| 
 | ||||
|     #[must_use] | ||||
|     pub const fn new(value: Value) -> Self { | ||||
|  |  | |||
|  | @ -74,13 +74,16 @@ impl Shape { | |||
|     } | ||||
| 
 | ||||
|     #[must_use] | ||||
|     pub fn score(self) -> Score { | ||||
|     pub const fn score(self) -> Score { | ||||
|         #[allow(clippy::cast_possible_truncation)] | ||||
|         const CP_PER_PT: i32 = Score::CENTIPAWNS_PER_POINT as i32; | ||||
| 
 | ||||
|         match self { | ||||
|             Shape::Pawn => Score::new(100), | ||||
|             Shape::Knight | Shape::Bishop => Score::new(300), | ||||
|             Shape::Rook => Score::new(500), | ||||
|             Shape::Queen => Score::new(900), | ||||
|             Shape::King => Score::new(20000), | ||||
|             Shape::Pawn => Score::new(CP_PER_PT), | ||||
|             Shape::Knight | Shape::Bishop => Score::new(3 * CP_PER_PT), | ||||
|             Shape::Rook => Score::new(5 * CP_PER_PT), | ||||
|             Shape::Queen => Score::new(9 * CP_PER_PT), | ||||
|             Shape::King => Score::new(200 * CP_PER_PT), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue