diff options
| author | Scott Gasch <[email protected]> | 2026-10-25 10:39:58 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-10-25 10:39:58 -0700 |
| commit | f97b2710981e936cfb500ad0cdf1ceab233efad8 (patch) | |
| tree | 0004275d9dae8f7df4b5f86f3b750d80bc3f4a52 /src/chess.h | |
| parent | 3927a4cac6ec254a8e34a5e864300f75c3efc9f3 (diff) | |
Make bitboard move generation unconditional; delete the mailbox fallback
All GENERATE_*_BITBOARD/EXPOSESCHECK_BITBOARD/ISATTACKED_BITBOARD/
UNBLOCKED_BITBOARD flags were already default-on (ifndef
DISABLE_BITBOARD_MOVEGEN); this removes that opt-out entirely (GNUmakefile)
and deletes the mailbox-era code the flags used to toggle between, since
there's no longer a build configuration that still needs it:
- generate.c: the mailbox per-piece generators and escape-generators
(GenerateKnight/GenerateWhiteKnight/GenerateBishop/GenerateRook/
GenerateQueen/GenerateBlackKing/GenerateWhiteKing/GenerateWhitePawn/
GenerateBlackPawn and their SaveMe* escape-generator counterparts),
_FindUnblockedSquares and its DEBUG-build cross-check inside
_FindUnblockedSquaresBB, and the dispatch-table #if/#else pairs that
chose between mailbox and bitboard functions (now unconditionally
bitboard). WouldGiveCheck simplified to its UNBLOCKED_BITBOARD-only
body. g_iBDeltas/g_iRDeltas (orphaned once their only consumers were
deleted) removed; g_iNDeltas (still used by data.c's InitMagic) moved
there, next to its real consumer.
- movesup.c: mailbox FasterExposesCheck/ExposesCheck/ExposesCheckEp/
IsAttacked/InCheck deleted; chess.h's three-way macro choice
simplified to a direct #define onto the BB versions (ExposesCheckBB/
IsAttackedBB/etc. are simply "the" implementation now).
- testsee.c/testgenerate.c: deleted the mailbox-vs-BB comparison/speed
harnesses that only existed to validate code just removed
(TestIsAttackedBB, TestGenerateKnightSpeed/KingSpeed/RookSpeed/
BishopSpeed/QueenSpeed, TestFindUnblockedSquaresSpeed's mailbox arm).
TestGetAttacks and the _GenerateAllMoves-vs-_GenerateAllMovesBB
dispatch-overhead benchmark are unaffected -- GetAttacks' mailbox/asm
predecessors were already retired independently, and that pair
compares two still-live BB-only dispatch strategies, not mailbox vs
BB.
Verified: clean release build and a clean DEBUG=1 TEST=1 self-test run
(move generation, perft-style legal-move checks, SAN/ICS parsing,
search smoke test) with no assertion failures.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/chess.h')
| -rwxr-xr-x | src/chess.h | 132 |
1 files changed, 10 insertions, 122 deletions
diff --git a/src/chess.h b/src/chess.h index 85b4bd7..2942f0a 100755 --- a/src/chess.h +++ b/src/chess.h @@ -950,17 +950,12 @@ MOVE_STACK; #define GENERATE_DONT_SCORE (5) // generate.c's _GenerateCapturesAndPromotions (GENERATE_CAPTURES_PROMS's -// direct, non-filtered generator) exists only when every piece type is -// on its bitboard generator -- see that function's block comment in -// generate.c. Declared here, not in generate.c, so every translation -// unit that needs to know whether it exists (main.c's test-registration -// list, testgenerate.c's own tests) sees the same answer generate.c's -// GenerateMoves dispatch does. -#if defined(GENERATE_KNIGHT_BITBOARD) && defined(GENERATE_BISHOP_BITBOARD) && \ - defined(GENERATE_ROOK_BITBOARD) && defined(GENERATE_QUEEN_BITBOARD) && \ - defined(GENERATE_KING_BITBOARD) && defined(GENERATE_PAWN_BITBOARD) +// direct, non-filtered generator) -- every piece type is always on its +// bitboard generator now, so this is unconditional; kept as a named +// macro (rather than inlined away) so main.c's test-registration list +// and testgenerate.c's own tests keep one clearly-named thing to guard +// on, matching generate.c's own #if there. #define CAPTURES_PROMS_BITBOARD_PATH 1 -#endif #ifdef TEST #define GENERATE_ALL_MOVES_CHECK_OK (6) @@ -3446,24 +3441,9 @@ DumpMove(ULONG u); #define MOVE_TO_INDEX(mv) (((mv).uMove & 0xFFFF) + \ (0x10000 * GET_COLOR(mv.pMoved))) -COOR -FasterExposesCheck(POSITION *pos, - COOR cRemove, - COOR cLocation); - -COOR -ExposesCheck(POSITION *pos, - COOR cRemove, - COOR cLocation); - -COOR -ExposesCheckEp(POSITION *pos, - COOR cTest, - COOR cIgnore, - COOR cBlock, - COOR cKing); - -// board_representation/MOVEGEN_MIGRATION.md section 6b +// board_representation/MOVEGEN_MIGRATION.md section 6b. The mailbox +// originals (and the three-way #ifdef choice between them and these) +// are retired -- these are simply the real implementations now. COOR FasterExposesCheckBB(POSITION *pos, COOR cRemove, @@ -3481,29 +3461,9 @@ ExposesCheckEpBB(POSITION *pos, COOR cBlock, COOR cKing); -// Three-way choice matching GetAttacks's own pattern (MIGRATION.md -// section 6): EXPOSESCHECK_BITBOARD defined -> the BB versions above; -// else the mailbox versions declared right above this block. -#if defined(EXPOSESCHECK_BITBOARD) #define ExposesCheck ExposesCheckBB #define FasterExposesCheck FasterExposesCheckBB #define ExposesCheckEp ExposesCheckEpBB -#endif - -// Real mailbox declarations first, unconditionally, so the plain names -// "IsAttacked"/"InCheck" are always genuinely declared -- the #define -// below only affects *later* call sites in files that include this -// header after this point, matching GetAttacks's own three-way-choice -// pattern (chess.h, `GetAttacks` block) exactly. Declaring these after -// the #define instead (an earlier mistake here, caught by testsee.c's -// TestIsAttackedBB needing to call the real mailbox function by name) -// would macro-substitute this very declaration too, leaving the real -// name never actually declared anywhere. -FLAG -IsAttacked(COOR cTest, POSITION *pos, ULONG uSide); - -FLAG -InCheck(POSITION *pos, ULONG uSide); FLAG IsAttackedBB(COOR cTest, POSITION *pos, ULONG uSide); @@ -3511,13 +3471,8 @@ IsAttackedBB(COOR cTest, POSITION *pos, ULONG uSide); FLAG FORCEINLINE InCheckBB(POSITION *pos, ULONG uSide); -// ISATTACKED_BITBOARD defined -> the BB versions above resolve plain -// "IsAttacked"/"InCheck" call sites from here on; else the mailbox -// versions declared just above stay live. -#if defined(ISATTACKED_BITBOARD) #define IsAttacked IsAttackedBB #define InCheck InCheckBB -#endif FLAG SanityCheckMove(POSITION *pos, MOVE mv); @@ -3675,8 +3630,6 @@ TestMakeUnmakeMove(void); extern const int g_iQKDeltas[9]; extern const int g_iNDeltas[9]; -extern const int g_iBDeltas[5]; -extern const int g_iRDeltas[5]; void GenerateMoves(SEARCHER_THREAD_CONTEXT *ctx, @@ -3703,45 +3656,23 @@ _RookAttacksBB(COOR c, BITBOARD bbOccupied); BITBOARD _BishopAttacksBB(COOR c, BITBOARD bbOccupied); -// generate.c's bitboard replacement for _FindUnblockedSquares, exposed -// non-static so testgenerate.c's correctness/speed harness can call it -// directly regardless of whether UNBLOCKED_BITBOARD is defined for -// this build. +// generate.c's bitboard build of pStack->bbUnblocked -- the mailbox +// original (and its DEBUG-build cross-check against this) is retired. void _FindUnblockedSquaresBB(MOVE_STACK *pStack, POSITION *pos); -// The mailbox original, exposed non-static (compiled whenever -// !UNBLOCKED_BITBOARD, or under DEBUG/TEST for the cross-check and -// the test harness above) under the same build conditions generate.c -// itself uses -- see generate.c. -#if !defined(UNBLOCKED_BITBOARD) || defined(DEBUG) || defined(TEST) -void -_FindUnblockedSquares(MOVE_STACK *pStack, - POSITION *pos); -#endif - void _GenerateRookBB(MOVE_STACK *pStack, POSITION *pos, COOR cRook); void -GenerateRook(MOVE_STACK *pStack, - POSITION *pos, - COOR cRook); - -void _GenerateBishopBB(MOVE_STACK *pStack, POSITION *pos, COOR cBishop); void -GenerateBishop(MOVE_STACK *pStack, - POSITION *pos, - COOR cBishop); - -void _GenerateQueenBB(MOVE_STACK *pStack, POSITION *pos, COOR cQueen); @@ -3802,40 +3733,15 @@ _SaveMeAllPawnMovesBB(MOVE_STACK *pStack, BITBOARD bbTargetMask); void -GenerateQueen(MOVE_STACK *pStack, - POSITION *pos, - COOR cQueen); - -void _GenerateKnightBB(MOVE_STACK *pStack, POSITION *pos, COOR cKnight); void -GenerateKnight(MOVE_STACK *pStack, - POSITION *pos, - COOR cKnight); - -void -GenerateWhiteKnight(MOVE_STACK *pStack, - POSITION *pos, - COOR cKnight); - -void _GenerateKingBB(MOVE_STACK *pStack, POSITION *pos, COOR cKing); -void -GenerateBlackKing(MOVE_STACK *pStack, - POSITION *pos, - COOR cKing); - -void -GenerateWhiteKing(MOVE_STACK *pStack, - POSITION *pos, - COOR cKing); - FLAG FORCEINLINE WouldGiveCheck(IN SEARCHER_THREAD_CONTEXT *ctx, IN MOVE mv); @@ -3860,21 +3766,6 @@ void TestNnueAccumulator(void); void -TestGenerateKnightSpeed(void); - -void -TestGenerateKingSpeed(void); - -void -TestGenerateRookSpeed(void); - -void -TestGenerateBishopSpeed(void); - -void -TestGenerateQueenSpeed(void); - -void TestGenerateAllMovesSpeed(void); void @@ -4903,9 +4794,6 @@ void TestGetAttacks(void); void -TestIsAttackedBB(void); - -void TestSeeFastSign(void); void |
