aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-23 06:27:23 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-23 06:27:23 +0300
commit8eb51ff6072413f03f6edc8a4ead95bb3380245d (patch)
treee030687de2c55d8ae13e21c204cd8e50a25cad0b
parentefd5505b7f211e09e56dc6482c850b5ff0fe8737 (diff)
downloadchessnost-8eb51ff6072413f03f6edc8a4ead95bb3380245d.tar.gz
fix: derive necessary traits
-rw-r--r--src/board.rs10
-rw-r--r--src/moves.rs2
2 files changed, 8 insertions, 4 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);
}
}
diff --git a/src/moves.rs b/src/moves.rs
index a43ed4b..3f55b2f 100644
--- a/src/moves.rs
+++ b/src/moves.rs
@@ -1,6 +1,6 @@
use crate::{square::Square, bitboard::print};
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub struct Move {
pub source: Square,
pub target: Square,