mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Micro optimize open files calculation
Committed mostly because is also a cleanup... No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
a0474a72a6
commit
9c9914d72a
1 changed files with 10 additions and 11 deletions
|
@ -124,18 +124,19 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const {
|
|||
|
||||
// Clear the PawnInfo object, and set the key
|
||||
memset(pi, 0, sizeof(PawnInfo));
|
||||
pi->halfOpenFiles[WHITE] = pi->halfOpenFiles[BLACK] = 0xFF;
|
||||
pi->kingSquares[WHITE] = pi->kingSquares[BLACK] = SQ_NONE;
|
||||
pi->key = key;
|
||||
|
||||
// Calculate pawn attacks
|
||||
Bitboard whitePawns = pos.pieces(PAWN, WHITE);
|
||||
Bitboard blackPawns = pos.pieces(PAWN, BLACK);
|
||||
pi->pawnAttacks[WHITE] = ((whitePawns << 9) & ~FileABB) | ((whitePawns << 7) & ~FileHBB);
|
||||
pi->pawnAttacks[BLACK] = ((blackPawns >> 7) & ~FileABB) | ((blackPawns >> 9) & ~FileHBB);
|
||||
Bitboard wPawns = pos.pieces(PAWN, WHITE);
|
||||
Bitboard bPawns = pos.pieces(PAWN, BLACK);
|
||||
pi->pawnAttacks[WHITE] = ((wPawns << 9) & ~FileABB) | ((wPawns << 7) & ~FileHBB);
|
||||
pi->pawnAttacks[BLACK] = ((bPawns >> 7) & ~FileABB) | ((bPawns >> 9) & ~FileHBB);
|
||||
|
||||
// Evaluate pawns for both colors
|
||||
pi->value = evaluate_pawns<WHITE>(pos, whitePawns, blackPawns, pi)
|
||||
- evaluate_pawns<BLACK>(pos, blackPawns, whitePawns, pi);
|
||||
pi->value = evaluate_pawns<WHITE>(pos, wPawns, bPawns, pi)
|
||||
- evaluate_pawns<BLACK>(pos, bPawns, wPawns, pi);
|
||||
return pi;
|
||||
}
|
||||
|
||||
|
@ -154,11 +155,6 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
|
|||
const BitCountType Max15 = CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
|
||||
const Square* ptr = pos.piece_list_begin(Us, PAWN);
|
||||
|
||||
// Initialize halfOpenFiles[]
|
||||
for (f = FILE_A; f <= FILE_H; f++)
|
||||
if (!(ourPawns & file_bb(f)))
|
||||
pi->halfOpenFiles[Us] |= (1 << f);
|
||||
|
||||
// Loop through all pawns of the current color and score each pawn
|
||||
while ((s = *ptr++) != SQ_NONE)
|
||||
{
|
||||
|
@ -167,6 +163,9 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
|
|||
f = square_file(s);
|
||||
r = square_rank(s);
|
||||
|
||||
// This file cannot be half open
|
||||
pi->halfOpenFiles[Us] &= ~(1 << f);
|
||||
|
||||
// Our rank plus previous one. Used for chain detection.
|
||||
b = rank_bb(r) | rank_bb(Us == WHITE ? r - Rank(1) : r + Rank(1));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue