summaryrefslogtreecommitdiff
path: root/src/generate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/generate.c')
-rwxr-xr-xsrc/generate.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/generate.c b/src/generate.c
index 69e431f..faecc2a 100755
--- a/src/generate.c
+++ b/src/generate.c
@@ -739,14 +739,14 @@ GenerateWhiteKnight(IN MOVE_STACK *pStack,
// lookup needs no such color-specific shortcut, it just ANDs off
// whichever side's occupancy pos->uToMove identifies.
//
-// Full-board occupancy, both sides -- same formula as see.c's static
-// _BuildOccupiedBB (a separate copy, not shared, since that one is
-// file-local to see.c and this module's own convention keeps its
-// bitboard helpers together). Needed by the slider magic-bitboard
-// generators (_GenerateRookBB/_GenerateBishopBB) to index into
-// g_RookAttackTable/g_BishopAttackTable -- see MOVE_STACK's
-// bbOccupied field comment in chess.h. Non-static so testgenerate.c's
-// harness can call it directly.
+// Full-board occupancy, both sides. Callers should prefer reading
+// pos->bbOccupied directly (incrementally maintained, see chess.h and
+// board_representation/EVAL.md section 0) -- this from-scratch
+// rebuild now exists mainly as the ground truth used to verify that
+// field stays in sync (VerifyPositionConsistency, board.c; the
+// ASSERT(pStack->bbOccupied == _BuildFullOccupiedBB(pos)) calls
+// below) and for testgenerate.c's benchmark harness. Non-static so
+// both of those can call it directly.
BITBOARD
_BuildFullOccupiedBB(IN POSITION *pos)
/**
@@ -850,10 +850,11 @@ _BuildFriendlySideBB(IN POSITION *pos, IN ULONG uSide)
Routine description:
Full occupancy bitboard for one side only (all piece types
- including pawns and king) -- see.c's _BuildOccupiedBB ORs both
- sides together for a different purpose (SEE's "is this square
- occupied at all" query); move generation needs just one side's
- squares, to AND off as illegal (self-occupied) destinations.
+ including pawns and king) -- pos->bbOccupied ORs both sides
+ together for a different purpose (SEE's/generation's "is this
+ square occupied at all" query); move generation also needs just
+ one side's squares here, to AND off as illegal (self-occupied)
+ destinations.
Parameters:
@@ -2733,7 +2734,7 @@ Return value:
**/
{
BITBOARD bbPawns = pos->bbPawns[uSide];
- BITBOARD bbOccupied = _BuildFullOccupiedBB(pos);
+ BITBOARD bbOccupied = pos->bbOccupied;
BITBOARD bbEmpty = ~bbOccupied;
BITBOARD bbEnemy = bbOccupied & ~_BuildFriendlySideBB(pos, uSide);
BITBOARD bbSinglePush, bbDoublePush, bbCapLeft, bbCapRight, bb;
@@ -3072,7 +3073,7 @@ Return value:
**/
{
BITBOARD bbPawns = pos->bbPawns[uSide];
- BITBOARD bbOccupied = _BuildFullOccupiedBB(pos);
+ BITBOARD bbOccupied = pos->bbOccupied;
BITBOARD bbEmpty = ~bbOccupied;
BITBOARD bbEnemy = bbOccupied & ~_BuildFriendlySideBB(pos, uSide);
BITBOARD bbSinglePush, bbDoublePush, bbCapLeft, bbCapRight, bb;
@@ -3382,7 +3383,7 @@ Return value:
#endif
#if defined(GENERATE_ROOK_BITBOARD) || defined(GENERATE_BISHOP_BITBOARD) || \
defined(GENERATE_QUEEN_BITBOARD)
- pStack->bbOccupied = _BuildFullOccupiedBB(pos);
+ pStack->bbOccupied = pos->bbOccupied;
#endif
for(u = pos->uNonPawnCount[pos->uToMove][0] - 1;
@@ -3511,7 +3512,7 @@ Return value:
#endif
pStack->bbFriendlyOccupied = _BuildFriendlySideBB(pos, uSide);
- pStack->bbOccupied = _BuildFullOccupiedBB(pos);
+ pStack->bbOccupied = pos->bbOccupied;
bb = pos->bbPieces[uSide][KNIGHT];
while (bb)
@@ -3728,7 +3729,7 @@ Return value:
(void)pKing;
BITBOARD bbFriendly = _BuildFriendlySideBB(pos, pos->uToMove);
BITBOARD bbOccupiedWithoutKing =
- _BuildFullOccupiedBB(pos) & ~COOR_TO_BB(cKing);
+ pos->bbOccupied & ~COOR_TO_BB(cKing);
BITBOARD bbDest = g_KingAttacksBB[cKing] & ~bbFriendly;
ULONG uBitIndex;
@@ -3875,7 +3876,7 @@ Return value:
// _SaveMe*BB call below to share (same amortization reasoning
// as _GenerateAllMoves's own precompute block).
pStack->bbFriendlyOccupied = _BuildFriendlySideBB(pos, pos->uToMove);
- pStack->bbOccupied = _BuildFullOccupiedBB(pos);
+ pStack->bbOccupied = pos->bbOccupied;
bbTargetMask =
_ComputeCheckTargetMaskBB(cKing, c, pStack->bbOccupied);