Enum stockfish_core::core::Square
source · #[repr(u8)]
pub enum Square {
Show 64 variants
A1,
B1,
C1,
D1,
E1,
F1,
G1,
H1,
A2,
B2,
C2,
D2,
E2,
F2,
G2,
H2,
A3,
B3,
C3,
D3,
E3,
F3,
G3,
H3,
A4,
B4,
C4,
D4,
E4,
F4,
G4,
H4,
A5,
B5,
C5,
D5,
E5,
F5,
G5,
H5,
A6,
B6,
C6,
D6,
E6,
F6,
G6,
H6,
A7,
B7,
C7,
D7,
E7,
F7,
G7,
H7,
A8,
B8,
C8,
D8,
E8,
F8,
G8,
H8,
}Expand description
A square on a chess board.
Variants§
A1
B1
C1
D1
E1
F1
G1
H1
A2
B2
C2
D2
E2
F2
G2
H2
A3
B3
C3
D3
E3
F3
G3
H3
A4
B4
C4
D4
E4
F4
G4
H4
A5
B5
C5
D5
E5
F5
G5
H5
A6
B6
C6
D6
E6
F6
G6
H6
A7
B7
C7
D7
E7
F7
G7
H7
A8
B8
C8
D8
E8
F8
G8
H8
Implementations§
source§impl Square
impl Square
source§impl Square
impl Square
sourcepub const fn new(file: File, rank: Rank) -> Self
pub const fn new(file: File, rank: Rank) -> Self
Creates a new square of the provided file and rank.
sourcepub const fn flip_file(self) -> Self
pub const fn flip_file(self) -> Self
Returns this square from the perspective of flipping the board left-to-right.
sourcepub const fn flip_rank(self) -> Self
pub const fn flip_rank(self) -> Self
Returns this square from the perspective of flipping the board top-to-bottom.
sourcepub const fn from_perspective(self, color: Color) -> Self
pub const fn from_perspective(self, color: Color) -> Self
If color is Color::White, returns the original square. If color
is Color::Black, returns the square on the same file but whose rank
is from the black player’s perspective.
Examples
assert_eq!(Square::B3, Square::B3.from_perspective(Color::White));
assert_eq!(Square::B6, Square::B3.from_perspective(Color::Black));
assert_eq!(Square::C1, Square::C8.from_perspective(Color::Black));sourcepub const fn distance_files(self, other: Self) -> u8
pub const fn distance_files(self, other: Self) -> u8
The number of steps a king would have to move in order to be on the file
of the other square.
sourcepub const fn distance_ranks(self, other: Self) -> u8
pub const fn distance_ranks(self, other: Self) -> u8
The number of steps a king would have to move in order to be on the rank
of the other square.
sourcepub const fn distance(self, other: Self) -> u8
pub const fn distance(self, other: Self) -> u8
The number of steps a king would have to move in order to wind up on the
other square.
sourcepub fn wrapping_add(self, dir: Direction) -> Self
pub fn wrapping_add(self, dir: Direction) -> Self
Performs wrapping addition of a Direction to a Square. Note that
this wraps around files and ranks.
Examples:
assert_eq!(Square::C4, Square::A3.wrapping_add(Direction::ENE));
assert_eq!(Square::A5, Square::H5.wrapping_add(Direction::E));
assert_eq!(Square::D2, Square::D8.wrapping_add(Direction::NN));
assert_eq!(Square::H8, Square::A2.wrapping_add(Direction::SSW));sourcepub fn wrapping_sub(self, dir: Direction) -> Self
pub fn wrapping_sub(self, dir: Direction) -> Self
Trait Implementations§
source§impl BitAndAssign<Square> for Bitboard
impl BitAndAssign<Square> for Bitboard
source§const fn bitand_assign(&mut self, rhs: Square)
const fn bitand_assign(&mut self, rhs: Square)
&= operation. Read moresource§impl BitOrAssign<Square> for Bitboard
impl BitOrAssign<Square> for Bitboard
source§const fn bitor_assign(&mut self, rhs: Square)
const fn bitor_assign(&mut self, rhs: Square)
|= operation. Read moresource§impl BitXorAssign<Square> for Bitboard
impl BitXorAssign<Square> for Bitboard
source§const fn bitxor_assign(&mut self, rhs: Square)
const fn bitxor_assign(&mut self, rhs: Square)
^= operation. Read more