diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-09-03 19:29:54 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-09-03 19:29:54 +0300 |
commit | e2934b95cbad65bc89cbc285c3ece2124bf44a55 (patch) | |
tree | 99252dd59ee15cace85730f68db0cd85ea628330 /src/board/piece.rs | |
parent | 9927af55dd12bc5eca7ff17e9dbc2665c42fcfb7 (diff) | |
download | chessnost-e2934b95cbad65bc89cbc285c3ece2124bf44a55.tar.gz |
feat: improved scoring for (semi)dead positions
Diffstat (limited to 'src/board/piece.rs')
-rw-r--r-- | src/board/piece.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/board/piece.rs b/src/board/piece.rs index 1889e94..3de27ca 100644 --- a/src/board/piece.rs +++ b/src/board/piece.rs @@ -1,3 +1,5 @@ +use super::color::Color; + #[derive(Debug, Clone, Copy, PartialEq, Eq, num_enum::FromPrimitive)] #[repr(usize)] pub enum Piece { @@ -21,6 +23,15 @@ impl Piece { let index = *self as usize; Self::from(index % 6) } + + /// Note: assumes self is without color! + pub fn colored(&self, color: Color) -> Self { + match color { + Color::White => *self, + Color::Black => Self::from(*self as usize + 6) + } + } + // Return the price of the peice pub fn static_eval(&self) -> f32 { match self.without_color() { |