[Board] Add method to print BitBoard
This commit is contained in:
19
Board.cpp
19
Board.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
Board::Board() {
|
Board::Board() {
|
||||||
}
|
}
|
||||||
@@ -197,6 +198,24 @@ bool Board::isMoveCastling(const BitBoard &from, const BitBoard &to, const Piece
|
|||||||
|
|
||||||
return (from & indexToBitBoard(E8));
|
return (from & indexToBitBoard(E8));
|
||||||
}
|
}
|
||||||
|
void Board::printBitBoard(const Board::BitBoard &bb) {
|
||||||
|
// For debugging only, performance isn't important
|
||||||
|
for (int i = 7; i >= 0; i--) {
|
||||||
|
int rank = i * 8;
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
// Get the piece for this index. Assume it exists.
|
||||||
|
// Print piece, otherwise '.';
|
||||||
|
if (bb & (1ULL << (rank + j))) {
|
||||||
|
std::cout << 1;
|
||||||
|
} else {
|
||||||
|
std::cout << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << ' ';
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Board &board) {
|
std::ostream &operator<<(std::ostream &os, const Board &board) {
|
||||||
// For debugging only, performance isn't important
|
// For debugging only, performance isn't important
|
||||||
|
@@ -127,6 +127,7 @@ private:
|
|||||||
return __builtin_ctzll(b);
|
return __builtin_ctzll(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void printBitBoard(const BitBoard &bb);
|
||||||
void handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece);
|
void handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece);
|
||||||
void handleEnPassant(const Move &move, const Piece &movedPiece);
|
void handleEnPassant(const Move &move, const Piece &movedPiece);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user