aboutsummaryrefslogtreecommitdiff
path: root/src/board.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-21 18:44:03 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-21 18:46:42 +0300
commit7d93bee082fb561d80a8fe3e1c60a9fcb0a399ba (patch)
tree2088c6980550da7264687d72a94de53bbaf00375 /src/board.rs
parent74973416aa6a7b0fae9ed2b9911fa18fe87c4e1c (diff)
downloadchessnost-7d93bee082fb561d80a8fe3e1c60a9fcb0a399ba.tar.gz
refactor: return generated arrays
Diffstat (limited to 'src/board.rs')
-rw-r--r--src/board.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/board.rs b/src/board.rs
index 13f86ec..86c42c7 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -32,6 +32,7 @@ const PIECE_CHARS: [&str; 12] = [
];
+#[allow(unused)]
impl Board {
#[allow(non_snake_case)]
pub fn from_FEN(fen: String) -> Self {
@@ -128,7 +129,7 @@ pub enum Square {
#[cfg(test)]
mod tests {
use super::*;
- use crate::bitboard;
+ use crate::bitboard::{pop_count, bitscan};
#[test]
fn test_square_enum() {
@@ -142,22 +143,22 @@ mod tests {
let fen = String::from("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
let board = Board::from_FEN(fen);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Pawn as usize]), 8);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Knight as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Bishop as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Rook as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Queen as usize]), 1);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::King as usize]), 1);
-
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::PawnBlack as usize]), 8);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::KnightBlack as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::BishopBlack as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::RookBlack as usize]), 2);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::QueenBlack as usize]), 1);
- assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::KingBlack as usize]), 1);
-
- assert_eq!(bitboard::bitscan(board.pieces[PieceTypes::King as usize]), Square::E1 as u8);
- assert_eq!(bitboard::bitscan(board.pieces[PieceTypes::QueenBlack as usize]), Square::D8 as u8);
+ assert_eq!(pop_count(board.pieces[PieceTypes::Pawn as usize]), 8);
+ assert_eq!(pop_count(board.pieces[PieceTypes::Knight as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::Bishop as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::Rook as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::Queen as usize]), 1);
+ assert_eq!(pop_count(board.pieces[PieceTypes::King as usize]), 1);
+
+ assert_eq!(pop_count(board.pieces[PieceTypes::PawnBlack as usize]), 8);
+ assert_eq!(pop_count(board.pieces[PieceTypes::KnightBlack as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::BishopBlack as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::RookBlack as usize]), 2);
+ assert_eq!(pop_count(board.pieces[PieceTypes::QueenBlack as usize]), 1);
+ assert_eq!(pop_count(board.pieces[PieceTypes::KingBlack as usize]), 1);
+
+ assert_eq!(bitscan(board.pieces[PieceTypes::King as usize]), Square::E1 as u8);
+ assert_eq!(bitscan(board.pieces[PieceTypes::QueenBlack as usize]), Square::D8 as u8);
board.print();
}