- checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them);
- checkSq[KNIGHT] = pos.attacks_from<KNIGHT>(ksq);
- checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
- checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
- checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
- checkSq[KING] = 0;
+ checkSquares[PAWN] = pos.attacks_from<PAWN>(ksq, them);
+ checkSquares[KNIGHT] = pos.attacks_from<KNIGHT>(ksq);
+ checkSquares[BISHOP] = pos.attacks_from<BISHOP>(ksq);
+ checkSquares[ROOK] = pos.attacks_from<ROOK>(ksq);
+ checkSquares[QUEEN] = checkSquares[BISHOP] | checkSquares[ROOK];
+ checkSquares[KING] = 0;
+}
+
+
+/// operator<<(Position) returns an ASCII representation of the position
+
+std::ostream& operator<<(std::ostream& os, const Position& pos) {
+
+ os << "\n +---+---+---+---+---+---+---+---+\n";
+
+ for (Rank r = RANK_8; r >= RANK_1; --r)
+ {
+ for (File f = FILE_A; f <= FILE_H; ++f)
+ os << " | " << PieceToChar[pos.piece_on(make_square(f, r))];
+
+ os << " |\n +---+---+---+---+---+---+---+---+\n";
+ }
+
+ os << "\nFen: " << pos.fen() << "\nKey: " << std::hex << std::uppercase
+ << std::setfill('0') << std::setw(16) << pos.key() << std::dec << "\nCheckers: ";
+
+ for (Bitboard b = pos.checkers(); b; )
+ os << UCI::square(pop_lsb(&b)) << " ";
+
+ return os;