diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-18 20:55:21 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-18 20:55:21 +0200 |
| commit | a4024e15a807e26ddad04d6804742fab0d6c8c96 (patch) | |
| tree | 7e951f816614fbf40eba1b32cbee61bbb54fbdfb /src/misc.cpp | |
| parent | fcc0dc87f04403c8073ab769d3046d32342e6c2a (diff) | |
perf(board): implementing magic bitboards for faster move generation
Diffstat (limited to 'src/misc.cpp')
| -rw-r--r-- | src/misc.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index e9073d4..a69054b 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -1,6 +1,8 @@ #include "misc.hpp" +#include "board/board.hpp" #include "moves.hpp" #include <cstdint> +#include <iostream> #include <string_view> #include <vector> @@ -31,3 +33,44 @@ uint64_t MoveGenTest(uint32_t depth, Game *g) { } return positionCount; } + +uint64_t MoveGenTestDivide(uint32_t depth, Game *g) { + if (depth == 0) { + return 1; + } + + uint64_t total = 0; + + std::vector<uint16_t> moves = GetLegalMoves(g, ALL); + + for (uint16_t move : moves) { + uint8_t from = getFromValueFromMove(move); + uint8_t to = getToValueFromMove(move); + Position fromPos = IndexToPosition(from); + Position toPos = IndexToPosition(to); + + Undo undo = MakeMove(move, g); + + uint64_t count = MoveGenTest(depth - 1, g); + + UndoMove(undo, g); + + char fromFile = static_cast<char>('a' + fromPos.file); + char toFile = static_cast<char>('a' + toPos.file); + std::cout << fromFile << (fromPos.rank + 1) << toFile << (toPos.rank + 1); + PieceType promo = getPromotionTypeFromMove(move); + if (promo == QUEEN) + std::cout << 'q'; + else if (promo == ROOK) + std::cout << 'r'; + else if (promo == KNIGHT) + std::cout << 'n'; + else if (promo == BISHOP) + std::cout << 'b'; + std::cout << ": " << count << "\n"; + total += count; + } + + std::cout << "\nTotal: " << total << "\n"; + return total; +} |
