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-2009 Marco Costalba
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.
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.
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/>.
21 #if !defined(EVALUATE_H_INCLUDED)
22 #define EVALUATE_H_INCLUDED
37 /// The EvalInfo struct contains various information computed and collected
38 /// by the evaluation function. An EvalInfo object is passed as one of the
39 /// arguments to the evaluation function, and the search can make use of its
40 /// contents to make intelligent search decisions.
42 /// At the moment, this is not utilized very much: The only part of the
43 /// EvalInfo object which is used by the search is futilityMargin.
48 // Middle game and endgame evaluations
49 Value mgValue, egValue;
51 // Pointers to material and pawn hash table entries
55 // attackedBy[color][piece type] is a bitboard representing all squares
56 // attacked by a given color and piece type, attackedBy[color][0] contains
57 // all squares attacked by the given color.
58 Bitboard attackedBy[2][8];
59 Bitboard attacked_by(Color c) const { return attackedBy[c][0]; }
60 Bitboard attacked_by(Color c, PieceType pt) const { return attackedBy[c][pt]; }
62 // kingZone[color] is the zone around the enemy king which is considered
63 // by the king safety evaluation. This consists of the squares directly
64 // adjacent to the king, and the three (or two, for a king on an edge file)
65 // squares two ranks in front of the king. For instance, if black's king
66 // is on g8, kingZone[WHITE] is a bitboard containing the squares f8, h8,
67 // f7, g7, h7, f6, g6 and h6.
70 // kingAttackersCount[color] is the number of pieces of the given color
71 // which attack a square in the kingZone of the enemy king.
72 int kingAttackersCount[2];
74 // kingAttackersWeight[color] is the sum of the "weight" of the pieces of the
75 // given color which attack a square in the kingZone of the enemy king. The
76 // weights of the individual piece types are given by the variables
77 // QueenAttackWeight, RookAttackWeight, BishopAttackWeight and
78 // KnightAttackWeight in evaluate.cpp
79 int kingAttackersWeight[2];
81 // kingAdjacentZoneAttacksCount[color] is the number of attacks to squares
82 // directly adjacent to the king of the given color. Pieces which attack
83 // more than one square are counted multiple times. For instance, if black's
84 // king is on g8 and there's a white knight on g5, this knight adds
85 // 2 to kingAdjacentZoneAttacksCount[BLACK].
86 int kingAdjacentZoneAttacksCount[2];
88 // mateThreat[color] is a move for the given side which gives a direct mate.
91 // Middle game and endgame mobility scores.
92 Value mgMobility, egMobility;
94 // Extra futility margin. This is added to the standard futility margin
95 // in the quiescence search.
104 extern Value evaluate(const Position& pos, EvalInfo& ei, int threadID);
105 extern Value quick_evaluate(const Position& pos);
106 extern void init_eval(int threads);
107 extern void quit_eval();
108 extern void read_weights(Color sideToMove);
111 #endif // !defined(EVALUATE_H_INCLUDED)