aboutsummaryrefslogtreecommitdiff
path: root/src/board.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/board.rs')
-rw-r--r--src/board.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/board.rs b/src/board.rs
index e0f2a0b..f32f7fc 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -1,5 +1,7 @@
use crate::{bitboard::{Bitboard, serialize_bitboard}, moves::Move, attacks::Attacks};
+pub static DEFAULT_FEN: &str = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
+
#[derive(Debug)]
pub struct Board {
pub pieces: [Bitboard; 12],
@@ -223,11 +225,13 @@ impl Board {
},
None => panic!("Move is malformed: source piece not found"),
};
+
+ self.ply += 1;
}
}
-#[derive(Clone, Copy, PartialEq, num_enum::FromPrimitive)]
+#[derive(Debug, Clone, Copy, PartialEq, num_enum::FromPrimitive)]
#[repr(u8)]
pub enum Color {
#[default]
@@ -240,8 +244,6 @@ mod tests {
use super::*;
use crate::{bitboard::{pop_count, bitscan, print}, square::Square};
- const DEFAULT_FEN: &str = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
-
#[test]
fn test_square_enum() {
assert_eq!(Square::A1 as u8, 0);
@@ -308,6 +310,7 @@ mod tests {
assert!(board.pieces[PieceType::PawnBlack as usize] & Square::F7.to_bitboard() == 0);
assert!(board.pieces[PieceType::PawnBlack as usize] & Square::F5.to_bitboard() > 0);
+ assert!(board.ply == 1);
let white_move = Move { source: Square::D2, target: Square::A5 };
println!("\n{:?}", white_move);
@@ -317,6 +320,7 @@ mod tests {
assert!(board.pieces[PieceType::PawnBlack as usize] & Square::A5.to_bitboard() == 0, "Target piece should be captured");
assert!(board.pieces[PieceType::Queen as usize] & Square::D2.to_bitboard() == 0);
assert!(board.pieces[PieceType::Queen as usize] & Square::A5.to_bitboard() > 0);
+ assert!(board.ply == 2);
}
}