Board: change types for score
This commit is contained in:
parent
77bf0e6438
commit
4db6f51c9c
@ -38,8 +38,8 @@ impl BitBoard {
|
|||||||
self.0 |= (value as BitBoardInner) << index; // set bit (if needed)
|
self.0 |= (value as BitBoardInner) << index; // set bit (if needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn count(&self) -> usize {
|
pub const fn count(&self) -> u8 {
|
||||||
self.0.count_ones() as usize
|
self.0.count_ones() as u8
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn is_empty(&self) -> bool {
|
pub const fn is_empty(&self) -> bool {
|
||||||
|
|||||||
@ -320,16 +320,10 @@ impl Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Count the number of a type of [`Piece`] on the board
|
/// Count the number of a type of [`Piece`] on the board
|
||||||
pub const fn count(&self, piece: Piece) -> usize {
|
pub const fn count(&self, piece: Piece) -> u8 {
|
||||||
get_board!(self, piece).count()
|
get_board!(self, piece).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the "net score" of a player
|
|
||||||
/// Formula: `net_score = Score_player - Score_opponent`
|
|
||||||
pub const fn net_score(&self, piece: Piece) -> i16 {
|
|
||||||
self.count(piece) as i16 - self.count(piece.flip()) as i16
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the winner of the board (if any)
|
/// Returns the winner of the board (if any)
|
||||||
pub fn game_winner(&self) -> Winner {
|
pub fn game_winner(&self) -> Winner {
|
||||||
// Wikipedia: `Players take alternate turns. If one player cannot make a valid move, play passes back to the other player. The game ends when the grid has filled up or if neither player can make a valid move.`
|
// Wikipedia: `Players take alternate turns. If one player cannot make a valid move, play passes back to the other player. The game ends when the grid has filled up or if neither player can make a valid move.`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user