summaryrefslogtreecommitdiff
path: root/src/engine/bitboard.c
diff options
context:
space:
mode:
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) {