aboutsummaryrefslogtreecommitdiff
path: root/src/moves.rs
blob: e27d74cfd4d61054e8d6845f20712336ec7d4c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::{square::Square, bitboard::BitboardFns, board::piece::Piece};

#[derive(Debug, Clone, PartialEq, Eq, Copy)]
pub enum MoveKind {
    Quiet,
    Capture,
    Castle,
    EnPassant,
    DoublePush,
    Promotion(Piece),
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Move {
    pub source: Square,
    pub target: Square,
    pub kind: MoveKind,
}

impl Move {
    pub fn print(&self) {
        let bb = self.source.to_bitboard() | self.target.to_bitboard();
        bb.print(format!("{:?}", self).as_str());
    }

    /// Tactical move is a move that changes material score
    pub fn is_tactical(&self) -> bool {
        matches!(self.kind, MoveKind::Capture | MoveKind::EnPassant)
    }
}