]> git.sesse.net Git - stockfish/blob - src/evaluate.h
Expose EvalInfo struct to search
[stockfish] / src / evaluate.h
1 /*
2   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3   Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
4   Copyright (C) 2008-2013 Marco Costalba, Joona Kiiski, Tord Romstad
5
6   Stockfish is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   Stockfish is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #if !defined(EVALUATE_H_INCLUDED)
21 #define EVALUATE_H_INCLUDED
22
23 #include "material.h"
24 #include "pawns.h"
25 #include "types.h"
26
27 class Position;
28
29 namespace Eval {
30
31 // Struct Eval::Info contains various information computed and collected
32 // by the evaluation functions.
33 struct Info {
34
35   // Pointers to material and pawn hash table entries
36   Material::Entry* mi;
37   Pawns::Entry* pi;
38
39   // attackedBy[color][piece type] is a bitboard representing all squares
40   // attacked by a given color and piece type, attackedBy[color][ALL_PIECES]
41   // contains all squares attacked by the given color.
42   Bitboard attackedBy[COLOR_NB][PIECE_TYPE_NB];
43
44   // kingRing[color] is the zone around the king which is considered
45   // by the king safety evaluation. This consists of the squares directly
46   // adjacent to the king, and the three (or two, for a king on an edge file)
47   // squares two ranks in front of the king. For instance, if black's king
48   // is on g8, kingRing[BLACK] is a bitboard containing the squares f8, h8,
49   // f7, g7, h7, f6, g6 and h6.
50   Bitboard kingRing[COLOR_NB];
51
52   // kingAttackersCount[color] is the number of pieces of the given color
53   // which attack a square in the kingRing of the enemy king.
54   int kingAttackersCount[COLOR_NB];
55
56   // kingAttackersWeight[color] is the sum of the "weight" of the pieces of the
57   // given color which attack a square in the kingRing of the enemy king. The
58   // weights of the individual piece types are given by the variables
59   // QueenAttackWeight, RookAttackWeight, BishopAttackWeight and
60   // KnightAttackWeight in evaluate.cpp
61   int kingAttackersWeight[COLOR_NB];
62
63   // kingAdjacentZoneAttacksCount[color] is the number of attacks to squares
64   // directly adjacent to the king of the given color. Pieces which attack
65   // more than one square are counted multiple times. For instance, if black's
66   // king is on g8 and there's a white knight on g5, this knight adds
67   // 2 to kingAdjacentZoneAttacksCount[BLACK].
68   int kingAdjacentZoneAttacksCount[COLOR_NB];
69 };
70
71 extern void init();
72 extern Value evaluate(const Position& pos, Value& margin, Info* ei);
73 extern std::string trace(const Position& pos);
74
75 }
76
77 #endif // !defined(EVALUATE_H_INCLUDED)