From 1ebaab7b771c4c73be66895515f948ffe2394cc0 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Mon, 20 Jul 2026 21:14:44 +0530 Subject: simple ttable tests --- src/bitboard.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/bitboard.c') diff --git a/src/bitboard.c b/src/bitboard.c index 1c3ed28..71e66a5 100644 --- a/src/bitboard.c +++ b/src/bitboard.c @@ -73,6 +73,22 @@ char get_piece_char_from_sqr(position_t position, size_t square) { return ' '; } +int find_piece_on_square(position_t* p, int square) { + if ((p->bitboards[WHITE_KING] >> square) & 1) return WHITE_KING; + if ((p->bitboards[WHITE_QUEEN] >> square) & 1) return WHITE_QUEEN; + if ((p->bitboards[WHITE_ROOK] >> square) & 1) return WHITE_ROOK; + if ((p->bitboards[WHITE_BISHOP] >> square) & 1) return WHITE_BISHOP; + if ((p->bitboards[WHITE_KNIGHT] >> square) & 1) return WHITE_KNIGHT; + if ((p->bitboards[WHITE_PAWN] >> square) & 1) return WHITE_PAWN; + if ((p->bitboards[BLACK_KING] >> square) & 1) return BLACK_KING; + if ((p->bitboards[BLACK_QUEEN] >> square) & 1) return BLACK_QUEEN; + if ((p->bitboards[BLACK_ROOK] >> square) & 1) return BLACK_ROOK; + if ((p->bitboards[BLACK_BISHOP] >> square) & 1) return BLACK_BISHOP; + if ((p->bitboards[BLACK_KNIGHT] >> square) & 1) return BLACK_KNIGHT; + if ((p->bitboards[BLACK_PAWN] >> square) & 1) return BLACK_PAWN; + assert(0 && "Failed to find the piece on the square"); +} + void print_position(position_t position) { for (int i = 8; i > 0; i--) { printf("+---+---+---+---+---+---+---+---+\n"); -- cgit v1.2.3