pub struct Square { /* fields omitted */ }
Represents a position of each cell in the game board.
use shogi::Square;
let sq = Square::new(4, 4).unwrap();
assert_eq!("5e", sq.to_string());
Square
can be created by parsing a SFEN formatted string as well.
use shogi::Square;
let sq = Square::from_sfen("5e").unwrap();
assert_eq!(4, sq.file());
assert_eq!(4, sq.rank());
Creates a new instance of Square
.
file
can take a value from 0('1') to 8('9'), while rank
is from 0('a') to 9('i').
Creates a new instance of Square
from SFEN formatted string.
Creates a new instance of Square
with the given index value.
Returns an iterator of all variants.
Returns a file of the square.
Returns a rank of the square.
Returns a new Square
instance by moving the file and the rank values.
use shogi::square::consts::*;
let sq = SQ_2B;
let shifted = sq.shift(2, 3).unwrap();
assert_eq!(3, shifted.file());
assert_eq!(4, shifted.rank());
Returns a relative rank as if the specified color is black.
use shogi::Color;
use shogi::square::consts::*;
let sq = SQ_1G;
assert_eq!(6, sq.relative_rank(Color::Black));
assert_eq!(2, sq.relative_rank(Color::White));
Tests if the square is in a promotion zone.
Converts the instance into the unique number for array indexing purpose.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
type Output = Bitboard
The resulting type after applying the &
operator.
Performs the &
operation.
type Output = Bitboard
The resulting type after applying the |
operator.
Performs the |
operation.
type Output = Bitboard
The resulting type after applying the ^
operator.
Performs the ^
operation.
Performs the &=
operation.
Performs the |=
operation.
Performs the ^=
operation.
type Owned = T
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
type Error = !
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more