The Pedigree Project  0.1
Public Member Functions | Private Attributes | List of all members
Bitboard Class Reference
+ Collaboration diagram for Bitboard:

Public Member Functions

 Bitboard ()
 
 Bitboard (unsigned char squares[64])
 
 Bitboard (Square sq)
 
unsigned char getRank (int n)
 
void setRank (int n, unsigned char c)
 
bool test (int rank, int file)
 
bool clear (int rank, int file)
 
bool set (int rank, int file)
 
void clear ()
 
bool empty ()
 
void flip ()
 
void rotate180 ()
 
unsigned char getDiagonalRank45 (int rank, int file, int *newFile)
 
unsigned char getDiagonalRank315 (int rank, int file, int *newFile)
 
void setDiagonalRank45 (int rank, int file, unsigned char newRank)
 
void setDiagonalRank315 (int rank, int file, unsigned char newRank)
 
void shift (int colOffset, int rowOffset)
 
Square getAndClearFirstSetBit ()
 
void print ()
 
Bitboard operator| (Bitboard b2)
 
Bitboard operator& (Bitboard b2)
 
Bitboard operator xor (Bitboard b2)
 
Bitboard operator~ ()
 
 operator bool ()
 

Private Attributes

union {
   uint64_t   i
 
   unsigned char   c [8]
 
member
 

Detailed Description

Definition at line 27 of file Bitboard.h.

Constructor & Destructor Documentation

Bitboard::Bitboard ( )

Constructs a bitboard, intialising to all zeroes.

Definition at line 25 of file Bitboard.cc.

Bitboard::Bitboard ( unsigned char  squares[64])

Constructs a bitboard, taking an array of bytes, each representing one square.

Definition at line 30 of file Bitboard.cc.

Member Function Documentation

bool Bitboard::clear ( int  rank,
int  file 
)
inline

Clears the bit at rank, file

Definition at line 75 of file Bitboard.h.

Referenced by SideState::friendlyMove().

+ Here is the caller graph for this function:

void Bitboard::clear ( )
inline

Clears the entire bitboard.

Definition at line 91 of file Bitboard.h.

bool Bitboard::empty ( )
inline

Is this bitboard completely empty?

Definition at line 99 of file Bitboard.h.

References flip(), operator|(), print(), and rotate180().

void Bitboard::flip ( )

Flips the board so rows become columns and vice versa.

Definition at line 56 of file Bitboard.cc.

Referenced by empty().

+ Here is the caller graph for this function:

unsigned char Bitboard::getRank ( int  n)
inline

Retrieves a rank in byte form.

Definition at line 51 of file Bitboard.h.

Bitboard Bitboard::operator| ( Bitboard  b2)

Overloaded bitwise functions.

Definition at line 209 of file Bitboard.cc.

Referenced by empty().

+ Here is the caller graph for this function:

void Bitboard::print ( )

Debugging function - prints out a bitboard.

Definition at line 40 of file Bitboard.cc.

References test().

Referenced by empty().

+ Here is the caller graph for this function:

void Bitboard::rotate180 ( )

Rotates the board 180 degrees. Used for swapping sides (black -> white etc)

Definition at line 77 of file Bitboard.cc.

References test().

Referenced by BoardState::dump(), empty(), BoardState::firstPawn(), BoardState::isLegal(), and BoardState::move().

+ Here is the caller graph for this function:

bool Bitboard::set ( int  rank,
int  file 
)
inline

Sets the bit at rank, file

Definition at line 83 of file Bitboard.h.

Referenced by BoardState::dump(), SideState::friendlyMove(), and SideState::isAttacking().

+ Here is the caller graph for this function:

void Bitboard::setRank ( int  n,
unsigned char  c 
)
inline

Sets a rank in byte form.

Definition at line 59 of file Bitboard.h.

bool Bitboard::test ( int  rank,
int  file 
)
inline

Tests the bit at rank, file

Definition at line 67 of file Bitboard.h.

Referenced by print(), and rotate180().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: