Board: change types for score

This commit is contained in:
Simon Gardling 2025-03-17 13:58:44 -04:00
parent 77bf0e6438
commit 4db6f51c9c
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 3 additions and 9 deletions

View File

@ -38,8 +38,8 @@ impl BitBoard {
self.0 |= (value as BitBoardInner) << index; // set bit (if needed)
}
pub const fn count(&self) -> usize {
self.0.count_ones() as usize
pub const fn count(&self) -> u8 {
self.0.count_ones() as u8
}
pub const fn is_empty(&self) -> bool {

View File

@ -320,16 +320,10 @@ impl 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 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)
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.`