aboutsummaryrefslogtreecommitdiff
path: root/src/board/engine.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-21 05:22:54 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-21 05:28:45 +0300
commit46e9fcdcce5730827355db9449c41dc0a0e42b1f (patch)
tree7b9903446bd7884df6a22ddd2c6a2b8a6dcc3d44 /src/board/engine.rs
parent02ebad55af6c76ac9e36832f9be041f547f63b7c (diff)
downloadchessnost-46e9fcdcce5730827355db9449c41dc0a0e42b1f.tar.gz
refactor: use bitboard trait
Diffstat (limited to 'src/board/engine.rs')
-rw-r--r--src/board/engine.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs
index ad2b3b2..5168350 100644
--- a/src/board/engine.rs
+++ b/src/board/engine.rs
@@ -1,5 +1,5 @@
use std::{time::{Instant, Duration}, f32::INFINITY, cmp::Ordering};
-use crate::{bitboard::pop_count, board::*};
+use crate::board::*;
use super::ttable::{NodeType, TranspositionTableItem};
@@ -171,7 +171,7 @@ impl Board {
_ => panic!("Unreachable")
};
- material += serialize_bitboard(*bitboard).iter().fold(0., |acc, square| {
+ material += bitboard.serialize().iter().fold(0., |acc, square| {
acc + piece_type.static_eval() + bonus_table[
match color {
Color::White => square.mirror() as usize,
@@ -195,7 +195,7 @@ impl Board {
for file in 0..8 {
let file_mask = A_FILE << file;
- let pawns_on_file = pop_count(pawns & file_mask) as f32;
+ let pawns_on_file = (pawns & file_mask).pop_count() as f32;
// Doubled pawns (-1 because one pawn on a file is ok)
result += (pawns_on_file - 1.).max(0.0);
@@ -214,7 +214,7 @@ impl Board {
Color::White => self.occupancy >> 8,
Color::Black => self.occupancy << 8,
};
- result += pop_count(pawns & blocked_mask) as f32;
+ result += (pawns & blocked_mask).pop_count() as f32;
result
}
@@ -224,14 +224,14 @@ impl Board {
pub fn king_tropism(&self, color: Color) -> f32 {
let mut result = 0.0;
- let king_square = bitscan(match color {
+ let king_square = match color {
Color::White => self.pieces[PieceType::King as usize],
Color::Black => self.pieces[PieceType::KingBlack as usize],
- });
+ }.bitscan();
for (piece_type, bitboard) in self.pieces_by_color(color.flip()).iter().enumerate() {
if piece_type != PieceType::King as usize && piece_type != PieceType::Pawn as usize {
- for square in serialize_bitboard(*bitboard) {
+ for square in bitboard.serialize() {
let distance =
(king_square.rank() as f32 - square.rank() as f32).abs() +
(king_square.file() as f32 - square.file() as f32).abs();