#if !defined(PAWNS_H_INCLUDED)
#define PAWNS_H_INCLUDED
+#include "misc.h"
#include "position.h"
-#include "tt.h"
#include "types.h"
const int PawnTableSize = 16384;
class PawnEntry {
- friend class PawnTable;
+ friend struct PawnTable;
public:
Score pawns_value() const;
Bitboard passedPawns[2];
Bitboard pawnAttacks[2];
Square kingSquares[2];
+ int minKPdistance[2];
+ int castleRights[2];
Score value;
int halfOpenFiles[2];
Score kingSafety[2];
/// The PawnTable class represents a pawn hash table. The most important
/// method is probe, which returns a pointer to a PawnEntry object.
-class PawnTable : public HashTable<PawnEntry, PawnTableSize> {
-public:
- PawnEntry* probe(const Position& pos) const;
+struct PawnTable {
+
+ PawnEntry* probe(const Position& pos);
-private:
template<Color Us>
static Score evaluate_pawns(const Position& pos, Bitboard ourPawns,
- Bitboard theirPawns, PawnEntry* pi);
+ Bitboard theirPawns, PawnEntry* e);
+
+ HashTable<PawnEntry, PawnTableSize> entries;
};
template<Color Us>
inline Score PawnEntry::king_safety(const Position& pos, Square ksq) {
- return kingSquares[Us] == ksq ? kingSafety[Us] : update_safety<Us>(pos, ksq);
+ return kingSquares[Us] == ksq && castleRights[Us] == pos.can_castle(Us)
+ ? kingSafety[Us] : update_safety<Us>(pos, ksq);
}
#endif // !defined(PAWNS_H_INCLUDED)