Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
12cebf1f2b WIP 2025-06-17 16:24:28 -07:00

View file

@ -326,6 +326,45 @@ impl Board {
}
}
impl Board {
#[must_use]
pub fn is_valid(&self) -> bool {
true
}
/// Determines whether `self` is a repetition of the given [`Board`]
/// according to the standard chess rules. A position is considered
/// equal or a repetition of another position if:
///
/// 1. The placement of all pieces of all colors is the same, i.e. same
/// pieces on same squares
/// 2. Castling rights are equal
/// 3. The target position does not have an en passant capture available
///
/// ## See Also
///
/// * The [Chess Programming][1] wiki page on repetitions
///
/// [1]: https://www.chessprogramming.org/Repetitions
///
#[must_use]
pub fn is_repetition(&self, other: &Board) -> bool {
if other.en_passant_target.is_some() {
return false;
}
if self.castling_rights != other.castling_rights {
return false;
}
if self.pieces != other.pieces {
return false;
}
true
}
}
impl Board {
pub fn display(&self) -> DiagramFormatter<'_> {
DiagramFormatter::new(self)