diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-20 21:14:44 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-20 21:14:44 +0530 |
| commit | 1ebaab7b771c4c73be66895515f948ffe2394cc0 (patch) | |
| tree | 47ae3d951056cc9a3e3b4aa76f0b15fd631a16b0 /src/bitboard.c | |
| parent | a0970bddbd9f6b97b6a12ba7f73fd1810a2e1e1b (diff) | |
simple ttable tests
Diffstat (limited to 'src/bitboard.c')
| -rw-r--r-- | src/bitboard.c | 16 |
1 files changed, 16 insertions, 0 deletions
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"); |
