shrink WIN_COUNT_TABLE

This commit is contained in:
nora 2023-01-16 09:54:23 +01:00
parent 91e3573e26
commit b9de5d27e0

View file

@ -101,7 +101,7 @@ impl Connect4 {
fn rate(&self, player: Player) -> Score { fn rate(&self, player: Player) -> Score {
#[rustfmt::skip] #[rustfmt::skip]
const WIN_COUNT_TABLE: [i32; BOARD_POSITIONS] = [ const WIN_COUNT_TABLE: [i16; BOARD_POSITIONS] = [
3, 4, 6, 7, 6, 4, 3, 3, 4, 6, 7, 6, 4, 3,
2, 4, 6, 7, 6, 4, 2, 2, 4, 6, 7, 6, 4, 2,
2, 4, 6, 7, 6, 4, 2, 2, 4, 6, 7, 6, 4, 2,
@ -114,10 +114,10 @@ impl Connect4 {
.enumerate() .enumerate()
.filter(|(_, state)| **state == Some(player)) .filter(|(_, state)| **state == Some(player))
.map(|(pos, _)| WIN_COUNT_TABLE[pos]) .map(|(pos, _)| WIN_COUNT_TABLE[pos])
.sum::<i32>() .sum::<i16>()
}; };
Score::new(score_player(player) - score_player(player.opponent())) Score::new(i32::from(score_player(player) - score_player(player.opponent())))
} }
pub fn drop_player(&self, position: usize) -> usize { pub fn drop_player(&self, position: usize) -> usize {