diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-18 18:45:15 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-18 18:45:15 +0530 |
| commit | c9d9bddf3df97ef7987c9824747ec1602522b542 (patch) | |
| tree | 449acf383fb10ccf2210d9af96515275b52cf1a9 /include | |
| parent | 9395e857db95481f6e2494d3a841632be0ff97c8 (diff) | |
zobrist hashing
Diffstat (limited to 'include')
| -rw-r--r-- | include/bitboard.h | 2 | ||||
| -rw-r--r-- | include/engine/magic.h | 1 | ||||
| -rw-r--r-- | include/engine/moves.h | 1 | ||||
| -rw-r--r-- | include/engine/transposition_table.h | 16 | ||||
| -rw-r--r-- | include/random.h | 10 |
5 files changed, 30 insertions, 0 deletions
diff --git a/include/bitboard.h b/include/bitboard.h index 3e1118d..b1ddcf0 100644 --- a/include/bitboard.h +++ b/include/bitboard.h @@ -27,11 +27,13 @@ enum { WHITE_LONG_CASTLE = 1 << 1, BLACK_SHORT_CASTLE = 1 << 2, BLACK_LONG_CASTLE = 1 << 3, + CASTLE_COUNT = 4, }; enum { WHITE_TURN, BLACK_TURN, + TURN_COUNT, }; #define BITMASK_RANK_1 255ULL diff --git a/include/engine/magic.h b/include/engine/magic.h index 7f584a9..1c9f303 100644 --- a/include/engine/magic.h +++ b/include/engine/magic.h @@ -3,6 +3,7 @@ #include "ints.h" #include "bitboard.h" +#include "random.h" typedef struct { bitboard_t mask; diff --git a/include/engine/moves.h b/include/engine/moves.h index 755a77a..cd71cdc 100644 --- a/include/engine/moves.h +++ b/include/engine/moves.h @@ -68,6 +68,7 @@ void get_moves(moves_t *moves, position_t position); bool square_attacked(position_t position, square_t square, u8 by_color); void get_legal_moves(moves_t *moves, position_t position); +int find_piece_on_square(position_t* p, int square); #ifdef MOVES_INTERNAL void __forloop_rook_moves_gen( diff --git a/include/engine/transposition_table.h b/include/engine/transposition_table.h new file mode 100644 index 0000000..f06ddbe --- /dev/null +++ b/include/engine/transposition_table.h @@ -0,0 +1,16 @@ +#ifndef TRANSPOSITION_TABLE_H +#define TRANSPOSITION_TABLE_H + +#include "bitboard.h" + +static struct zobrist_keys { + u64 piece[PIECE_TYPE_COUNT][64]; + u64 castle[CASTLE_COUNT]; + u64 turn[TURN_COUNT]; + u64 en_passant[64]; +} zobrist_keys; + +void transposition_table_init(); +u64 zobrist_hash(position_t position); + +#endif // TRANSPOSITION_TABLE_H diff --git a/include/random.h b/include/random.h new file mode 100644 index 0000000..633c015 --- /dev/null +++ b/include/random.h @@ -0,0 +1,10 @@ +#ifndef RANDOM_H +#define RANDOM_H + +#include "ints.h" + +u64 random_u64(); +u64 random_magic(); + +#endif // RANDOM_H + |
