Struct hexe_core::board::MultiBoard [] [src]

#[repr(C)]
pub struct MultiBoard { /* fields omitted */ }

A full chess board, represented as multiple bitboard segments.

Methods

impl MultiBoard
[src]

STANDARD: MultiBoard = values::STANDARD

The board for standard chess.

[src]

Clears the board of all pieces.

[src]

Returns whether self is empty.

For much better performance and readability, is recommended to use this method over checking whether board.len() == 0.

Examples

Basic usage:

use hexe_core::board::MultiBoard;

assert!(!MultiBoard::STANDARD.is_empty());
assert!(MultiBoard::default().is_empty());

[src]

Returns the total number of pieces in self.

Examples

Basic usage:

use hexe_core::board::MultiBoard;

let board = MultiBoard::STANDARD;
assert_eq!(board.len(), 32);

Important traits for Bitboard
[src]

Returns all bits of the pieces contained in self.

Examples

Basic usage:

use hexe_core::board::MultiBoard;

let board = MultiBoard::STANDARD;
let value = 0xFFFF00000000FFFFu64;

assert_eq!(board.all_bits(), value.into());

Important traits for Bitboard
[src]

Returns the Bitboard for value in self.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let board   = MultiBoard::STANDARD;
let king_sq = board.bitboard(Piece::WhiteKing).lsb();

assert_eq!(king_sq, Some(Square::E1));

Important traits for Bitboard
[src]

Returns the bits of the royal pieces, King and Queen.

[src]

Returns the first square that value appears at, if any.

[src]

Returns the first square that value may appear at, without checking whether it exists in self.

[src]

Returns the last square that value appears at, if any.

[src]

Returns the last square that value may appear at, without checking whether it exists in self.

[src]

Returns the total number of value in self.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let board = MultiBoard::STANDARD;

assert_eq!(board.count(Color::Black), 16);
assert_eq!(board.count(Piece::WhiteRook), 2);
assert_eq!(board.count(Role::Queen), 2);

[src]

Returns whether value is contained at all squares in bits.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let board = MultiBoard::STANDARD;

assert!(board.contains(Square::A2, Color::White));
assert!(board.contains(Square::C8, Role::Bishop));
assert!(board.contains(Rank::Seven, Piece::BlackPawn));

[src]

Returns whether value is contained at any square in bits.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let board = MultiBoard::STANDARD;

assert!(board.contains_any(File::B, Role::Knight));
assert!(board.contains_any(Rank::One, Role::King));

[src]

Inserts piece at each square in bits, removing any other pieces that may be at bits.

[src]

Performs a blind insertion of piece at a each square in bits.

It does not check whether other pieces are located at bits. If the board may contain pieces at bits, then insert should be called instead.

[src]

Removes each piece at bits for value.

[src]

Performs a blind removal of value at bits.

It does not check whether other pieces that value does not represent are located at bits.

[src]

Removes all pieces at bits.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let mut board = MultiBoard::STANDARD;
let squares = [
    Square::A1,
    Square::C1,
    Square::F2,
];

for &square in squares.iter() {
    assert!(board[Color::White].contains(square));
    board.remove_all(square);
    assert!(!board[Color::White].contains(square));
}

[src]

Returns references to the underlying bitboards for Color and Role, respectively.

[src]

Returns mutable references to the underlying bitboards for Color and Role, respectively.

[src]

Returns whether the square for player is being attacked.

This method does not check whether a piece for player actually exists at sq. To check for that, call board.contains(sq, player).

[src]

Performs a blind castle of the pieces for the castling right.

Invariants

Under legal castling circumstances, this method makes it so that squares involved with castling using right are in a correct state post-castle.

There are some cases where the board state may be invalidated if the above invariant isn't correctly met:

  • If the king is not in its initial position, then a king will spawn both where it was expected to be, as well as where it would move to. The same will happen when the rook is not at its corner of the board.

  • If another rook is located where the castling rook is being moved to then both rooks will be removed.

  • If any other pieces are located at the involved squares, then other strange things will happen.

The above are all the result of properly defined behavior. They are just side effects of how the board is represented and this use of XOR.

Examples

Basic usage:

use hexe_core::board::MultiBoard;
use hexe_core::prelude::*;

let mut board: MultiBoard = {
    /* create board */
};

board.castle(Right::WhiteQueen);
assert!(board.contains(Square::C1, Piece::WhiteKing));
assert!(board.contains(Square::D1, Piece::WhiteRook));

Undo-Redo

Because this method internally uses XOR, it is its own inverse. If the involved king and rook sit at their destination squares, they will be moved back to their initial squares.

use hexe_core::board::MultiBoard;
use hexe_core::castle::Right;

let mut board: MultiBoard = {
    /* create board */
};

let right = Right::WhiteQueen;
let clone = board.clone();

board.castle(right);
board.castle(right);

assert!(board == clone);

Trait Implementations

impl Clone for MultiBoard
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for MultiBoard
[src]

impl PartialEq for MultiBoard
[src]

[src]

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

1.0.0
[src]

This method tests for !=.

impl Default for MultiBoard
[src]

[src]

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

impl AsRef<[u64]> for MultiBoard
[src]

[src]

Performs the conversion.

impl AsMut<[u64]> for MultiBoard
[src]

[src]

Performs the conversion.

impl AsRef<[Bitboard]> for MultiBoard
[src]

[src]

Performs the conversion.

impl AsMut<[Bitboard]> for MultiBoard
[src]

[src]

Performs the conversion.

impl<'a> From<&'a PieceMap> for MultiBoard
[src]

[src]

Performs the conversion.

impl Hash for MultiBoard
[src]

[src]

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

1.3.0
[src]

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

impl Index<Role> for MultiBoard
[src]

The returned type after indexing.

Important traits for Bitboard
[src]

Performs the indexing (container[index]) operation.

impl IndexMut<Role> for MultiBoard
[src]

Important traits for Bitboard
[src]

Performs the mutable indexing (container[index]) operation.

impl Index<Color> for MultiBoard
[src]

The returned type after indexing.

Important traits for Bitboard
[src]

Performs the indexing (container[index]) operation.

impl IndexMut<Color> for MultiBoard
[src]

Important traits for Bitboard
[src]

Performs the mutable indexing (container[index]) operation.

Auto Trait Implementations

impl Send for MultiBoard

impl Sync for MultiBoard