Struct pleco::core::sq::SQ[][src]

pub struct SQ(pub u8);

Represents a singular square of a chessboard.

Methods

impl SQ
[src]

NONE: SQ = NO_SQ

A square that isn't on the board. Basically equivilant to Option<SQ> where the value is None.

Returns the UCI String representation of a SQ.

Returns if a SQ is within the legal bounds of a square, which is inclusively between 0 - 63.

Examples

use pleco::SQ;
let sq_ok = SQ(5);
let no_sq = SQ(64);

assert!(sq_ok.is_okay());
assert!(!no_sq.is_okay());

Returns distance between this square and another square. Distance is not in algebraic difference, but in squares away.

Examples

use pleco::SQ;

let a1 = SQ::A1;
let b2 = SQ::B2;
let b3 = SQ::B3;

assert_eq!(a1.distance(a1), 0);
assert_eq!(a1.distance(b2), 1);
assert_eq!(a1.distance(b3), 2);

Important traits for BitBoard

Converts a SQ to it's BitBoard equivalent. The resulting BitBoard will have exactly 1 bit set at the index where the square is location on the chessboard.

Returns the Rank that a SQ lies on.

Examples

use pleco::{SQ,Rank};

let sq_f2 = SQ::F2;
assert_eq!(sq_f2.rank(), Rank::R2);

Important traits for BitBoard

Returns the BitBoard representation of a Rank that a SQ lies on.

Returns the rank index (number) of a SQ.

Returns the File that a SQ lies on.

Examples

use pleco::{SQ,File};

let sq_f2 = SQ::F2;
assert_eq!(sq_f2.file(), File::F);

Important traits for BitBoard

Returns the BitBoard representation of a File that a SQ lies on.

Returns the file index (number) of a SQ.

Returns the castle rights mask for the given square. If the square does not have a castle rights mask, returns 0.

Creates a SQ from the designated File and Rank.

Examples

use pleco::{SQ,Rank,File};

let file_f = File::F;
let rank_2 = Rank::R2;
let sq_f2 = SQ::F2;

assert_eq!(sq_f2, SQ::make(file_f, rank_2));

Returns if the SQ is a dark square.

Returns if the SQ is a dark square.

Returns the player index of the color of the square.

Flips the square's rank, so SQ::A1 -> SQ::A8.

Determines if two squares are on opposite colors.

Trait Implementations

impl Copy for SQ
[src]

impl Clone for SQ
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for SQ
[src]

Returns the "default value" for a type. Read more

impl Hash for SQ
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for SQ
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd for SQ
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for SQ
[src]

impl Debug for SQ
[src]

Formats the value using the given formatter. Read more

impl From<u8> for SQ
[src]

Performs the conversion.

impl From<SQ> for u8
[src]

Performs the conversion.

impl Rem for SQ
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl RemAssign for SQ
[src]

Performs the %= operation.

impl Rem<u8> for SQ
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl RemAssign<u8> for SQ
[src]

Performs the %= operation.

impl BitOr for SQ
[src]

The resulting type after applying the | operator.

Performs the | operation.

impl BitOrAssign for SQ
[src]

Performs the |= operation.

impl BitOr<u8> for SQ
[src]

The resulting type after applying the | operator.

Performs the | operation.

impl BitOrAssign<u8> for SQ
[src]

Performs the |= operation.

impl BitAnd for SQ
[src]

The resulting type after applying the & operator.

Performs the & operation.

impl BitAndAssign for SQ
[src]

Performs the &= operation.

impl BitAnd<u8> for SQ
[src]

The resulting type after applying the & operator.

Performs the & operation.

impl BitAndAssign<u8> for SQ
[src]

Performs the &= operation.

impl BitXor for SQ
[src]

The resulting type after applying the ^ operator.

Performs the ^ operation.

impl BitXorAssign for SQ
[src]

Performs the ^= operation.

impl BitXor<u8> for SQ
[src]

The resulting type after applying the ^ operator.

Performs the ^ operation.

impl BitXorAssign<u8> for SQ
[src]

Performs the ^= operation.

impl Add for SQ
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl AddAssign for SQ
[src]

Performs the += operation.

impl Add<u8> for SQ
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl AddAssign<u8> for SQ
[src]

Performs the += operation.

impl Div for SQ
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl DivAssign for SQ
[src]

Performs the /= operation.

impl Div<u8> for SQ
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl DivAssign<u8> for SQ
[src]

Performs the /= operation.

impl Mul for SQ
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl MulAssign for SQ
[src]

Performs the *= operation.

impl Mul<u8> for SQ
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl MulAssign<u8> for SQ
[src]

Performs the *= operation.

impl Sub for SQ
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl SubAssign for SQ
[src]

Performs the -= operation.

impl Sub<u8> for SQ
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl SubAssign<u8> for SQ
[src]

Performs the -= operation.

impl Shl<usize> for SQ
[src]

The resulting type after applying the << operator.

Performs the << operation.

impl ShlAssign<usize> for SQ
[src]

Performs the <<= operation.

impl Shr<usize> for SQ
[src]

The resulting type after applying the >> operator.

Performs the >> operation.

impl ShrAssign<usize> for SQ
[src]

Performs the >>= operation.

impl Not for SQ
[src]

The resulting type after applying the ! operator.

Performs the unary ! operation.

impl Display for SQ
[src]

Formats the value using the given formatter. Read more

impl Shl<SQ> for BitBoard
[src]

The resulting type after applying the << operator.

Important traits for BitBoard

Performs the << operation.

Auto Trait Implementations

impl Send for SQ

impl Sync for SQ