Cache king shelter info in pawns structure

It does not change often and is not so fast
to calculate.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-05-16 16:15:05 +02:00
parent a75aa6035b
commit f83b899f39
2 changed files with 26 additions and 4 deletions

View File

@@ -709,11 +709,19 @@ namespace {
// King shelter
if (relative_rank(us, s) <= RANK_4)
{
Bitboard pawns = p.pawns(us) & this_and_neighboring_files_bb(s);
Rank r = square_rank(s);
for (int i = 1; i < 4; i++)
shelter += count_1s_8bit(shiftRowsDown(pawns, r+i*sign)) * (128>>i);
// Shelter cache lookup
shelter = ei.pi->kingShelter(us, s);
if (shelter == -1)
{
shelter = 0;
Bitboard pawns = p.pawns(us) & this_and_neighboring_files_bb(s);
Rank r = square_rank(s);
for (int i = 1; i < 4; i++)
shelter += count_1s_8bit(shiftRowsDown(pawns, r+i*sign)) * (128>>i);
// Cache shelter value in pawn info
ei.pi->setKingShelter(us, s, shelter);
}
ei.mgValue += sign * Value(shelter);
}