Struct bitboard::Bitboard [] [src]

pub struct Bitboard<N: Unsigned> {
    pub ptr: *mut u64,
    // some fields omitted
}

A square bitboard of size NxN, with alignment A

There are no aliases provided, but I suggest you create one for whatever application you have. Something like:

extern crate typenum;
extern crate bitboard;

use typenum::consts::U8;
use bitboard::Bitboard;

type Chessboard = bitboard::Bitboard<U8>;

fn main() {
    let cc : Chessboard = Bitboard::new();
    // ...
}

Will save a lot of typing and will also probably prevent screwups.

Fields

Methods

impl<N: Unsigned> Bitboard<N>
[src]

[src]

Construct a new, blank bitboard of size NxN, with alignment A

Examples

extern crate typenum;
   extern crate bitboard;

   use typenum::consts::U8;
   use bitboard::Bitboard;

   fn main() {
       let bb = Bitboard::<U8>::new();
       // ...
   }

[src]

Set the bit at location (x,y)

Origin is in the top-left, starting at 0, high values of x move to the right, high values of y move downward.

Examples

extern crate typenum;
extern crate bitboard;

use typenum::consts::U3;
use bitboard::Bitboard;

type TicTacToe = bitboard::Bitboard<U3>;
fn main() {
  let mut x_positions : TicTacToe = Bitboard::new();
  // X has taken no positions
  // 000
  // 000
  // 000
  assert!(!x_positions.is_set(1,1).ok().unwrap()); // the center square is free!

  x_positions.set(1,1); // take the center square
  // x_positions now looks like:
  // 000
  // 010
  // 000
  assert!(x_positions.is_set(1,1).ok().unwrap());
  // ... snip
}

[src]

Returns true if the bit at the given coords is set, false otherwise. May error out if given out-of-bounds coordinates. See #set for examples

[src]

[src]

Flip the value of the bit at (x,y)

Examples

extern crate typenum;
extern crate bitboard;

use typenum::consts::U3;
use bitboard::Bitboard;

type TicTacToe = bitboard::Bitboard<U3>;
fn main() {
  let mut x_positions : TicTacToe = Bitboard::new();
  // X has taken no positions
  // 000
  // 000
  // 000
  assert!(!x_positions.is_set(1,1).ok().unwrap()); // the center square is free!

  x_positions.flip(1,1); // take the center square
  // x_positions now looks like:
  // 000
  // 010
  // 000
  assert!(x_positions.is_set(1,1).ok().unwrap());

  x_positions.flip(1,1); // undo that

  assert!(!x_positions.is_set(1,1).ok().unwrap());
}

[src]

Unset the bit at location (x,y)

[src]

Returns true if the bit at the given coords is set, false otherwise. May error out if given out-of-bounds coordinates. See #set for examples

[src]

Return the alignment, in bytes, of the Bitboard

# Examples

extern crate typenum;
    extern crate bitboard;

    use typenum::consts::U8;
    use bitboard::Bitboard;

    fn main() {
        assert_eq!(Bitboard::<U8>::alignment(), 8);
    }

[src]

Return the alignment, in bits, of the Bitboard

# Examples

extern crate typenum;
    extern crate bitboard;

    use typenum::consts::U8;
    use bitboard::Bitboard;


    fn main() {
        assert_eq!(Bitboard::<U8>::alignment_bits(), 64);
    }

[src]

Return the size, in bytes, needed to allocate the bitboard.

# Examples

extern crate typenum;
    extern crate bitboard;

    use typenum::consts::{U8,U19};
    use bitboard::Bitboard;

    fn main() {
        // chess boards
        assert_eq!(Bitboard::<U8>::byte_size(), 8);
        // go boards
        assert_eq!(Bitboard::<U19>::byte_size(), 48);
    }

Trait Implementations

impl<N: Unsigned> Drop for Bitboard<N>
[src]

[src]

Executes the destructor for this type. Read more

impl<N: Unsigned> Debug for Bitboard<N>
[src]

[src]

Formats the value using the given formatter.

impl<N: Unsigned> Display for Bitboard<N>
[src]

[src]

Formats the value using the given formatter. Read more

impl<N: Unsigned> PartialEq for Bitboard<N>
[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<N: Unsigned> Eq for Bitboard<N>
[src]

impl<N: Unsigned> Hash for Bitboard<N>
[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<N: Unsigned> Clone for Bitboard<N>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<N: Unsigned> BitAnd for Bitboard<N>
[src]

The resulting type after applying the & operator.

[src]

Performs the & operation.

impl<N: Unsigned> BitAndAssign for Bitboard<N>
[src]

[src]

Performs the &= operation.

impl<N: Unsigned> BitOr for Bitboard<N>
[src]

The resulting type after applying the | operator.

[src]

Performs the | operation.

impl<N: Unsigned> BitOrAssign for Bitboard<N>
[src]

[src]

Performs the |= operation.

impl<N: Unsigned> BitXor for Bitboard<N>
[src]

The resulting type after applying the ^ operator.

[src]

Performs the ^ operation.

impl<N: Unsigned> BitXorAssign for Bitboard<N>
[src]

[src]

Performs the ^= operation.

impl<N: Unsigned> Not for Bitboard<N>
[src]

The resulting type after applying the ! operator.

[src]

Performs the unary ! operation.