2 Glaurung, a UCI chess playing engine.
3 Copyright (C) 2004-2008 Tord Romstad
5 Glaurung is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 Glaurung is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #if !defined(PAWNS_H_INCLUDED)
21 #define PAWNS_H_INCLUDED
34 /// PawnInfo is a class which contains various information about a pawn
35 /// structure. Currently, it only includes a middle game and an end game
36 /// pawn structure evaluation, and a bitboard of passed pawns. We may want
37 /// to add further information in the future. A lookup to the pawn hash table
38 /// (performed by calling the get_pawn_info method in a PawnInfoTable object)
39 /// returns a pointer to a PawnInfo object.
43 friend class PawnInfoTable;
46 Value mg_value() const;
47 Value eg_value() const;
48 Value kingside_storm_value(Color c) const;
49 Value queenside_storm_value(Color c) const;
50 Bitboard passed_pawns() const;
51 bool file_is_half_open(Color c, File f) const;
52 bool has_open_file_to_left(Color c, File f) const;
53 bool has_open_file_to_right(Color c, File f) const;
60 int16_t mgValue, egValue;
61 int8_t ksStormValue[2], qsStormValue[2];
62 uint8_t halfOpenFiles[2];
66 /// The PawnInfoTable class represents a pawn hash table. It is basically
67 /// just an array of PawnInfo objects and a few methods for accessing these
68 /// objects. The most important method is get_pawn_info, which looks up a
69 /// position in the table and returns a pointer to a PawnInfo object.
74 PawnInfoTable(unsigned numOfEntries);
77 PawnInfo *get_pawn_info(const Position &pos);
89 inline Value PawnInfo::mg_value() const {
90 return Value(mgValue);
93 inline Value PawnInfo::eg_value() const {
94 return Value(egValue);
97 inline Bitboard PawnInfo::passed_pawns() const {
101 inline Value PawnInfo::kingside_storm_value(Color c) const {
102 return Value(ksStormValue[c]);
105 inline Value PawnInfo::queenside_storm_value(Color c) const {
106 return Value(qsStormValue[c]);
109 inline bool PawnInfo::file_is_half_open(Color c, File f) const {
110 return (halfOpenFiles[c] & (1 << int(f)));
113 inline bool PawnInfo::has_open_file_to_left(Color c, File f) const {
114 return halfOpenFiles[c] & ((1 << int(f)) - 1);
117 inline bool PawnInfo::has_open_file_to_right(Color c, File f) const {
118 return halfOpenFiles[c] & ~((1 << int(f+1)) - 1);
121 inline void PawnInfo::clear() {
122 mgValue = egValue = 0;
123 passedPawns = EmptyBoardBB;
124 ksStormValue[WHITE] = ksStormValue[BLACK] = 0;
125 qsStormValue[WHITE] = qsStormValue[BLACK] = 0;
126 halfOpenFiles[WHITE] = halfOpenFiles[BLACK] = 0xFF;
130 #endif // !defined(PAWNS_H_INCLUDED)