summaryrefslogtreecommitdiff
path: root/src/engine/bitboard.c
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2026-05-31 13:56:43 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2026-05-31 13:56:43 +0530
commitd786ac8fc49391e4efc69891b135979aa2848701 (patch)
tree011f6ae51da54494495c21a8a1240233a6d3f642 /src/engine/bitboard.c
parent8671756d141292d4ec9747ec8de6e9cf3324777d (diff)
replaced asserts with test failures
Diffstat (limited to 'src/engine/bitboard.c')
-rw-r--r--src/engine/bitboard.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/engine/bitboard.c b/src/engine/bitboard.c
index 2d123ea..6e4f1b6 100644
--- a/src/engine/bitboard.c
+++ b/src/engine/bitboard.c
@@ -28,16 +28,21 @@ position_t position_starting() {
}
void assert_valid_position(position_t position) {
- assert(position.castling <=
+ assert(check_valid_position(position) == true);
+}
+
+bool check_valid_position(position_t position) {
+ if (position.castling >
(
WHITE_SHORT_CASTLE | WHITE_LONG_CASTLE |
BLACK_SHORT_CASTLE | BLACK_LONG_CASTLE
)
- );
- assert(position.turn == WHITE_TURN || position.turn == BLACK_TURN);
- assert(position.passantable_file <= 8); // 0 means no passant
- assert(position.bitboards[WHITE_KING] != 0);
- assert(position.bitboards[BLACK_KING] != 0);
+ ) return false;
+ if (position.turn != WHITE_TURN && position.turn != BLACK_TURN) return false;
+ if (position.passantable_file > 8) return false; // 0 means no passant
+ if (position.bitboards[WHITE_KING] == 0) return false;
+ if (position.bitboards[BLACK_KING] == 0) return false;
+ return true;
}
bitboard_t whites(position_t position) {