summaryrefslogtreecommitdiff
path: root/src/testsee.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-10-25 10:39:58 -0700
committerScott Gasch <[email protected]>2026-10-25 10:39:58 -0700
commitf97b2710981e936cfb500ad0cdf1ceab233efad8 (patch)
tree0004275d9dae8f7df4b5f86f3b750d80bc3f4a52 /src/testsee.c
parent3927a4cac6ec254a8e34a5e864300f75c3efc9f3 (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/testsee.c')
-rw-r--r--src/testsee.c125
1 files changed, 0 insertions, 125 deletions
diff --git a/src/testsee.c b/src/testsee.c
index 240ac39..4afe60f 100644
--- a/src/testsee.c
+++ b/src/testsee.c
@@ -26,19 +26,6 @@ Revision History:
#include "chess.h"
-// Same reasoning, for IsAttacked/InCheck (board_representation/
-// MOVEGEN_MIGRATION.md section 6b's ISATTACKED_BITBOARD toggle):
-// TestIsAttackedBB below must always be able to call the real mailbox
-// IsAttacked by name and compare it against IsAttackedBB explicitly,
-// regardless of which one chess.h's macro currently routes plain
-// "IsAttacked(...)" calls to elsewhere in the engine.
-#ifdef IsAttacked
-#undef IsAttacked
-#endif
-#ifdef InCheck
-#undef InCheck
-#endif
-
#ifdef TEST_BROKEN
ULONG g_uRootOnMove;
@@ -264,118 +251,6 @@ TestGetAttacks(void)
}
}
-// board_representation/MOVEGEN_MIGRATION.md section 6b: direct
-// comparison harness for IsAttacked/IsAttackedBB, same pattern as
-// TestGetAttacks above -- mailbox vs. bitboard, same inputs, must
-// match exactly. This is the piece ExposesCheckBB didn't get before
-// shipping and had to be debugged the hard way instead (two real bugs
-// found via TestSan/perft/DEBUG-assert failures rather than a direct
-// comparison); doing it properly here from the start.
-void
-TestIsAttackedBB(void)
-{
- POSITION pos;
- ULONG u;
- COOR c;
- ULONG uSide;
- FLAG fMailbox, fBB;
-
- Trace("Testing IsAttacked...\n");
- for (u = 0; u < 20000; u++)
- {
- GenerateRandomLegalPosition(&pos);
- FOREACH_SQUARE(c)
- {
- if (!IS_ON_BOARD(c)) continue;
- for (uSide = BLACK; uSide <= WHITE; uSide++)
- {
- fMailbox = IsAttacked(c, &pos, uSide);
- fBB = IsAttackedBB(c, &pos, uSide);
- if (fMailbox != fBB)
- {
- UtilPanic(TESTCASE_FAILURE,
- &pos,
- "IsAttacked/IsAttackedBB mismatch",
- NULL, NULL,
- __FILE__, __LINE__);
- }
- }
- }
- for (uSide = BLACK; uSide <= WHITE; uSide++)
- {
- fMailbox = InCheck(&pos, uSide);
- fBB = InCheckBB(&pos, uSide);
- if (fMailbox != fBB)
- {
- UtilPanic(TESTCASE_FAILURE,
- &pos,
- "InCheck/InCheckBB mismatch",
- NULL, NULL,
- __FILE__, __LINE__);
- }
- }
- }
-
- //
- // Speed: same isolated cycles/call methodology as TestGetAttacks
- // above, interleaved call-by-call to cancel shared-box noise.
- //
- {
- static const char *rgszFen[3] =
- {
- "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
- "r1bq1rk1/pp2bppp/2n1pn2/2pp4/3P4/2NBPN2/PP3PPP/R1BQ1RK1 w - - 0 1",
- "8/5k2/8/3K4/8/8/8/4R3 w - - 0 1",
- };
- static const char *rgszLabel[3] =
- {
- "opening ", "middlegame", "endgame ",
- };
- POSITION posBench;
- UINT64 u64MailboxTotal, u64BBTotal, u64Start;
- ULONG uIter;
- ULONG uSq;
- COOR cBench;
- ULONG uSideBench;
- const ULONG uCallsPerPosition = 200000;
- FLAG fSink;
-
- Trace("Benchmarking IsAttacked: mailbox vs IsAttackedBB "
- "(interleaved, %lu calls/position)...\n",
- uCallsPerPosition);
- for (u = 0; u < 3; u++)
- {
- FenToPosition(&posBench, (char *)rgszFen[u]);
- u64MailboxTotal = 0;
- u64BBTotal = 0;
- for (uIter = 0; uIter < uCallsPerPosition; uIter++)
- {
- uSq = uIter % 64;
- cBench = BIT_NUMBER_TO_COOR(uSq);
- uSideBench = uIter & 1;
- if (!IS_ON_BOARD(cBench)) continue;
-
- u64Start = SystemReadTimeStampCounter();
- fSink = IsAttacked(cBench, &posBench, uSideBench);
- u64MailboxTotal += (SystemReadTimeStampCounter() - u64Start);
-
- u64Start = SystemReadTimeStampCounter();
- fSink = IsAttackedBB(cBench, &posBench, uSideBench);
- u64BBTotal += (SystemReadTimeStampCounter() - u64Start);
- (void)fSink;
- }
- printf(" %s: mailbox %" COMPILER_LONGLONG_UNSIGNED_FORMAT
- " cycles/call, IsAttackedBB %"
- COMPILER_LONGLONG_UNSIGNED_FORMAT " cycles/call "
- "(BB is %.2fx mailbox)\n",
- rgszLabel[u],
- u64MailboxTotal / uCallsPerPosition,
- u64BBTotal / uCallsPerPosition,
- (double)u64BBTotal / (double)u64MailboxTotal);
- }
- }
-}
-
// SeeFastSign (see.c) is a sign-only shortcut for SEE(pos, mv) >= 0 --
// GetMoveSee's only consumer (ComputeMoveExtension, searchsup.c) never
// reads the magnitude, only the sign, so this skips SEE()'s list-