From a4024e15a807e26ddad04d6804742fab0d6c8c96 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 18 Aug 2026 20:55:21 +0200 Subject: perf(board): implementing magic bitboards for faster move generation --- src/moves.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/moves.hpp') diff --git a/src/moves.hpp b/src/moves.hpp index e0ed427..47e41c0 100644 --- a/src/moves.hpp +++ b/src/moves.hpp @@ -10,12 +10,16 @@ enum move_generate_options : std::uint8_t { CAPTUARES_ONLY, NON_CAPTUARES_ONLY, }; - +void initMagicBitboards(); std::vector GetLegalMoves(Game *g, const move_generate_options &options); std::vector GetPseudoLegalMoves(const Game &g, const move_generate_options &options); -Position IndexToPosition(int i); +constexpr Position IndexToPosition(int i) { + auto rank = static_cast(i / 8); + auto file = static_cast(i % 8); + return {.rank = rank, .file = file}; +} bool IsSquareAttacked(const Game &g, Position square, bool byColor); GameState GetNewGameState(Game *g); -- cgit v1.2.3