From 4db6f51c9c1134bacd9a4b7f56507dd4e9956fef Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 17 Mar 2025 13:58:44 -0400 Subject: [PATCH] Board: change types for score --- src/repr/bitboard.rs | 4 ++-- src/repr/board.rs | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/repr/bitboard.rs b/src/repr/bitboard.rs index 9196888..ae760bd 100644 --- a/src/repr/bitboard.rs +++ b/src/repr/bitboard.rs @@ -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 { diff --git a/src/repr/board.rs b/src/repr/board.rs index 96131c6..c199ba6 100644 --- a/src/repr/board.rs +++ b/src/repr/board.rs @@ -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.`